fix: treat empty-string solver_options_file as unset#714
Merged
Conversation
shared_options() and apply_solver_specs() gated the
load_solver_options_file() call on _hasit(cfg, ...), which returns
True for any non-None value -- including "". Callers that default
solver_options_file or {name}_solver_options_file to "" (e.g. as a
YAML/JSON sentinel for "no file") were hitting
FileNotFoundError: [Errno 2] No such file or directory: ''.
Replace _hasit with a plain truthiness check on the path. None and
"" are both treated as unset, matching conventional file-path-arg
semantics. No other _hasit semantics changed.
Adds regression tests in test_solver_options_layers.py for both
the global flag and a per-spoke flag.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #714 +/- ##
==========================================
- Coverage 71.43% 71.42% -0.02%
==========================================
Files 154 154
Lines 19463 19463
==========================================
- Hits 13903 13901 -2
- Misses 5560 5562 +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
shared_options()andapply_solver_specs()gated theload_solver_options_file()call on_hasit(cfg, ...), which returnsTruefor any non-None value — including\"\".solver_options_file(or any{name}_solver_options_file) to\"\"as a "no file" sentinel were hittingFileNotFoundError: [Errno 2] No such file or directory: ''._hasitwith a plain truthiness check on the path. BothNoneand\"\"are now treated as unset, matching conventional file-path-arg semantics. No other_hasitsemantics changed.Test plan
test_solver_options_layers.py(one for the global flag, one for the per-spoke{name}_solver_options_file); both pass.python -m pytest mpisppy/tests/test_solver_options_layers.py— 64/64 pass.ruff checkclean on touched files.Configwithcfg.solver_options_file = \"\"no longer raisesFileNotFoundErrorfromshared_options.🤖 Generated with Claude Code