Skip to content

Use petab.v1 imports instead of deprecated top-level petab aliases - #330

Merged
dweindl merged 1 commit into
Benchmarking-Initiative:masterfrom
dweindl:petab-v1-imports
Oct 12, 2026
Merged

dweindl merged 1 commit into
Benchmarking-Initiative:masterfrom
dweindl:petab-v1-imports

Conversation

@dweindl

@dweindl dweindl commented Oct 12, 2026

Copy link
Copy Markdown
Member

libpetab-python will remove the deprecated top-level petab.* aliases; only petab.v1, petab.v2, petab.ENV_NUM_THREADS and petab.__version__ will remain. from petab.yaml import load_yaml in overview.py would then break import benchmark_models_petab.

This switches that import to petab.v1, and does the same for the generator scripts / README snippets under problems/*/resources/ (Smith_BMCSystBiol2013, Blasi_CellSystems2016, Isensee_JCB2018). In Smith's generate_petab.py, import petab.v1.models would rebind petab to the top-level package and shadow the import petab.v1 as petab alias, so it uses from petab.v1.models import sbml_model instead.

The petab>=0.4.0 requirement is unchanged (petab.v1 exists since 0.4.0). The rest of the package already uses petab.v1.

Relates to #328 (no overlapping files; merges cleanly).

🤖 Generated with Claude Code

libpetab-python will remove the deprecated top-level `petab.*` aliases,
leaving only `petab.v1`, `petab.v2`, `petab.ENV_NUM_THREADS` and
`petab.__version__`. `from petab.yaml import load_yaml` in `overview.py`
would then break `import benchmark_models_petab`.

Switch to `petab.v1` there and in the problem-specific generator scripts
and README snippets under `problems/*/resources/` (Smith_BMCSystBiol2013,
Blasi_CellSystems2016, Isensee_JCB2018).

In Smith_BMCSystBiol2013's `generate_petab.py`,
`import petab.v1.models` would rebind `petab` to the top-level package
and shadow the `petab.v1` alias, so use
`from petab.v1.models import sbml_model` instead.

`petab.v1` exists since petab 0.4.0, so the `petab>=0.4.0` requirement
is unchanged.

Drafted with AI assistance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl
dweindl marked this pull request as ready for review October 12, 2026 09:06
@dweindl dweindl self-assigned this Oct 12, 2026

@dilpath dilpath left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@dweindl
dweindl merged commit 32d021a into Benchmarking-Initiative:master Oct 12, 2026
3 checks passed
dweindl added a commit to PEtab-dev/libpetab-python that referenced this pull request Oct 13, 2026
Accessing `petab.<name>` or importing `petab.<module>` has been
deprecated in favor of `petab.v1` since 0.4.0 (July 2024). This removes
the `__getattr__` fallback and the `sys.modules` aliases from
`petab/__init__.py`. The only top-level names left are `petab.v1`,
`petab.v2`, `petab.ENV_NUM_THREADS` and `petab.__version__`. Everything
else now raises `AttributeError` or `ModuleNotFoundError`. As a side
effect, `import petab` no longer imports `petab.v1`.

**This is a breaking change** for code that still uses the old paths.
The fix is to replace `import petab` with `import petab.v1 as petab` and
`from petab.<module> import ...` with `from petab.v1.<module> import
...`.

Other changes:
* Fixed a circular import between `petab.versions` and `petab.v1.yaml`
that the old eager `petab.v1` import had been hiding.
* `petab.v1.parameter_mapping` now imports `ENV_NUM_THREADS` from
`petab` instead of defining it again.
* Updated tests, docstring cross-references, messages, the README and
the visualization notebook to use `petab.v1`.
* Removed `test_problem_with_sbml_model`, which only differed from
`test_get_condition_specific_models` by using the deprecated alias.
* Added a changelog section for the unreleased 0.10.0.

Requires Benchmarking-Initiative/Benchmark-Models-PEtab#330: CI installs
`benchmark_models_petab` from master, which still imports `petab.yaml`.
`tests/v1/test_priors.py` fails until that PR is merged.

🤖 Drafted with AI assistance ([Claude
Code](https://claude.com/claude-code))

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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