diff --git a/dandi/dandiapi.py b/dandi/dandiapi.py index ffcd8641c..435cd9a55 100644 --- a/dandi/dandiapi.py +++ b/dandi/dandiapi.py @@ -1450,7 +1450,10 @@ def get_content_url( else: break except requests.HTTPError as e: - url = e.request.url + if e.request is not None and isinstance(e.request.url, str): + url = e.request.url + else: + raise # reraise since we need to figure out how to handle such a case if strip_query: url = urlunparse(urlparse(url)._replace(query="")) return url diff --git a/dandi/files/bids.py b/dandi/files/bids.py index 8ab7c06c7..a875ba1cc 100644 --- a/dandi/files/bids.py +++ b/dandi/files/bids.py @@ -235,7 +235,7 @@ def get_metadata( ) -class ZarrBIDSAsset(BIDSAsset, ZarrAsset): +class ZarrBIDSAsset(ZarrAsset, BIDSAsset): """ .. versionadded:: 0.46.0 diff --git a/dandi/tests/fixtures.py b/dandi/tests/fixtures.py index a13fa954b..788a1a438 100644 --- a/dandi/tests/fixtures.py +++ b/dandi/tests/fixtures.py @@ -628,6 +628,22 @@ def bids_nwb_dandiset( return new_dandiset +# TODO: refactor: avoid duplication and come up with some fixture helper which would +# just need specify bids example name +@pytest.fixture() +def bids_zarr_dandiset( + new_dandiset: SampleDandiset, bids_examples: Path +) -> SampleDandiset: + shutil.copytree( + bids_examples / "micr_SEMzarr", + new_dandiset.dspath, + dirs_exist_ok=True, + ignore=shutil.ignore_patterns(dandiset_metadata_file), + ) + (new_dandiset.dspath / "CHANGES").write_text("0.1.0 2014-11-03\n") + return new_dandiset + + @pytest.fixture() def bids_dandiset_invalid( new_dandiset: SampleDandiset, bids_error_examples: Path diff --git a/dandi/tests/test_upload.py b/dandi/tests/test_upload.py index f30620a52..2d08200cb 100644 --- a/dandi/tests/test_upload.py +++ b/dandi/tests/test_upload.py @@ -292,6 +292,19 @@ def test_upload_zarr(new_dandiset: SampleDandiset) -> None: new_dandiset.upload() +# identical to above, but different scenaior/fixture and path. TODO: avoid duplication +def test_upload_bids_zarr(bids_zarr_dandiset: SampleDandiset) -> None: + bids_zarr_dandiset.upload() + assets = list(bids_zarr_dandiset.dandiset.get_assets()) + assert len(assets) > 10 # it is a bigish dataset + (asset,) = [a for a in assets if a.path.endswith(".zarr")] + assert isinstance(asset, RemoteZarrAsset) + assert asset.asset_type is AssetType.ZARR + assert asset.path.endswith(".zarr") + # Test that uploading again without any changes works: + bids_zarr_dandiset.upload() + + def test_upload_different_zarr(tmp_path: Path, zarr_dandiset: SampleDandiset) -> None: asset = zarr_dandiset.dandiset.get_asset_by_path("sample.zarr") assert isinstance(asset, RemoteZarrAsset)