Skip to content

Serialize all OutcomeConstraints uniformly via expression in JSON - #5326

Open
saitcakmak wants to merge 1 commit into
meta:mainfrom
saitcakmak:export-D135145413
Open

saitcakmak wants to merge 1 commit into
meta:mainfrom
saitcakmak:export-D135145413

Conversation

@saitcakmak

Copy link
Copy Markdown
Contributor

Summary:
All outcome constraint subclasses are represented by an expression under the hood. The separate storage logic is leftover from the legacy setup. This diff unifies the encoders to simplify things.

What Changed

  • Simplify outcome_constraint_to_dict to serialize every OutcomeConstraint (single-metric, multi-metric, ObjectiveThreshold, and ScalarizedOutcomeConstraint) uniformly as {"__type": "OutcomeConstraint", "expression": ..., "metric_name_to_signature": ...} instead of branching by class or metric count.
  • Remove scalarized_outcome_constraint_to_dict and _build_constraint_dict; map ScalarizedOutcomeConstraint to outcome_constraint_to_dict in CORE_ENCODER_REGISTRY and pass constraint lists directly in _build_opt_config_dict.
  • Keep legacy decoder entries ("OutcomeConstraint", "ObjectiveThreshold", "ScalarizedOutcomeConstraint") intact so old JSON payloads continue to deserialize cleanly.

Differential Revision: D135145413

Summary:
All outcome constraint subclasses are represented by an expression under the hood. The separate storage logic is leftover from the legacy setup. This diff unifies the encoders to simplify things.

## What Changed
- Simplify `outcome_constraint_to_dict` to serialize every `OutcomeConstraint` (single-metric, multi-metric, `ObjectiveThreshold`, and `ScalarizedOutcomeConstraint`) uniformly as `{"__type": "OutcomeConstraint", "expression": ..., "metric_name_to_signature": ...}` instead of branching by class or metric count.
- Remove `scalarized_outcome_constraint_to_dict` and `_build_constraint_dict`; map `ScalarizedOutcomeConstraint` to `outcome_constraint_to_dict` in `CORE_ENCODER_REGISTRY` and pass constraint lists directly in `_build_opt_config_dict`.
- Keep legacy decoder entries (`"OutcomeConstraint"`, `"ObjectiveThreshold"`, `"ScalarizedOutcomeConstraint"`) intact so old JSON payloads continue to deserialize cleanly.

Differential Revision: D135145413
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Dec 2, 2026
@meta-codesync

meta-codesync Bot commented Dec 2, 2026

Copy link
Copy Markdown

@saitcakmak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D135145413.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.77778% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.62%. Comparing base (a86d5b0) to head (4b2d424).

Files with missing lines Patch % Lines
ax/storage/json_store/encoders.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5326   +/-   ##
=======================================
  Coverage   96.62%   96.62%           
=======================================
  Files         621      621           
  Lines       71324    71358   +34     
=======================================
+ Hits        68915    68949   +34     
  Misses       2409     2409           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants