Skip to content

Validate all sympy-parsed inputs early with clear error messages#5196

Open
bernardbeckerman wants to merge 1 commit intofacebook:mainfrom
bernardbeckerman:export-D100058027
Open

Validate all sympy-parsed inputs early with clear error messages#5196
bernardbeckerman wants to merge 1 commit intofacebook:mainfrom
bernardbeckerman:export-D100058027

Conversation

@bernardbeckerman
Copy link
Copy Markdown
Contributor

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

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
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 29, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 29, 2026

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

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.38%. Comparing base (12ebbd9) to head (56a239a).

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.
📢 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.

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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants