display_timing: expose via Config and CLI (#290)#708
Merged
Conversation
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
- 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>
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
display_timingwas a "secret menu" option that callers had to set on the options dict by hand. Move it intompisppy.utils.config.Confignext todisplay_progressanddisplay_convergence_detailso it shows up under--helpand propagates throughcfg_vanillathe same way.shared_options()now forwardscfg.display_timinginto the hub'sopt_kwargs.options.subgradient_spoke,ph_dual_spoke,relaxed_ph_spokehardcodeoptions["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 thedisplay_timingsection 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-timingflag next to the existing--with-display-convergence-detailnote so the option stays discoverable from the docs.phbase.py:887-888keeps its defensive default soPHBasecan still be instantiated outside the cfg flow.Test plan
ruff checkclean on changed filesConfig().popular_args(); cfg.display_timingworks and defaults toFalsempisppy/tests/test_ef_ph.py::Test_sizes:test_display_timing_emits_nonzero_solve_timesruns PH iter0 withdisplay_timing=True, captures stdout, asserts the"Pyomo solve times (seconds):"header appears, parses themin/mean/maxstats line, and requiresmax > 0. Guards against a future refactor quietly dropping the option fromself.optionsor the print path.test_display_timing_off_suppresses_solve_timesconfirms the timing report is not printed when the flag isFalse, so the assertion above isn't catching unconditionally-emitted output.examples/run_all.pynow appends--display-timingto the existingsizes/sizes_cylinders.pyrun, so therun_all.pyCI jobs exercise the new flag end-to-end throughgeneric_cylinders.py-style invocation.mpisppy/generic/parsing.py:120callscfg.popular_args(), so--display-timingautomatically appears onpython -m mpisppy.generic_cylinders --module-name ... --helpwith no additional wiring.🤖 Generated with Claude Code