Skip to content

Commit

Permalink
use minio to get entry's RDF
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Jun 5, 2024
1 parent 120470d commit d257317
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bioimageio_collection_backoffice/remote_collection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import hashlib
import io
import json
import random
Expand Down Expand Up @@ -967,7 +968,10 @@ def create_collection_entries(
if not versions:
return []

# create an explicit entry only for the latest version
# (all versions are referenced under `versions`)
rv = versions[0]

with ValidationContext(perform_io_checks=False):
rdf_url = HttpUrl(rv.rdf_url)

Expand All @@ -983,8 +987,11 @@ def create_collection_entries(
)
), (root_url, root)
parsed_root = urlsplit(root_url)
rdf_path = download(rdf_url).path
rdf: Union[Any, Dict[Any, Any]] = yaml.load(rdf_path)
rdf_data = rv.client.load_file(rv.rdf_path)
if rdf_data is None:
raise RuntimeError(f"failed to load {rv.rdf_path}")

rdf: Union[Any, Dict[Any, Any]] = yaml.load(io.BytesIO(rdf_data))
assert isinstance(rdf, dict)

try:
Expand Down Expand Up @@ -1102,7 +1109,7 @@ def maybe_swap_with_thumbnail(
name=rdf["name"],
nickname_icon=nickname_icon,
nickname=nickname,
rdf_sha256=get_sha256(rdf_path),
rdf_sha256=hashlib.sha256(rdf_data).hexdigest(),
rdf_source=AnyUrl(rv.rdf_url),
root_url=root_url,
tags=rdf.get("tags", []),
Expand Down

0 comments on commit d257317

Please sign in to comment.