Validate all sympy-parsed inputs early with clear error messages#5196
Open
bernardbeckerman wants to merge 1 commit intofacebook:mainfrom
Open
Validate all sympy-parsed inputs early with clear error messages#5196bernardbeckerman wants to merge 1 commit intofacebook:mainfrom
bernardbeckerman wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary: 1. **`ax/core/parameter.py` (`DerivedParameter._parse_expression_str`)**: Wrapped bare `sympify()` call in try/except to convert `SympifyError` to `UserInputError` with a descriptive message. 2. **`ax/utils/common/sympy.py` (`parse_objective_expression`)**: Wrapped bare `sympify()` call in try/except to convert `SympifyError` to `UserInputError`. 3. **`ax_core_instantiation_utils.py` (`_make_objectives`)**: Migrated from `MultiObjective(objectives=[...])` to the new expression-based `Objective(expression=..., metric_name_to_signature=...)` API. This is a behavioral change: objectives are now constructed using a single `Objective` with a comma-separated expression string instead of wrapping individual `Objective` instances in a `MultiObjective`. The corresponding test in `base_utils_test.py` is updated to match. Differential Revision: D100058027
|
@bernardbeckerman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D100058027. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5196 +/- ##
==========================================
- Coverage 96.38% 96.38% -0.01%
==========================================
Files 617 617
Lines 69463 69474 +11
==========================================
+ Hits 66954 66963 +9
- Misses 2509 2511 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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:
ax/core/parameter.py(DerivedParameter._parse_expression_str): Wrapped baresympify()call in try/except to convertSympifyErrortoUserInputErrorwith a descriptive message.ax/utils/common/sympy.py(parse_objective_expression): Wrapped baresympify()call in try/except to convertSympifyErrortoUserInputError.ax_core_instantiation_utils.py(_make_objectives): Migrated fromMultiObjective(objectives=[...])to the new expression-basedObjective(expression=..., metric_name_to_signature=...)API. This is a behavioral change: objectives are now constructed using a singleObjectivewith a comma-separated expression string instead of wrapping individualObjectiveinstances in aMultiObjective. The corresponding test inbase_utils_test.pyis updated to match.Differential Revision: D100058027