Skip to content

distr example cleanup: typo, dead code, kwarg defaults, go.bash modernization#687

Merged
DLWoodruff merged 1 commit into
Pyomo:mainfrom
DLWoodruff:distr-example-cleanup
May 13, 2026
Merged

distr example cleanup: typo, dead code, kwarg defaults, go.bash modernization#687
DLWoodruff merged 1 commit into
Pyomo:mainfrom
DLWoodruff:distr-example-cleanup

Conversation

@DLWoodruff
Copy link
Copy Markdown
Collaborator

Summary

Four review items from a walkthrough of examples/distr/distr.py, bundled into one PR. Independent of the phase-A work in PR #686.

  • Typo + vague description. The --scalable CLI option's help string said "decides whether a sclale model is used". Fix the typo and broaden the wording to explain what the flag actually does: "generate pseudo-random data parameterized by --mnpr instead of using the hardwired 2/3/4-region datasets". Apply the same description to examples/stoch_distr/stoch_distr.py for consistency.

  • Dead code in scenario_denouement. Five lines after an unconditional return (pprint/print calls) — removed.

  • Misleading kwarg defaults. scenario_creator declared inter_region_dict=None, cfg=None, data_params=None, all_nodes_dict=None and then assert ... is not None on entry. For inter_region_dict and cfg this is misleading — kw_creator always passes them and the =None defaults imply optionality. Make them required kwargs and let Python's missing-arg error report the problem naturally. Keep =None defaults on data_params / all_nodes_dict (genuinely scalable-only). Rewrite the (stale) docstring to match.

  • go.bash modernization (Move and generalize license re-try loop logic in PHBase #3 from the review list). Switch to generic_cylinders --admm, matching the recommendation we put at the top of admmWrapper.rst in PR ADMM doc cross-refs, BFs flow-through, stage2ef hard error #685. The legacy custom driver distr_admm_cylinders.py stays in the directory for reference; go.bash has a comment pointing at the doc rationale.

Test plan

  • bash go.bash (SOLVERNAME=gurobi_persistent locally) — converges to 2.1% gap (below the 5% target)
  • python -m pytest mpisppy/tests/test_admm_bundler.py — 26/26 pass
  • python -m pytest mpisppy/tests/test_admmWrapper.py — 6/7 pass; the 7th (test_values) is a pre-existing flaky subprocess-capture failure that also fails on clean main (same pattern as test_stoch_admmWrapper::test_values)
  • ruff check examples/distr/distr.py examples/stoch_distr/stoch_distr.py — clean

🤖 Generated with Claude Code

…nization

Four review items from the distr.py walkthrough:

  - typo: "sclale" -> "scalable" in the --scalable CLI description.
    Also broaden the description to actually explain what the flag
    does ("generate pseudo-random data parameterized by --mnpr
    instead of using the hardwired 2/3/4-region datasets") and apply
    the same description to stoch_distr.py for consistency.

  - dead code: scenario_denouement had four lines of pprint/print
    after an unconditional `return`.  Drop them.

  - misleading kwarg defaults: scenario_creator declared all four
    kwargs (inter_region_dict, cfg, data_params, all_nodes_dict) as
    `=None` and then assert-not-None on entry.  For inter_region_dict
    and cfg this is misleading: kw_creator always passes them and the
    None defaults imply optionality.  Make them required positional
    kwargs; let Python's missing-arg error report the problem
    naturally instead of an opaque assertion.  Keep `=None` on
    data_params / all_nodes_dict since they really are
    scalable-only.  Rewrite the (stale) docstring to match.

  - go.bash modernization: switch to `generic_cylinders --admm`
    matching the documented recommendation at the top of admmWrapper
    pages from PR Pyomo#685.  The legacy custom driver
    `distr_admm_cylinders.py` is still in the directory; a comment in
    go.bash points at the doc for the rationale.

Verified `bash go.bash` (with SOLVERNAME=gurobi_persistent for local
solver availability) — converges to 2.1% gap.  test_admm_bundler
still 26/26.  test_admmWrapper has a pre-existing test_values
subprocess-capture failure (returncode=1, same flaky pattern as
test_stoch_admmWrapper::test_values; verified failing on clean
main too).

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

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.03%. Comparing base (fcae16f) to head (bcc267a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #687   +/-   ##
=======================================
  Coverage   71.02%   71.03%           
=======================================
  Files         154      154           
  Lines       19252    19252           
=======================================
+ Hits        13674    13675    +1     
+ Misses       5578     5577    -1     

☔ 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 f49377c into Pyomo:main May 13, 2026
30 checks passed
@DLWoodruff DLWoodruff deleted the distr-example-cleanup branch May 13, 2026 22:40
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