Skip to content

Commit b5ac250

Browse files
Merge pull request #184 from bioimage-io/package-samples
Check that samples are packaged in build_spec tests
2 parents f8b1bc3 + b79b429 commit b5ac250

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

bioimageio/core/build_spec/build_model.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,6 @@ def _get_output_tensor(path, name, reference_tensor, scale, offset, axes, data_r
229229
return outputs
230230

231231

232-
def _build_authors(authors: List[Dict[str, str]]):
233-
return [model_spec.raw_nodes.Author(**a) for a in authors]
234-
235-
236232
# TODO The citation entry should be improved so that we can properly derive doi vs. url
237233
def _build_cite(cite: Dict[str, str]):
238234
citation_list = [model_spec.raw_nodes.CiteEntry(text=k, url=v) for k, v in cite.items()]
@@ -564,6 +560,7 @@ def build_model(
564560
postprocessing: Optional[List[Dict[str, Dict[str, Union[int, float, str]]]]] = None,
565561
pixel_sizes: Optional[List[Dict[str, float]]] = None,
566562
# general optional
563+
maintainers: Optional[List[Dict[str, str]]] = None,
567564
license: Optional[str] = None,
568565
covers: Optional[List[str]] = None,
569566
git_repo: Optional[str] = None,
@@ -731,7 +728,7 @@ def build_model(
731728
format_version = get_args(model_spec.raw_nodes.FormatVersion)[-1]
732729
timestamp = datetime.datetime.now()
733730

734-
authors = _build_authors(authors)
731+
authors = [model_spec.raw_nodes.Author(**a) for a in authors]
735732
cite = _build_cite(cite)
736733
documentation = _ensure_local(documentation, root)
737734
if covers is None:
@@ -822,6 +819,8 @@ def build_model(
822819
if parent is not None:
823820
assert len(parent) == 2
824821
kwargs["parent"] = {"uri": parent[0], "sha256": parent[1]}
822+
if maintainers is not None:
823+
kwargs["maintainers"] = [model_spec.raw_nodes.Maintainer(**m) for m in maintainers]
825824

826825
try:
827826
model = model_spec.raw_nodes.Model(

tests/build_spec/test_build_spec.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def _test_build_spec(
7979
postprocessing=postprocessing,
8080
output_path=out_path,
8181
add_deepimagej_config=add_deepimagej_config,
82+
maintainers=[{"github_user": "jane_doe"}],
8283
)
8384
if architecture is not None:
8485
kwargs["architecture"] = architecture
@@ -106,6 +107,14 @@ def _test_build_spec(
106107
loaded_config = loaded_model.config
107108
assert "deepimagej" in loaded_config
108109

110+
if loaded_model.sample_inputs is not missing:
111+
for sample in loaded_model.sample_inputs:
112+
assert sample.exists()
113+
if loaded_model.sample_outputs is not missing:
114+
for sample in loaded_model.sample_outputs:
115+
assert sample.exists()
116+
117+
assert loaded_model.maintainers[0].github_user == "jane_doe"
109118
attachments = loaded_model.attachments
110119
if attachments is not missing and attachments.files is not missing:
111120
for attached_file in attachments["files"]:

0 commit comments

Comments
 (0)