Skip to content

Commit

Permalink
fix pyright issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed May 24, 2024
1 parent f3bc2ad commit 81d1c39
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
33 changes: 17 additions & 16 deletions bioimageio_collection_backoffice/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion bioimageio_collection_backoffice/mailroom/send_email.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import smtplib
import sys
from email.mime.text import MIMEText
from typing import List, Union

Expand Down
5 changes: 1 addition & 4 deletions tests/test_utils/test_remote_resource.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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

0 comments on commit 81d1c39

Please sign in to comment.