Skip to content

fix: treat empty-string solver_options_file as unset#714

Merged
DLWoodruff merged 1 commit into
Pyomo:mainfrom
DLWoodruff:fix-empty-solver-options-file
May 20, 2026
Merged

fix: treat empty-string solver_options_file as unset#714
DLWoodruff merged 1 commit into
Pyomo:mainfrom
DLWoodruff:fix-empty-solver-options-file

Conversation

@DLWoodruff
Copy link
Copy Markdown
Collaborator

Summary

  • 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 any {name}_solver_options_file) to \"\" as a "no file" sentinel were hitting FileNotFoundError: [Errno 2] No such file or directory: ''.
  • Replace _hasit with a plain truthiness check on the path. Both None and \"\" are now treated as unset, matching conventional file-path-arg semantics. No other _hasit semantics changed.

Test plan

  • Two regression tests added in 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 check clean on touched files.
  • Manual: a Config with cfg.solver_options_file = \"\" no longer raises FileNotFoundError from shared_options.

🤖 Generated with Claude Code

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
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.42%. Comparing base (265345b) to head (da61698).

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

@DLWoodruff DLWoodruff merged commit df879ae into Pyomo:main May 20, 2026
31 checks passed
@DLWoodruff DLWoodruff deleted the fix-empty-solver-options-file branch May 20, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant