Skip to content

Commit

Permalink
Saving to bioimageio modelzoo is not yet supported for python 3.10 an…
Browse files Browse the repository at this point in the history
…d below
  • Loading branch information
pattonw committed Feb 19, 2025
1 parent b093965 commit 7f9aad7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dacapo/experiments/run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from .validation_scores import ValidationScores
from .model import Model

import sys

from bioimageio.core import test_model
from bioimageio.spec import save_bioimageio_package
from bioimageio.spec.model.v0_5 import (
Expand Down Expand Up @@ -455,6 +457,10 @@ def save_bioimage_io_model(

weights_path = tmp / "model.pth"
torch.save(self.model.state_dict(), weights_path)
if sys.version_info[1] < 11:
raise RuntimeError(
"Saving to bioimageio modelzoo format is not implemented for Python versions < 3.11"
)
with open(weights_path, "rb", buffering=0) as f:
weights_hash = hashlib.file_digest(f, "sha256").hexdigest()

Expand Down
14 changes: 13 additions & 1 deletion tests/components/test_architectures.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import pytest

import sys


def build_test_architecture_config(
data_dims: int,
Expand Down Expand Up @@ -136,7 +138,17 @@ def build_test_architecture_config(
@pytest.mark.parametrize("batch_norm", [True, False])
@pytest.mark.parametrize("use_attention", [True, False])
@pytest.mark.parametrize("padding", ["valid", "same"])
@pytest.mark.parametrize("source", ["config", "module", "bioimage_modelzoo"])
@pytest.mark.parametrize(
"source",
[
"config",
"module",
pytest.param(
"bioimage_modelzoo",
marks=pytest.mark.skipif(sys.version_info[1] < 11, reason="skip this one"),
),
],
)
def test_architectures(
data_dims,
channels,
Expand Down

0 comments on commit 7f9aad7

Please sign in to comment.