Skip to content

Commit 3bcf8c4

Browse files
mgrange1998meta-codesync[bot]
authored andcommitted
Remove deprecated ObjectiveThreshold assert_is_instance checks (#5105)
Summary: Pull Request resolved: #5105 After the recent refactoring in D93520819 that deprecated `ObjectiveThreshold` in favor of plain `OutcomeConstraint`, two locations in the codebase still used `assert_is_instance(..., ObjectiveThreshold)` which would fail when objective thresholds are represented as plain `OutcomeConstraint` objects (the new recommended pattern). This caused Axolotl to crash with: ``` TypeError: obj is not an instance of cls: obj=OutcomeConstraint(core_app:ecosystem:linked_sessions:fb_session_count_cap30 >= 58.924384179812996) cls=<class 'ax.core.outcome_constraint.ObjectiveThreshold'> ``` Changes: - `ax/storage/sqa_store/encoder.py`: Updated `objective_threshold_to_sqa` to accept `OutcomeConstraint` instead of `ObjectiveThreshold`, and removed the `assert_is_instance` cast at the call site. Since `ObjectiveThreshold` is deprecated and `MultiObjectiveOptimizationConfig.objective_thresholds` is typed as `list[OutcomeConstraint]`, these assertions were incorrect. Reviewed By: mpolson64 Differential Revision: D98172405 fbshipit-source-id: 98ad65db14e473ac45c721e7a9ad0963724d7fdf
1 parent 316dbad commit 3bcf8c4

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

ax/storage/sqa_store/encoder.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@
3939
OptimizationConfig,
4040
PreferenceOptimizationConfig,
4141
)
42-
from ax.core.outcome_constraint import (
43-
ObjectiveThreshold,
44-
OutcomeConstraint,
45-
ScalarizedOutcomeConstraint,
46-
)
42+
from ax.core.outcome_constraint import OutcomeConstraint, ScalarizedOutcomeConstraint
4743
from ax.core.parameter import (
4844
ChoiceParameter,
4945
DerivedParameter,
@@ -772,7 +768,7 @@ def scalarized_outcome_constraint_to_sqa(
772768

773769
def objective_threshold_to_sqa(
774770
self,
775-
objective_threshold: ObjectiveThreshold,
771+
objective_threshold: OutcomeConstraint,
776772
experiment_metrics: dict[str, Metric] | None = None,
777773
) -> SQAMetric:
778774
"""Convert Ax OutcomeConstraint to SQLAlchemy."""
@@ -847,9 +843,7 @@ def optimization_config_to_sqa(
847843
):
848844
for threshold in optimization_config.objective_thresholds:
849845
threshold_sqa = self.objective_threshold_to_sqa(
850-
objective_threshold=assert_is_instance(
851-
threshold, ObjectiveThreshold
852-
),
846+
objective_threshold=threshold,
853847
experiment_metrics=experiment_metrics,
854848
)
855849
metrics_sqa.append(threshold_sqa)

0 commit comments

Comments
 (0)