Make pandas, scipy, and matplotlib optional dependencies via attempt_import#646
Make pandas, scipy, and matplotlib optional dependencies via attempt_import#646DLWoodruff merged 4 commits intomainfrom
attempt_import#646Conversation
Agent-Logs-Url: https://github.com/Pyomo/mpi-sppy/sessions/694e68f0-81c1-43f9-abfc-e8a2fe895f20 Co-authored-by: bknueven <30801372+bknueven@users.noreply.github.com>
attempt_import
|
@DLWoodruff I'm a bit ambivalent about having |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #646 +/- ##
==========================================
+ Coverage 70.15% 70.17% +0.02%
==========================================
Files 153 153
Lines 18905 18905
==========================================
+ Hits 13262 13267 +5
+ Misses 5643 5638 -5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
As we do more with the stochastic problem itself (e.g., confidence intervals), we will use it a little more; however, it is hard to argue that a soft dependency really hurts anyone. It makes some sense to have as many dependencies as possible be soft. So I say we merge this. |
straight_tests.py exercises mmw which requires scipy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Several packages used by mpi-sppy (
pandas,scipy,matplotlib) were either undeclared or treated as hard requirements, preventing lightweight installs for users who don't need those features.Changes
Package metadata (
pyproject.toml,setup.py)pandasandscipyfrom required dependencies[pandas],[scipy],[plot](matplotlib)Deferred imports — replaced direct imports with Pyomo's lazy-loading mechanism:
pandas: 4 files (rho_utils,wtracker,phtracker,primal_dual_converger)scipy: 5 files (prox_approx,seqsampling,zhat4xhat,mmw_ci,kkt/interface)matplotlib.pyplot: 2 files (phtracker,primal_dual_converger)The deferred import pattern (already used in the repo for
networkx,dill,yaml) allows modules to load without these packages installed; errors are raised only when the optional functionality is actually invoked.