Skip to content

Commit 9a1723f

Browse files
jdeschampsmese79pre-commit-ci[bot]
authored
chore: Bump BMZ dependency to 0.9.0 (#508)
## Description <!-- This section provides the necessary background and information for reviewers to understand the code and have the correct mindset when examining changes. --> > [!NOTE] > **tldr**: Depend on BMZ latest version ### Background - why do we need this PR? <!-- What problem are you solving? Describe in a few sentences the state before this PR. Use code examples if useful. --> Currently, we fixed `xarray` dependency bc of the BMZ, and we depend on an old BMZ version. This allows us to depend on the latest version (`0.8.0` was incompatible bc of bioimageio.specs lagging dependency on Pydantic). ### Overview - what changed? <!-- What aspects and mechanisms of the code base changed? Describe only the general idea and overarching features. --> Dependency on BMZ. ### Implementation - how did you implement the changes? <!-- How did you solve the issue technically? Explain why you chose this approach and provide code examples if applicable (e.g. change in the API for users). --> Update `pyproject.toml` and some BMZ API calls. ## Changes Made <!-- This section highlights the important features and files that reviewers should pay attention to when reviewing. Only list important features or files, this is useful for reviewers to correctly assess how deeply the modifications impact the code base. For instance: ### New features or files - `NewClass` added to `new_file.py` - `new_function` added to `existing_file.py` ... --> ### Modified features or files <!-- List important modified features or files. --> - `pyproject.toml` - `model_description.py` ## How has this been tested? <!-- Describe the tests that you ran to verify your changes. This can be a short description of the tests added to the PR or code snippet to reproduce the change in behaviour. --> CI and local. ## Related Issues <!-- Link to any related issues or discussions. Use keywords like "Fixes", "Resolves", or "Closes" to link to issues automatically. --> #495 (comment) Thanks @mese79 !!! --- **Please ensure your PR meets the following requirements:** - [x] Code builds and passes tests locally, including doctests - [ ] New tests have been added (for bug fixes/features) - [x] Pre-commit passes - [ ] PR to the documentation exists (for bug fixes / features) --------- Co-authored-by: Mehdi Seifi <mehdiseifi@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 137cb30 commit 9a1723f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dependencies = [
4444
'numpy<2.0.0',
4545
'torch>=2.0,<=2.7.1',
4646
'torchvision<=0.22.1',
47-
'bioimageio.core==0.7',
47+
'bioimageio.core==0.9.0',
4848
'tifffile<=2025.5.10',
4949
'psutil<=7.0.0',
5050
'pydantic>=2.11,<=2.12',
@@ -55,7 +55,6 @@ dependencies = [
5555
'zarr<3.0.0',
5656
'pillow<=11.2.1',
5757
'matplotlib<=3.10.3',
58-
'xarray<2025.3.0',
5958
]
6059

6160
[project.optional-dependencies]

src/careamics/model_io/bioimage/model_description.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
from typing import Optional, Union
55

66
import numpy as np
7-
from bioimageio.spec._internal.io import resolve_and_extract
7+
from bioimageio.spec._internal.io import extract
88
from bioimageio.spec.model.v0_5 import (
99
ArchitectureFromLibraryDescr,
1010
Author,
1111
AxisBase,
1212
AxisId,
1313
BatchAxis,
1414
ChannelAxis,
15-
EnvironmentFileDescr,
1615
FileDescr,
1716
FixedZeroMeanUnitVarianceAlongAxisKwargs,
1817
FixedZeroMeanUnitVarianceDescr,
@@ -269,7 +268,7 @@ def create_model_description(
269268
source=weights_path,
270269
architecture=architecture_descr,
271270
pytorch_version=Version(torch_version),
272-
dependencies=EnvironmentFileDescr(source=env_path),
271+
dependencies=FileDescr(source=Path(env_path)),
273272
),
274273
)
275274

@@ -322,17 +321,19 @@ def extract_model_path(model_desc: ModelDescr) -> tuple[Path, Path]:
322321
"""
323322
if model_desc.weights.pytorch_state_dict is None:
324323
raise ValueError("No model weights found in model description.")
325-
weights_path = resolve_and_extract(
326-
model_desc.weights.pytorch_state_dict.source
327-
).path
324+
325+
# extract the zip model and return the directory
326+
model_dir = extract(model_desc.root)
327+
328+
weights_path = model_dir.joinpath(model_desc.weights.pytorch_state_dict.source.path)
328329

329330
for file in model_desc.attachments:
330331
file_path = file.source if isinstance(file.source, Path) else file.source.path
331332
if file_path is None:
332333
continue
333334
file_path = Path(file_path)
334335
if file_path.name == "careamics.yaml":
335-
config_path = resolve_and_extract(file.source).path
336+
config_path = model_dir.joinpath(file.source.path)
336337
break
337338
else:
338339
raise ValueError("Configuration file not found.")

src/careamics/model_io/bmz_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def export_to_bmz(
187187

188188
# test model description
189189
test_kwargs = (
190-
model_description.config.get("bioimageio", {})
190+
model_description.config.bioimageio.model_dump()
191191
.get("test_kwargs", {})
192192
.get("pytorch_state_dict", {})
193193
)

0 commit comments

Comments
 (0)