Skip to content

Commit

Permalink
fixed filenames for zenodo sources
Browse files Browse the repository at this point in the history
these would previously be resolved to "content", "content-0" and so on
in case of multiple such files.
Some functionality relies on file extensions which would be omitted.
The original filenames are restored by removing the "/content" bit from
the zenodo urls.
  • Loading branch information
k-dominik committed Jan 15, 2024
1 parent 4a05b37 commit 2978438
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bioimageio/spec/shared/node_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ def _transform_resource(
resource = self.root / resource

elif isinstance(resource, URI):
name_from = pathlib.PurePath(resource.path or "unknown")
if (
resource.authority == "zenodo.org"
and resource.path.startswith("/api/records/")
and resource.path.endswith("/content")
):
name_from = pathlib.PurePath(resource.path[: -len("/content")].strip("/"))
else:
name_from = pathlib.PurePath(resource.path or "unknown")
folder_in_package = ""
else:
raise TypeError(f"Unexpected type {type(resource)} for {resource}")
Expand Down

0 comments on commit 2978438

Please sign in to comment.