Skip to content

PR 2/7: Pyomo optional dependencies and module structure#7

Open
bernalde wants to merge 1 commit intopr/ci-cd-pyomofrom
pr/pyomo-dependencies
Open

PR 2/7: Pyomo optional dependencies and module structure#7
bernalde wants to merge 1 commit intopr/ci-cd-pyomofrom
pr/pyomo-dependencies

Conversation

@bernalde
Copy link
Member

@bernalde bernalde commented Mar 3, 2026

Summary

Adds Pyomo as an optional dependency (pip install lyopronto[optimization]). Creates the lyopronto.pyomo_models package with a PYOMO_AVAILABLE flag and graceful import handling. Pyomo coexists with scipy — both remain available.

PR 2 of 7 in the Pyomo integration series.

Changes

  • lyopronto/pyomo_models/__init__.py — Module init with lazy imports, availability check
  • pyproject.toml — Add [project.optional-dependencies] for optimization extra (pyomo, idaes-pse)
  • tests/test_pyomo_models/__init__.py — Test package init

Key Design Decision

Coexistence, not replacement. Installing the optimization extra adds Pyomo alongside scipy. The core package works without Pyomo. Code checks PYOMO_AVAILABLE before using Pyomo features.

PR Chain

# PR Status
0 Sync upstream (#5) Merged
1 CI/CD for Pyomo (#6) Open
2 Pyomo dependencies (this PR)
3 Utils & single-step Pending
4 Multi-period model Pending
5 Optimizer functions Pending
6 Benchmarks Pending
7 Docs & examples Pending

Testing

No new tests added. Import test validates graceful fallback when Pyomo is not installed.

This PR adds the foundation for Pyomo integration:

pyproject.toml changes:
- Add [optimization] extra with pyomo>=6.7.0 and idaes-pse>=2.9.0
- These are optional dependencies, scipy-based code works without them

Module structure:
- lyopronto/pyomo_models/__init__.py: Placeholder with documentation
- tests/test_pyomo_models/__init__.py: Test directory placeholder

Installation:
  pip install .[optimization]  # For Pyomo support
  pip install .                # Standard scipy-only installation

This enables users to opt-in to Pyomo optimization without affecting
existing scipy-based workflows.
@bernalde bernalde force-pushed the pr/pyomo-dependencies branch from 72e8b86 to 9b54119 Compare March 3, 2026 18:07
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