Skip to content

display_timing: expose via Config and CLI (#290)#708

Merged
DLWoodruff merged 4 commits into
Pyomo:mainfrom
DLWoodruff:display-timing-in-config-290
May 18, 2026
Merged

display_timing: expose via Config and CLI (#290)#708
DLWoodruff merged 4 commits into
Pyomo:mainfrom
DLWoodruff:display-timing-in-config-290

Conversation

@DLWoodruff
Copy link
Copy Markdown
Collaborator

@DLWoodruff DLWoodruff commented May 17, 2026

Summary

  • Fixes display_timing should be in config.py #290. display_timing was a "secret menu" option that callers had to set on the options dict by hand. Move it into mpisppy.utils.config.Config next to display_progress and display_convergence_detail so it shows up under --help and propagates through cfg_vanilla the same way.
  • shared_options() now forwards cfg.display_timing into the hub's opt_kwargs.options.
  • subgradient_spoke, ph_dual_spoke, relaxed_ph_spoke hardcode options["display_timing"] = False, matching the existing pattern for the other two display flags (spokes should not print per-iteration diagnostics).
  • doc/src/secretmenu.rst: drop the display_timing section now that it's a first-class CLI option. The other two secret-menu entries (initial_proximal_cut_count, subgradient_while_waiting) remain.
  • doc/src/hubs.rst: mention the new --display-timing flag next to the existing --with-display-convergence-detail note so the option stays discoverable from the docs.
  • phbase.py:887-888 keeps its defensive default so PHBase can still be instantiated outside the cfg flow.

Test plan

  • ruff check clean on changed files
  • Config().popular_args(); cfg.display_timing works and defaults to False
  • New unit tests in mpisppy/tests/test_ef_ph.py::Test_sizes:
    • test_display_timing_emits_nonzero_solve_times runs PH iter0 with display_timing=True, captures stdout, asserts the "Pyomo solve times (seconds):" header appears, parses the min/mean/max stats line, and requires max > 0. Guards against a future refactor quietly dropping the option from self.options or the print path.
    • test_display_timing_off_suppresses_solve_times confirms the timing report is not printed when the flag is False, so the assertion above isn't catching unconditionally-emitted output.
  • CLI smoke test: examples/run_all.py now appends --display-timing to the existing sizes/sizes_cylinders.py run, so the run_all.py CI jobs exercise the new flag end-to-end through generic_cylinders.py-style invocation.
  • Generic cylinders integration: confirmed mpisppy/generic/parsing.py:120 calls cfg.popular_args(), so --display-timing automatically appears on python -m mpisppy.generic_cylinders --module-name ... --help with no additional wiring.
  • CI run on this PR

🤖 Generated with Claude Code

display_timing was previously a "secret menu" option that had to be set by
hand on the options dict. Bring it into mpisppy.utils.config.Config alongside
display_progress and display_convergence_detail so it is documented via
--help and propagates through cfg_vanilla like its siblings.

- mpisppy/utils/config.py: register display_timing (bool, default False).
- mpisppy/utils/cfg_vanilla.py:
  * shared_options(): forward cfg.display_timing into opt_kwargs.options.
  * subgradient_spoke, ph_dual_spoke, relaxed_ph_spoke: hardcode
    options["display_timing"] = False, matching the existing pattern for
    display_progress / display_convergence_detail (these spokes should not
    print per-iteration diagnostics).
- doc/src/secretmenu.rst: drop the display_timing section now that it's a
  first-class CLI option.

The defensive default in phbase.py:887-888 is left in place so PHBase can
still be instantiated outside the cfg flow with a manual options dict.

Fixes Pyomo#290

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.42%. Comparing base (bbe8fba) to head (27c6eac).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
mpisppy/utils/cfg_vanilla.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #708      +/-   ##
==========================================
+ Coverage   71.28%   71.42%   +0.13%     
==========================================
  Files         154      154              
  Lines       19438    19462      +24     
==========================================
+ Hits        13857    13901      +44     
+ Misses       5581     5561      -20     

☔ 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 and others added 3 commits May 17, 2026 16:53
- doc/src/hubs.rst: mention the new --display-timing flag next to the
  existing --with-display-convergence-detail note so the option is
  discoverable from the docs now that the secret-menu section was
  removed.
- examples/run_all.py: add --display-timing to the existing sizes
  sizes_cylinders.py command so the run_all CI jobs exercise the new
  CLI plumbing end-to-end as a smoke test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds two tests to Test_sizes in mpisppy/tests/test_ef_ph.py:

- test_display_timing_emits_nonzero_solve_times: runs PH iter0 with
  display_timing=True, captures stdout, asserts the
  "Pyomo solve times (seconds):" header appears, parses the
  min/mean/max stats line, and requires max > 0. Guards against a
  future refactor quietly dropping the option from self.options or
  the print path (issue Pyomo#290).
- test_display_timing_off_suppresses_solve_times: companion that
  confirms the timing report is NOT printed when the flag is False,
  so we know the assertion above isn't picking up output emitted
  unconditionally somewhere.

Both tests skip when no solver is available.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DLWoodruff DLWoodruff enabled auto-merge (squash) May 18, 2026 00:49
@DLWoodruff DLWoodruff merged commit 1cc109e into Pyomo:main May 18, 2026
29 checks passed
@DLWoodruff DLWoodruff deleted the display-timing-in-config-290 branch May 18, 2026 00:51
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.

display_timing should be in config.py

1 participant