Skip to content

Make all wrapped tools optional dependencies#51

Merged
mathieu7an merged 1 commit intoEUFLOW:mainfrom
bjarketol:optional-tool-dependencies
Mar 23, 2026
Merged

Make all wrapped tools optional dependencies#51
mathieu7an merged 1 commit intoEUFLOW:mainfrom
bjarketol:optional-tool-dependencies

Conversation

@bjarketol
Copy link
Copy Markdown
Contributor

@bjarketol bjarketol commented Feb 25, 2026

Summary

  • Move pywake, floris, foxes, wayve, and code_saturne from hard dependencies to optional extras (pip install wifa[pywake], wifa[all], etc.)
  • Add wifa/_optional.py with a require() helper that raises clear ImportError messages with install instructions when a tool is missing
  • Add pytest.importorskip() to each tool's test module so tests skip cleanly when the tool is not installed

Details

All API modules already used lazy imports (tool packages imported inside function bodies), so import wifa works without any tools installed. This PR formalizes that by:

  1. pyproject.toml: Tools moved to [project.optional-dependencies] groups. scipy and pyyaml added as core deps (used at module level by API modules). mpmath moved to the wayve extra.
  2. wifa/_optional.py (new): Central require(package, extra) utility using importlib.util.find_spec().
  3. API modules: Each run_*() function calls require() at its top, giving actionable error messages before any tool import runs.
  4. wifa/wayve_api.py: matplotlib and mpmath moved to lazy imports inside the functions that use them. FoxesWakeModel import moved into the foxes branch of wake_model_setup().
  5. Test files: pytest.importorskip() added before tool imports so entire test modules skip when the tool is absent.
  6. wifa/__init__.py: Added missing run_floris export.

Verified

  • Bare install (pip install wifa): import wifa succeeds; calling any run_* gives a clear error with install instructions
  • Single tool (pip install wifa[pywake]): pywake tests pass, other tools' tests skip
  • All tools (pip install wifa[all]): all tests pass as before

Closes #50

Test plan

  • pip install wifa (bare) — verify import wifa works, run_pywake() etc. raise clear ImportError
  • pip install wifa[pywake] — verify pywake tests pass, other tests skip
  • pip install wifa[all] — verify all tests pass
  • CI pipeline passes

🤖 Generated with Claude Code

@bjarketol
Copy link
Copy Markdown
Contributor Author

@SchmJo @kilojoules @mathieu7an

Can one of you take a look at this? It's staggered on top of #55, so it should be merged after.

@bjarketol bjarketol force-pushed the optional-tool-dependencies branch 2 times, most recently from 10ac88d to 1c3c1fa Compare March 12, 2026 18:14
Move py_wake, foxes, floris, and wayve from core dependencies to optional
extras in pyproject.toml. Update README and installation docs to document
the extras syntax (e.g. wifa[py_wake], wifa[all]).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bjarketol bjarketol force-pushed the optional-tool-dependencies branch from 1c3c1fa to 1880267 Compare March 13, 2026 10:07
@bjarketol
Copy link
Copy Markdown
Contributor Author

@SchmJo @kilojoules @mathieu7an

Can one of you take a look at this? It's staggered on top of #55, so it should be merged after.

Any feedback on this?

@mathieu7an mathieu7an merged commit 1101c04 into EUFLOW:main Mar 23, 2026
6 checks passed
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.

Make all wrapped tools (pywake, floris, foxes, wayve, code_saturne) optional dependencies

2 participants