Skip to content

Commit

Permalink
add mapping_dois.json
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed May 7, 2024
1 parent aeda914 commit 36d4a52
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
22 changes: 22 additions & 0 deletions bioimageio_collection_backoffice/generate_collection_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down
7 changes: 6 additions & 1 deletion bioimageio_collection_backoffice/remote_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 36d4a52

Please sign in to comment.