Skip to content

refactor(py)!: make phylo2vec.opt importable without the GradME extras - #228

Merged
Neclow merged 1 commit into
sbhattlab:mainfrom
Neclow:refactor/optional-gradme
Nov 6, 2026
Merged

Neclow merged 1 commit into
sbhattlab:mainfrom
Neclow:refactor/optional-gradme

Conversation

@Neclow

@Neclow Neclow commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

phylo2vec.opt imported GradME eagerly, so importing anything from it required jax, optax, tqdm and rpy2. This prepares phylo2vec.opt for the upcoming BME functions, which need none of them.

  • GradME and gradme_loss are imported in a try block. Without the extras, the rest of phylo2vec.opt imports, and asking for GradME raises an ImportError that says what to install.
  • The [opt] extras are renamed [gradme], without joblib (already a core dependency).
  • pixi run test now runs the docstring examples in phylo2vec.opt, except in the modules that need extra packages.
  • Docs updated to [gradme]; new tests/test_opt.py for the import behaviour.

Breaking change: pip install phylo2vec[opt] no longer installs the GradME dependencies. Use pip install phylo2vec[gradme].

phylo2vec.opt imported GradME eagerly, so any import from it needed jax,
optax, tqdm and rpy2. GradME is now imported in a try block: without
these, the rest of phylo2vec.opt imports, and asking for GradME raises
an ImportError that says what to install.

Since only GradME needs them, the [opt] extras are renamed [gradme].
joblib is dropped from them, as it is already a core dependency.

The test task now runs the docstring examples of the phylo2vec.opt
modules that need no extras, instead of skipping the whole package.

BREAKING CHANGE: the [opt] extras are now [gradme].
`pip install phylo2vec[opt]` only warns that the extra does not exist
and installs phylo2vec without the GradME dependencies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Neclow
Neclow merged commit e78c28d into sbhattlab:main Nov 6, 2026
9 checks passed
@Neclow
Neclow deleted the refactor/optional-gradme branch November 6, 2026 14:27
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