Skip to content

Commit 4a05b37

Browse files
authored
Merge pull request #536 from bioimage-io/fix_names_in_package
improve cached file name for zenodo api changes
2 parents b2baad1 + 21de8c4 commit 4a05b37

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

bioimageio/spec/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "0.4.9post4"
2+
"version": "0.4.9post5"
33
}

bioimageio/spec/shared/_resolve_source.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,12 @@ def _download_url(uri: raw_nodes.URI, output: typing.Optional[os.PathLike] = Non
423423
local_path = pathlib.Path(output)
424424
elif BIOIMAGEIO_USE_CACHE:
425425
# todo: proper caching
426-
local_path = BIOIMAGEIO_CACHE_PATH / uri.scheme / uri.authority / uri.path.strip("/") / uri.query
426+
if uri.authority == "zenodo.org" and uri.path.startswith("/api/records/") and uri.path.endswith("/content"):
427+
p = uri.path[: -len("/content")].strip("/")
428+
else:
429+
p = uri.path.strip("/")
430+
431+
local_path = BIOIMAGEIO_CACHE_PATH / uri.scheme / uri.authority / p / uri.query
427432
else:
428433
tmp_dir = TemporaryDirectory()
429434
no_cache_tmp_list.append(tmp_dir) # keep temporary file until process ends
@@ -462,9 +467,9 @@ def _download_url(uri: raw_nodes.URI, output: typing.Optional[os.PathLike] = Non
462467
total_size = int(r.headers.get("content-length", 0))
463468
block_size = 1024 # 1 Kibibyte
464469
if pbar:
465-
t = pbar(total=total_size, unit="iB", unit_scale=True, desc=uri.path.split("/")[-1])
470+
t = pbar(total=total_size, unit="iB", unit_scale=True, desc=local_path.name)
466471
else:
467-
t = tqdm(total=total_size, unit="iB", unit_scale=True, desc=uri.path.split("/")[-1])
472+
t = tqdm(total=total_size, unit="iB", unit_scale=True, desc=local_path.name)
468473
tmp_path = local_path.with_suffix(f"{local_path.suffix}.part")
469474
with tmp_path.open("wb") as f:
470475
for data in r.iter_content(block_size):

0 commit comments

Comments
 (0)