PR 3/7: Pyomo utilities and single-step optimization#8
Conversation
fa26a34 to
65fc2c3
Compare
6fa03b3 to
58d26cd
Compare
65fc2c3 to
b8a82c3
Compare
pytest -m 'pyomo' exits with code 5 when no pyomo-marked tests exist. This is expected until PR #8 adds the first pyomo tests. Treat exit code 5 as success so the Pyomo Tests job passes gracefully.
58d26cd to
72e8b86
Compare
b8a82c3 to
53ad6d9
Compare
72e8b86 to
9b54119
Compare
53ad6d9 to
389c49e
Compare
Source fixes: - calc_knownRp.py: use constant.Torr_to_mTorr instead of literal 1000.0 in early-return path, with regression test Test fixes: - Fix percent-dried scale bug: 0.99 -> 99.0 across test_regression.py (5), test_optimizer.py (1), test_opt_Pch_Tsh_coverage.py (2+2), test_opt_Pch_coverage.py (2) - test_coverage_gaps.py: remove duplicate TestIneqConstraints class - test_functions.py: add value assertions to TestIneqConstraints - test_regression.py: skip column 0 (time) in stability test - test_calculators.py: add meaningful assertion in test_higher_pressure_dries_faster - test_web_interface.py, test_calc_unknownRp_coverage.py: use reference_data_path fixture instead of relative paths - test_calc_knownRp.py: add regression test for mTorr conversion Config fixes: - pyproject.toml: remove duplicate [tool.pytest.ini_options] (pytest.ini takes precedence) - pytest.ini: update minversion from 3.8 to 7.4 - requirements-dev.txt: add pytest-mock (matches pyproject.toml [dev]) CI fixes: - pr-tests.yml, tests.yml, slow-tests.yml: consolidate triple pip install into single pip install -e ".[dev]" - Remove hardcoded PR #8 reference from pyomo fallback messages Script fixes: - run_local_ci.sh: remove emojis, replace grep -oP with portable -oE, remove set -e/dead-code if-block, remove hardcoded -n 8, use pip install -e ".[dev]" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9b54119 to
a4d2f9a
Compare
c4356ba to
15eb233
Compare
a4d2f9a to
c60cf5e
Compare
pytest -m 'pyomo' exits with code 5 when no pyomo-marked tests exist. This is expected until PR #8 adds the first pyomo tests. Treat exit code 5 as success so the Pyomo Tests job passes gracefully.
This PR adds the foundational Pyomo modules: lyopronto/pyomo_models/utils.py (254 lines): - Warmstart utilities for initializing from scipy solutions - Variable scaling functions for numerical stability - Validation helpers for checking physical constraints - Result extraction and formatting utilities lyopronto/pyomo_models/single_step.py (427 lines): - Single time-point optimization formulation - Direct Pyomo model for one drying step - Basis for multi-period trajectory optimization - Physics constraints as Pyomo constraints Tests: - tests/test_pyomo_models/test_model_single_step.py - tests/test_pyomo_models/README.md These utilities are used by the multi-period model (PR 4) and the optimizer functions (PR 5).
15eb233 to
38607c8
Compare
bernalde
left a comment
There was a problem hiding this comment.
- Blocking issues: equipment capability can be silently omitted when
eq_capis provided withoutnVial; infeasible/non-optimal solves are returned as usable solutions;extract_solution_to_arrayadvertises the standard output format but writes rawdmdtand a placeholder dried percentage. - Nonblocking issues: the Pyomo test skip guard imports the Pyomo submodule before checking availability.
- Questions: none.
- Tests run and outcomes:
env PYTHONPATH=/tmp/LyoPRONTO_pr8 MPLCONFIGDIR=/tmp/mplconfig pytest tests/test_pyomo_models/test_init.py tests/test_pyomo_models/test_model_single_step.py -m "not slow": 11 passed.env PYTHONPATH=/tmp/LyoPRONTO_pr8 MPLCONFIGDIR=/tmp/mplconfig pytest tests/test_pyomo_models/test_model_single_step.py -m "slow": 3 passed.env PYTHONPATH=/tmp/LyoPRONTO_pr8 MPLCONFIGDIR=/tmp/mplconfig pytest tests/ -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models: 235 passed, 2 skipped.- Initial run from
/tmp/lyopronto-pr8failed because the dash in the worktree directory name made pytest import the repo root under an invalid package name; reran from/tmp/LyoPRONTO_pr8.
- Merge recommendation: do not merge as-is.
I would not merge this until the blocking issues above are addressed.
bernalde
left a comment
There was a problem hiding this comment.
Reviewed current head c271b60. No blocking issues found. GitHub would not allow APPROVE because the authenticated account is the PR author, so I am submitting this as COMMENT. One nonblocking CI coverage issue is inline. Tests run: pytest tests/test_pyomo_models/test_init.py tests/test_pyomo_models/test_model_single_step.py -m "not slow" passed 13; pytest tests/test_pyomo_models/test_model_single_step.py -m "slow" passed 4; pytest tests/test_pyomo_models/ -v passed 17; pytest tests/ -n auto -v -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models --cov=lyopronto --cov-report=term-missing passed 235, skipped 2; pytest tests/ -n auto -v -m "pyomo" --cov=lyopronto --cov-report=term-missing passed 13; python -m ruff check lyopronto/pyomo_models tests/test_pyomo_models passed; git diff --check origin/pr/pyomo-dependencies...HEAD passed.
| if [ "${{ steps.mode.outputs.mode }}" == "fast" ]; then | ||
| echo "Draft PR: Skipping notebook and pyomo tests for fast feedback" | ||
| pytest tests/ -n auto -v -m "not notebook and not pyomo" | ||
| pytest tests/ -n auto -v -m "not notebook and not pyomo" --ignore=tests/test_pyomo_models |
There was a problem hiding this comment.
Nonblocking: Ignoring the whole tests/test_pyomo_models directory here means the non-Pyomo PR job no longer runs tests/test_pyomo_models/test_init.py, and the Pyomo job uses -m "pyomo", so that unmarked initializer/export smoke test is not covered there either. This weakens CI coverage for the optional-package import path added in PR #7. Prefer ignoring only the Pyomo-dependent model/solver test files, or move/mark the initializer test so it is still exercised by one CI job; apply the same pattern to the matching --ignore=tests/test_pyomo_models changes in the other workflows.
Summary
Core Pyomo building blocks.
utils.pyprovides parameter conversion from LyoPRONTO dicts to Pyomo-compatible formats, variable bound defaults, and warmstart helpers.single_step.pyimplements a single time-step steady-state optimization (one NLP solve per step), mirroring the scipy optimizer's step-by-step approach.PR 3 of 7 in the Pyomo integration series.
Changes
lyopronto/pyomo_models/utils.py— Shared utilities (variable bounds, parameter loading, warmstart)lyopronto/pyomo_models/single_step.py— Single time-step Pyomo modeltests/test_pyomo_models/test_model_single_step.py— 307 lines of teststests/test_pyomo_models/README.md— Test documentationKey Design Decisions
Pch(0.05–0.5 Torr),Tsh(-50–50°C),Tsub(-60–0°C)exp()PR Chain
Testing
~307 lines of new tests covering single-step model creation, solving, and parameter validation.