diff --git a/bioimageio_collection_backoffice/backup.py b/bioimageio_collection_backoffice/backup.py index 045a0b6d..02944a94 100644 --- a/bioimageio_collection_backoffice/backup.py +++ b/bioimageio_collection_backoffice/backup.py @@ -212,23 +212,24 @@ 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)" - ) + if rdf.license is not None: + # check if license id is valid: + license_response = requests.get( + f"https://zenodo.org/api/vocabularies/licenses/{rdf.license.lower()}" ) - else: - ret["license"] = rdf.license + 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 diff --git a/bioimageio_collection_backoffice/collection_config/collection_json_template.py b/bioimageio_collection_backoffice/collection_config/collection_json_template.py index fe203315..cb1b17ae 100644 --- a/bioimageio_collection_backoffice/collection_config/collection_json_template.py +++ b/bioimageio_collection_backoffice/collection_config/collection_json_template.py @@ -4,7 +4,12 @@ from typing import Any, Literal, Optional, Sequence -from bioimageio.spec.generic.v0_3 import Author, CiteEntry, LicenseId, Version +from bioimageio.spec.generic.v0_3 import ( + Author, + CiteEntry, + LicenseId, # type: ignore + Version, +) from pydantic import HttpUrl from ..common import Node diff --git a/bioimageio_collection_backoffice/mailroom/_forward_emails_to_chat.py b/bioimageio_collection_backoffice/mailroom/_forward_emails_to_chat.py index 52db82ca..e2368d5a 100644 --- a/bioimageio_collection_backoffice/mailroom/_forward_emails_to_chat.py +++ b/bioimageio_collection_backoffice/mailroom/_forward_emails_to_chat.py @@ -10,7 +10,7 @@ from .._settings import settings from ..db_structure.chat import Chat, Message -from ..remote_collection import get_remote_collection_version +from ..remote_collection import get_remote_resource_version from ..s3_client import Client from .constants import ( BOT_EMAIL, @@ -93,8 +93,8 @@ def _update_chats( text = "[forwarded from email]\n" + body.replace("> " + REPLY_HINT, "").replace( REPLY_HINT, "" ) - rr = get_remote_collection_version(s3_client, rid, rv) - if not rr.exists: + rr = get_remote_resource_version(s3_client, rid, rv) + if not rr.exists(): logger.error("Cannot comment on non-existing resource {} {}", rid, rv) continue diff --git a/bioimageio_collection_backoffice/mailroom/send_email.py b/bioimageio_collection_backoffice/mailroom/send_email.py index 31427b43..4cf7a1fd 100644 --- a/bioimageio_collection_backoffice/mailroom/send_email.py +++ b/bioimageio_collection_backoffice/mailroom/send_email.py @@ -1,5 +1,4 @@ import smtplib -import sys from email.mime.text import MIMEText from typing import List, Union diff --git a/tests/test_utils/test_remote_resource.py b/tests/test_utils/test_remote_resource.py index 561f63cd..7ae38bf0 100644 --- a/tests/test_utils/test_remote_resource.py +++ b/tests/test_utils/test_remote_resource.py @@ -1,6 +1,3 @@ -from pathlib import Path - -from bioimageio_collection_backoffice._settings import settings from bioimageio_collection_backoffice.backup import backup from bioimageio_collection_backoffice.remote_collection import ( Record, @@ -35,7 +32,7 @@ def test_lifecycle( remote_collection.generate_collection_json() - backup(client, settings.zenodo_test_url) + backup(client) assert concept.doi is not None assert published.doi is not None