Skip to content

Commit

Permalink
add versions_sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Jun 10, 2024
1 parent 935fc57 commit f2c8082
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bioimageio_collection_backoffice/collection_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CollectionEntry(Node, frozen=True):
type: Literal["application", "model", "notebook", "dataset"]
versions: Sequence[str]
"""available versions of this resource. newest first"""
versions_sha256: Sequence[str]
versions_sha256: Sequence[Optional[str]]
"""SHA-256 of each versioned RDF"""
dois: Sequence[Optional[str]]
"""version specific dois of the available versions. newest first"""
Expand Down
9 changes: 8 additions & 1 deletion bioimageio_collection_backoffice/remote_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,14 +1071,20 @@ def maybe_swap_with_thumbnail(
if (
this_version_id := f"{concept_doi}/{version_record_id}"
) not in entry_versions:
entry_versions.append(this_version_id)
entry_versions.insert(0, this_version_id)

versions_sha256: List[Optional[str]] = [None] * (len(entry_versions) - 1)

entry_dois = [f"10.5281/zenodo.{v}" for v in entry_versions]
else:
concept_doi = rv.concept_doi
entry_id = rdf["id"]
legacy_download_count = 0
entry_versions = [v.id for v in versions]
versions_sha256 = [
None if d is None else hashlib.sha256(d).hexdigest()
for d in [v.client.load_file(v.rdf_path) for v in versions]
]
entry_dois = [v.doi for v in versions]

if "/" in rdf["id"]:
Expand Down Expand Up @@ -1126,6 +1132,7 @@ def maybe_swap_with_thumbnail(
training_data=rdf["training_data"] if "training_data" in rdf else None,
type=rdf["type"],
versions=entry_versions,
versions_sha256=versions_sha256,
dois=entry_dois,
)
]

0 comments on commit f2c8082

Please sign in to comment.