diff --git a/bioimageio_collection_backoffice/generate_collection_json.py b/bioimageio_collection_backoffice/generate_collection_json.py index 4e6b8dd4..a45bcc8e 100644 --- a/bioimageio_collection_backoffice/generate_collection_json.py +++ b/bioimageio_collection_backoffice/generate_collection_json.py @@ -101,6 +101,28 @@ def maybe_swap_with_thumbnail( return entry +def generate_doi_mapping( + client: Client, + collection: Dict[ + str, Union[Any, Dict[str, Union[Any, List[Union[Any, Dict[str, Any]]]]]] + ], +): + mapping: Dict[str, str] = {} + for e in collection["collection"]: + assert isinstance(e, dict) + doi: Any = e.get("doi") + if doi is not None: + assert isinstance(doi, str) + mapping[doi] = e["id"] + + concept_doi: Any = e.get("concept_doi") + if concept_doi is not None: + assert isinstance(concept_doi, str) + mapping[concept_doi] = e["id"] + + client.put_json("mapping_dois.json", mapping) + + def generate_old_doi_mapping( client: Client, collection: Dict[ diff --git a/bioimageio_collection_backoffice/remote_collection.py b/bioimageio_collection_backoffice/remote_collection.py index b7c6f398..84fcde07 100644 --- a/bioimageio_collection_backoffice/remote_collection.py +++ b/bioimageio_collection_backoffice/remote_collection.py @@ -8,7 +8,11 @@ from loguru import logger from typing_extensions import assert_never -from .generate_collection_json import create_entry, generate_old_doi_mapping +from .generate_collection_json import ( + create_entry, + generate_doi_mapping, + generate_old_doi_mapping, +) from .s3_client import Client @@ -83,6 +87,7 @@ def generate_collection_json( if mode == "published": generate_old_doi_mapping(self.client, collection) + generate_doi_mapping(self.client, collection) self.client.put_json(output_file_name, collection) if error_in_published_entry is not None: