Repository navigation
Serialize all OutcomeConstraints uniformly via expression in JSON - #5326
Open
saitcakmak wants to merge 1 commit into
Open
saitcakmak wants to merge 1 commit into
saitcakmak wants to merge 1 commit into
Conversation
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
|
@saitcakmak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D135145413. |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
outcome_constraint_to_dictto serialize everyOutcomeConstraint(single-metric, multi-metric,ObjectiveThreshold, andScalarizedOutcomeConstraint) uniformly as{"__type": "OutcomeConstraint", "expression": ..., "metric_name_to_signature": ...}instead of branching by class or metric count.scalarized_outcome_constraint_to_dictand_build_constraint_dict; mapScalarizedOutcomeConstrainttooutcome_constraint_to_dictinCORE_ENCODER_REGISTRYand pass constraint lists directly in_build_opt_config_dict."OutcomeConstraint","ObjectiveThreshold","ScalarizedOutcomeConstraint") intact so old JSON payloads continue to deserialize cleanly.Differential Revision: D135145413