From 297843877a37c06446288dc040ae4e04821ae886 Mon Sep 17 00:00:00 2001 From: k-dominik Date: Mon, 15 Jan 2024 19:58:08 +0100 Subject: [PATCH] fixed filenames for zenodo sources 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. --- bioimageio/spec/shared/node_transformer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bioimageio/spec/shared/node_transformer.py b/bioimageio/spec/shared/node_transformer.py index cc834a397..b328e94a6 100644 --- a/bioimageio/spec/shared/node_transformer.py +++ b/bioimageio/spec/shared/node_transformer.py @@ -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}")