From 6af842c9b7c76179995bba5c5a41c1953f1f563b Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 28 Sep 2023 13:19:22 -0400 Subject: [PATCH] Add a test checking/demonstrating the problem of uploading Zarr within BIDS could not run tests locally unfortunately - likely due to my custom configuration of networking for podman (?) or was it also done for docker? TODO to figure it out ulling django ... done Creating network "dandiarchive-docker_default" with the default driver ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-c26ebcecb035 -j RETURN: iptables: No chain/target/match by that name. (exit status 1)) Removing network dandiarchive-docker_default WARNING: Network dandiarchive-docker_default not found. ERROR ============================================================ ERRORS ============================================================= ____________________________________________ ERROR at setup of test_upload_bids_zarr ____________________________________________ dandi/tests/fixtures.py:403: in docker_compose_setup run( /usr/lib/python3.11/subprocess.py:571: in run raise CalledProcessError(retcode, process.args, E subprocess.CalledProcessError: Command '['docker-compose', 'run', '--rm', 'django', './manage.py', 'migrate']' returned non-zero exit status 1. ===================================================== slowest 10 durations ====================================================== 119.18s setup dandi/tests/test_upload.py::test_upload_bids_zarr (1 durations < 0.005s hidden. Use -vv to show these durations.) ==================================================== short test summary info ==================================================== ERROR dandi/tests/test_upload.py::test_upload_bids_zarr - subprocess.CalledProcessError: Command '['docker-compose', 'run', '--rm', 'django', './manage.py', 'migrate']' returned non-... ================================================= 1 error in 119.31s (0:01:59) ================================================== python -m pytest -s -v dandi/tests/test_upload.py::test_upload_bids_zarr 3.87s user 3.43s system 6% cpu 2:01.11 total Also flake8 was not happy either flake8...................................................................Failed - hook id: flake8 - exit code: 1 dandi/tests/test_upload.py:297:5: F821 undefined name 'new_dandiset' dandi/tests/test_upload.py:298:16: F821 undefined name 'new_dandiset' dandi/tests/test_upload.py:303:5: F821 undefined name 'new_dandiset' so it seems it does not know how to deal with those pytest fixtures but odd that just now and just for that one --- dandi/tests/fixtures.py | 16 ++++++++++++++++ dandi/tests/test_upload.py | 11 +++++++++++ 2 files changed, 27 insertions(+) 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..61cb95247 100644 --- a/dandi/tests/test_upload.py +++ b/dandi/tests/test_upload.py @@ -292,6 +292,17 @@ 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: + new_dandiset.upload() + (asset,) = new_dandiset.dandiset.get_assets() + assert isinstance(asset, RemoteZarrAsset) + assert asset.asset_type is AssetType.ZARR + assert asset.path == "sample.zarr" + # Test that uploading again without any changes works: + new_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)