Skip to content

Commit 0d3d9bf

Browse files
committed
add test_load_dataset_description
1 parent 12b5a31 commit 0d3d9bf

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ def stardist04_data():
6363
return MappingProxyType(data)
6464

6565

66+
@pytest.fixture(scope="session")
67+
def covid_if_dataset_path() -> Path:
68+
return EXAMPLE_DESCRIPTIONS / "datasets/covid_if_training_data/bioimageio.yaml"
69+
70+
6671
@pytest.fixture(scope="session")
6772
def unet2d_path() -> Path:
6873
return UNET2D_ROOT / "bioimageio.yaml"

tests/test_io.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,19 @@ def test_load_description_again(unet2d_data: BioimageioYamlContent):
4242
perform_io_checks=False,
4343
)
4444
assert descr is descr2
45+
46+
47+
def test_load_dataset_description(covid_if_dataset_path: Path, tmp_path: Path):
48+
from bioimageio.spec import load_dataset_description
49+
from bioimageio.spec._io import save_bioimageio_yaml_only
50+
from bioimageio.spec.dataset.v0_2 import DatasetDescr
51+
52+
dataset_descr = load_dataset_description(covid_if_dataset_path)
53+
assert isinstance(dataset_descr, DatasetDescr)
54+
55+
# this example happens to consist only of the bioimageio.yaml file,
56+
# so we can test the roundtrip with `save_bioimageio_yaml_only`
57+
save_bioimageio_yaml_only(dataset_descr, tmp_path / "dataset.yaml")
58+
dataset_descr2 = load_dataset_description(tmp_path / "dataset.yaml")
59+
assert isinstance(dataset_descr2, DatasetDescr) # we cannot expect
60+
assert dataset_descr.model_dump() == dataset_descr2.model_dump()

0 commit comments

Comments
 (0)