Skip to content

Commit

Permalink
only set license if known to zenodo
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed May 24, 2024
1 parent 490bbd5 commit f3bc2ad
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions bioimageio_collection_backoffice/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,10 @@ def rdf_to_metadata(
keywords = ["backup.bioimage.io", "bioimage.io", "bioimage.io:" + rdf.type]
# related_identifiers = generate_related_identifiers_from_rdf(rdf, rdf_file_name) # TODO: add related identifiers

# for debugging: check if license id is valid:
# license_response = requests.get(
# f"https://zenodo.org/api/vocabularies/licenses/{rdf.license.lower()}"
# )
# raise_for_status_discretely(license_response)

return {
ret: Dict[str, Any] = {
"title": f"bioimage.io upload: {rdf.id}",
"description": description,
"access_right": "open",
"license": rdf.license,
"upload_type": "dataset" if rdf.type == "dataset" else "software",
"creators": creators,
"publication_date": publication_date.date().isoformat(),
Expand All @@ -219,6 +212,26 @@ def rdf_to_metadata(
# "communities": [],
}

# check if license id is valid:
license_response = requests.get(
f"https://zenodo.org/api/vocabularies/licenses/{rdf.license.lower()}"
)
try:
raise_for_status_discretely(license_response)
except Exception as e:
logger.error(str(e))
logger.error(
(
f"License '{rdf.license}' not known to Zenodo."
+ " Please add manually as custom license"
+ " (as this is currently not supported to do via REST API)"
)
)
else:
ret["license"] = rdf.license

return ret


def generate_related_identifiers_from_rdf(rdf: ResourceDescr, rdf_file_name: str):
related_identifiers: List[Dict[str, str]] = []
Expand Down

0 comments on commit f3bc2ad

Please sign in to comment.