Skip to content

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

Open
bernalde wants to merge 3 commits into
pr/ci-cd-pyomofrom
pr/pyomo-dependencies
Open

PR 2/7: Pyomo optional dependencies and module structure#7
bernalde wants to merge 3 commits into
pr/ci-cd-pyomofrom
pr/pyomo-dependencies

Conversation

@bernalde
Copy link
Copy Markdown
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 a4d2f9a to c60cf5e Compare April 2, 2026 22:19
Comment thread lyopronto/pyomo_models/__init__.py Outdated
Co-authored-by: Copilot <copilot@github.com>
Comment thread lyopronto/pyomo_models/__init__.py Outdated
@@ -0,0 +1,49 @@
# Copyright 2019-2025, Gayathri Shivkumar, Petr S. Kazarin, Alina A. Alexeenko
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some files are copyright to lyohub members, some are to david, why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 28d0898. Updated the new lyopronto/pyomo_models/__init__.py header to Copyright (C) 2026, SECQUOIA so the Pyomo package files use a single SECQUOIA-owned header.

Comment thread lyopronto/pyomo_models/__init__.py Outdated
Comment thread tests/test_pyomo_models/__init__.py Outdated
@@ -0,0 +1,2 @@
# Copyright 2019-2025, SECQUOIA
# Tests for Pyomo-based optimization models.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 28d0898. Removed the placeholder tests/test_pyomo_models/__init__.py file and added real initializer coverage in tests/test_pyomo_models/test_init.py.

Comment thread tests/test_pyomo_models/__init__.py Outdated
Copy link
Copy Markdown
Member Author

@bernalde bernalde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the PR diff, packaging metadata, Pyomo roadmap/conventions, test docs, CI workflows, and surrounding package/test structure. GitHub would not allow REQUEST_CHANGES because the authenticated account is the PR author, so I am leaving this as a COMMENT review with blocking findings. Tests run: Python 3.13.5; python -m pytest tests/ -n auto -v -m "not notebook and not pyomo" --cov=lyopronto --cov-report=term-missing passed 235, skipped 2 in 570.66s; python -m pytest tests/ -n auto -v -m "pyomo" --cov=lyopronto --cov-report=term-missing collected 0 tests and exited 5; python -m pip install --dry-run --no-build-isolation ".[optimization]" resolved on Python 3.13; cross-version resolver check for Python 3.8 failed with ResolutionImpossible. I would not merge this until the blocking issues above are addressed.

Comment thread pyproject.toml Outdated
Comment thread lyopronto/pyomo_models/__init__.py Outdated
Comment thread lyopronto/pyomo_models/__init__.py Outdated
Comment thread pyproject.toml Outdated
@bernalde
Copy link
Copy Markdown
Member Author

bernalde commented May 7, 2026

Follow-up on the copyright-header discussion: PR #7 currently leaves pre-existing upstream files' copyright notices untouched and uses Copyright (C) 2026, SECQUOIA only on files added by this PR. I opened upstream issue LyoHUB#27 to ask for a repository-level convention before applying this more broadly. Since this PR is part of the SECQUOIA Pyomo stack, later stacked PRs may need to be rebased or adjusted to follow the same policy once upstream clarifies it.

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.

2 participants