Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions dandi/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,11 +1213,7 @@ def _check_attempts_and_sleep(
lgr.debug("%s - download failed after %d attempts: %s", path, attempt, exc)
return 0
if exc.response is not None:
if exc.response.status_code not in (
400, # Bad Request, but happened with girder:
# https://github.com/dandi/dandi-cli/issues/87
*RETRY_STATUSES,
):
if exc.response.status_code not in RETRY_STATUSES:
lgr.debug(
"%s - download failed due to response %d: %s",
path,
Expand Down
24 changes: 21 additions & 3 deletions dandi/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,24 @@ def test__check_attempts_and_sleep() -> None:
assert mock_sleep.call_args.args[0] >= 0


@pytest.mark.ai_generated
@pytest.mark.parametrize("status_code", [400, 403, 404])
def test__check_attempts_and_sleep_no_retry(status_code: int) -> None:
response = requests.Response()
response.status_code = status_code
with mock.patch("time.sleep") as mock_sleep:
assert (
_check_attempts_and_sleep(
Path("some/path"),
HTTPError(response=response),
attempt=1,
attempts_allowed=2,
)
== 0
)
mock_sleep.assert_not_called()


@pytest.mark.parametrize("status_code", [429, 503])
def test__check_attempts_and_sleep_retries(status_code: int) -> None:
f = partial(_check_attempts_and_sleep, Path("some/path"))
Expand Down Expand Up @@ -1553,9 +1571,9 @@ def test_download_zarr_with_glob_filter(
all_files = list_paths(zarr_dir)
assert len(all_files) > 0
for f in all_files:
assert f.name.startswith(".z") or f.name == "zarr.json", (
f"Non-metadata file downloaded: {f}"
)
assert (
f.name.startswith(".z") or f.name == "zarr.json"
), f"Non-metadata file downloaded: {f}"


@pytest.mark.ai_generated
Expand Down
5 changes: 0 additions & 5 deletions dandi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,6 @@ def get_instance(dandi_instance_id: str | DandiInstance) -> DandiInstance:
else:
dandi_id = dandi_instance_id
instance = known_instances[dandi_id]
if dandi_id == "dandi-staging":
raise ValueError(
"'dandi-staging' DANDI instance identifier was removed. "
"The instance was renamed into 'dandi-sandbox', please use that identifier instead."
)
if redirector_url is None:
assert instance is not None
return _get_instance(instance.api.rstrip("/"), True, instance, dandi_id)
Expand Down
Loading