Skip to content

Commit 684da5c

Browse files
yarikopticclaude
andcommitted
Skip zarr multipart-upload tests when server lacks the endpoint
The two ``ai_generated`` tests added in 9bc2976 patch ``ZARR_LARGE_CHUNK_THRESHOLD`` down so chunks are routed through ``_multipart_upload`` against whatever server backs ``new_dandiset``. The local docker dandi-archive image does not yet ship dandi-archive#2784, so the new ``supports_zarr_multipart_upload`` capability check raises ``UploadError`` before ``_multipart_upload`` is ever called and the tests fail without exercising what they claim to. Probe the live client for capability and ``pytest.skip`` only when the endpoint is missing — keeps the tests effective on setups whose server already carries dandi-archive#2784. Co-Authored-By: Claude Code 2.1.123 / Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 39cc742 commit 684da5c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

dandi/tests/test_files.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from ..consts import ZARR_MIME_TYPE, dandiset_metadata_file
1717
from ..dandiapi import AssetType, RemoteZarrAsset
1818
from ..exceptions import UnknownAssetError
19-
from ..files.bases import _multipart_upload as real_multipart_upload
2019
from ..files import (
2120
BIDSDatasetDescriptionAsset,
2221
DandisetMetadataFile,
@@ -30,6 +29,7 @@
3029
dandi_file,
3130
find_dandi_files,
3231
)
32+
from ..files.bases import _multipart_upload as real_multipart_upload
3333

3434
lgr = get_logger()
3535

@@ -540,6 +540,11 @@ def test_upload_zarr_entry_content_type(new_dandiset, tmp_path):
540540
@pytest.mark.ai_generated
541541
def test_upload_zarr_large_chunks(new_dandiset, tmp_path):
542542
"""Chunks above ZARR_LARGE_CHUNK_THRESHOLD are uploaded via multipart upload."""
543+
if not new_dandiset.client.supports_zarr_multipart_upload:
544+
pytest.skip(
545+
"Server does not expose the zarr multipart upload endpoints"
546+
" (dandi-archive#2784)"
547+
)
543548
filepath = tmp_path / "example.zarr"
544549
zarr.save(filepath, np.arange(1000), np.arange(1000, 0, -1))
545550
zf = dandi_file(filepath)
@@ -571,6 +576,11 @@ def spy_multipart_upload(**kwargs):
571576
@pytest.mark.ai_generated
572577
def test_upload_zarr_mixed_chunks(new_dandiset, tmp_path):
573578
"""Chunks above ZARR_LARGE_CHUNK_THRESHOLD go multipart; smaller ones use single-part upload."""
579+
if not new_dandiset.client.supports_zarr_multipart_upload:
580+
pytest.skip(
581+
"Server does not expose the zarr multipart upload endpoints"
582+
" (dandi-archive#2784)"
583+
)
574584
filepath = tmp_path / "mixed.zarr"
575585
store = zarr.open_group(str(filepath), mode="w")
576586
# small array: 10 int64 elements, produces a ~96-byte chunk (compressed)
@@ -601,9 +611,7 @@ def spy_multipart_upload(**kwargs):
601611
remote_entries = {str(e) for e in asset.iterfiles()}
602612
# Only chunk files whose on-disk size exceeds the threshold should be multipart-uploaded
603613
large_chunks = {
604-
p
605-
for p in remote_entries
606-
if (filepath / p).stat().st_size > mixed_threshold
614+
p for p in remote_entries if (filepath / p).stat().st_size > mixed_threshold
607615
}
608616
assert set(multipart_paths) == large_chunks
609617
# At least one chunk must have gone each path so the test is meaningful

0 commit comments

Comments
 (0)