From eb286d328e6eba3e97fa9046a0cf1eb308bf0a04 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 15 Jan 2025 16:53:49 +0000 Subject: [PATCH 01/20] Clean up warning filters in tests --- pyproject.toml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d862cce0ac..daf065a8d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -397,12 +397,9 @@ addopts = [ "--durations=10", "-ra", "--strict-config", "--strict-markers", ] filterwarnings = [ - "error:::zarr.*", - "ignore:PY_SSIZE_T_CLEAN will be required.*:DeprecationWarning", - "ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning", - "ignore:Creating a zarr.buffer.gpu.*:UserWarning", - "ignore:Duplicate name:UserWarning", # from ZipFile - "ignore:.*is currently not part in the Zarr format 3 specification.*:UserWarning", + "error", + # TODO: explicitly filter or catch the warnings below where we expect them to be emitted in the tests + "ignore:Consolidated metadata is currently not part in the Zarr format 3 specification.*:UserWarning", ] markers = [ "gpu: mark a test as requiring CuPy and GPU", From 2f9ec9fe5aecd61102f974a68dfd52739c09b783 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 15 Jan 2025 17:15:35 +0000 Subject: [PATCH 02/20] Ignore some more warnings --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index daf065a8d9..6b8fcaa5c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -400,6 +400,9 @@ filterwarnings = [ "error", # TODO: explicitly filter or catch the warnings below where we expect them to be emitted in the tests "ignore:Consolidated metadata is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:Creating a zarr.buffer.gpu.Buffer with an array that does not support the __cuda_array_interface__.*:UserWarning", + "ignore:Automatic shard shape inference is experimental and may change without notice.*:UserWarning", + "ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning" ] markers = [ "gpu: mark a test as requiring CuPy and GPU", From 3c48cd6383f45363b253d80903cfb36c4fe6195c Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Jan 2025 16:55:55 +0000 Subject: [PATCH 03/20] Ignore some more warnings --- pyproject.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6b8fcaa5c5..36d9512e85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -402,7 +402,13 @@ filterwarnings = [ "ignore:Consolidated metadata is currently not part in the Zarr format 3 specification.*:UserWarning", "ignore:Creating a zarr.buffer.gpu.Buffer with an array that does not support the __cuda_array_interface__.*:UserWarning", "ignore:Automatic shard shape inference is experimental and may change without notice.*:UserWarning", - "ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning" + "ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:The dtype .* is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:Use zarr.create_array instead.:DeprecationWarning", + "ignore:Duplicate name.*:UserWarning", + "ignore:The `compressor` argument is deprecated. Use `compressors` instead.:UserWarning", + "ignore:Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations.:UserWarning", + ] markers = [ "gpu: mark a test as requiring CuPy and GPU", From fd5ac3ac0f5c2e7f3a5c02ac89171c371ec0030c Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Jan 2025 17:12:36 +0000 Subject: [PATCH 04/20] Ignore boto3 deprecation warning --- tests/test_store/test_fsspec.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index 2e9620f29d..bdef1e3da3 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -2,6 +2,7 @@ import json import os +import re from typing import TYPE_CHECKING import pytest @@ -19,6 +20,12 @@ import botocore.client +# Warning filter due to https://github.com/boto/boto3/issues/3889 +pytestmark = [ + pytest.mark.filterwarnings( + re.escape("ignore:datetime.datetime.utcnow() is deprecated:DeprecationWarning") + ) +] fsspec = pytest.importorskip("fsspec") s3fs = pytest.importorskip("s3fs") From 803e6d2a0e1c312b822a282508b4029ae213874c Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Jan 2025 17:42:32 +0000 Subject: [PATCH 05/20] Ignore unclosed client warning --- tests/test_store/test_fsspec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index bdef1e3da3..0d09a9e2bd 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -24,7 +24,9 @@ pytestmark = [ pytest.mark.filterwarnings( re.escape("ignore:datetime.datetime.utcnow() is deprecated:DeprecationWarning") - ) + ), + # TODO: fix these resource warnings + pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") ] fsspec = pytest.importorskip("fsspec") From 6de6652f3d6df5be8178bd83715a642243f35461 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Jan 2025 17:48:15 +0000 Subject: [PATCH 06/20] Filter another fsspec warning --- tests/test_store/test_fsspec.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index 0d09a9e2bd..a295979c1e 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -25,8 +25,9 @@ pytest.mark.filterwarnings( re.escape("ignore:datetime.datetime.utcnow() is deprecated:DeprecationWarning") ), - # TODO: fix these resource warnings - pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") + # TODO: fix these warnings + pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning"), + pytest.mark.filterwarnings("ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited:RuntimeWarning") ] fsspec = pytest.importorskip("fsspec") From 62aaa24761babae3a27d9373221466890fbc3e75 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Jan 2025 18:02:32 +0000 Subject: [PATCH 07/20] Ignore zip warning --- tests/test_store/test_zip.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_store/test_zip.py b/tests/test_store/test_zip.py index 839656108b..b1cc94e463 100644 --- a/tests/test_store/test_zip.py +++ b/tests/test_store/test_zip.py @@ -19,6 +19,14 @@ from typing import Any +# TODO: work out where this is coming from and fix +pytestmark = [ + pytest.mark.filterwarnings( + "ignore:coroutine method 'aclose' of 'ZipStore.list' was never awaited:RuntimeWarning" + ) +] + + class TestZipStore(StoreTests[ZipStore, cpu.Buffer]): store_cls = ZipStore buffer_cls = cpu.Buffer From 963f657fd879a6a8fca7673af83484f3701c86e6 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 22 Jan 2025 11:36:38 +0000 Subject: [PATCH 08/20] Filter warning in test_stateful --- tests/test_store/test_stateful.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_store/test_stateful.py b/tests/test_store/test_stateful.py index 63df814ac9..e0201fb3d0 100644 --- a/tests/test_store/test_stateful.py +++ b/tests/test_store/test_stateful.py @@ -8,7 +8,12 @@ from zarr.storage import LocalStore, ZipStore from zarr.testing.stateful import ZarrHierarchyStateMachine, ZarrStoreStateMachine -pytestmark = pytest.mark.slow_hypothesis + +pytestmark = [ + pytest.mark.slow_hypothesis, + # TODO: work out where this warning is coming from and fix + pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning"), +] def test_zarr_hierarchy(sync_store: Store): From 8e14f46a3c361728a091db1e289e2c2a4f3ecd3d Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 22 Jan 2025 11:37:05 +0000 Subject: [PATCH 09/20] pre-commit fixes --- tests/test_store/test_fsspec.py | 4 +++- tests/test_store/test_stateful.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_store/test_fsspec.py b/tests/test_store/test_fsspec.py index a295979c1e..08cf2f286d 100644 --- a/tests/test_store/test_fsspec.py +++ b/tests/test_store/test_fsspec.py @@ -27,7 +27,9 @@ ), # TODO: fix these warnings pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning"), - pytest.mark.filterwarnings("ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited:RuntimeWarning") + pytest.mark.filterwarnings( + "ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited:RuntimeWarning" + ), ] fsspec = pytest.importorskip("fsspec") diff --git a/tests/test_store/test_stateful.py b/tests/test_store/test_stateful.py index e0201fb3d0..462b463373 100644 --- a/tests/test_store/test_stateful.py +++ b/tests/test_store/test_stateful.py @@ -16,6 +16,7 @@ ] + def test_zarr_hierarchy(sync_store: Store): def mk_test_instance_sync() -> ZarrHierarchyStateMachine: return ZarrHierarchyStateMachine(sync_store) From 4ccc751fc736b0b436470137bf24f56e4a873e7d Mon Sep 17 00:00:00 2001 From: David Stansby Date: Wed, 22 Jan 2025 11:49:21 +0000 Subject: [PATCH 10/20] Filter warning in test_wrapper --- tests/test_store/test_wrapper.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_store/test_wrapper.py b/tests/test_store/test_wrapper.py index 7e933548b3..71bd8244b5 100644 --- a/tests/test_store/test_wrapper.py +++ b/tests/test_store/test_wrapper.py @@ -72,6 +72,10 @@ def test_is_open_setter_raises(self, store: WrapperStore) -> None: store._is_open = True +# TODO: work out where warning is coming from and fix +@pytest.mark.filterwarnings( + "ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited:RuntimeWarning" +) @pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=True) async def test_wrapped_set(store: Store, capsys: pytest.CaptureFixture[str]) -> None: # define a class that prints when it sets From d391d2a7912cddea3c619f9e562ab8d29154ef5a Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 30 Jan 2025 10:00:21 +0000 Subject: [PATCH 11/20] Filter warning in memorystore --- tests/test_store/test_memory.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_store/test_memory.py b/tests/test_store/test_memory.py index f00d75a8f0..bed548eaac 100644 --- a/tests/test_store/test_memory.py +++ b/tests/test_store/test_memory.py @@ -1,5 +1,6 @@ from __future__ import annotations +import re from typing import TYPE_CHECKING import numpy as np @@ -15,6 +16,10 @@ from zarr.core.common import ZarrFormat +# TODO: work out where this warning is coming from and fix it +@pytest.mark.filterwarnings( + re.escape("ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited") +) class TestMemoryStore(StoreTests[MemoryStore, cpu.Buffer]): store_cls = MemoryStore buffer_cls = cpu.Buffer From 273faee61d41f365155124baeff446ff5a29ff2b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 17 Feb 2025 21:39:55 +0000 Subject: [PATCH 12/20] Close pool in multiprocessing test --- tests/test_array.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_array.py b/tests/test_array.py index efcf8a6bf9..3751d5409e 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1417,9 +1417,8 @@ def test_multiprocessing(store: Store, method: Literal["fork", "spawn", "forkser data = np.arange(100) arr = zarr.create_array(store=store, data=data) ctx = mp.get_context(method) - pool = ctx.Pool() - - results = pool.starmap(_index_array, [(arr, slice(len(data)))]) + with ctx.Pool() as pool: + results = pool.starmap(_index_array, [(arr, slice(len(data)))]) assert all(np.array_equal(r, data) for r in results) From 16cb8f6011943cfa068b463219e66c0a5cfa9e01 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Mon, 17 Feb 2025 21:43:27 +0000 Subject: [PATCH 13/20] pre-commit fixes --- tests/test_store/test_stateful.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_store/test_stateful.py b/tests/test_store/test_stateful.py index 462b463373..a17d7a55be 100644 --- a/tests/test_store/test_stateful.py +++ b/tests/test_store/test_stateful.py @@ -8,7 +8,6 @@ from zarr.storage import LocalStore, ZipStore from zarr.testing.stateful import ZarrHierarchyStateMachine, ZarrStoreStateMachine - pytestmark = [ pytest.mark.slow_hypothesis, # TODO: work out where this warning is coming from and fix @@ -16,7 +15,6 @@ ] - def test_zarr_hierarchy(sync_store: Store): def mk_test_instance_sync() -> ZarrHierarchyStateMachine: return ZarrHierarchyStateMachine(sync_store) From af544778f3b2fb16869143e4898bf12369e25a22 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 18 Feb 2025 07:55:49 +0000 Subject: [PATCH 14/20] Filter two more warnings --- tests/test_store/test_memory.py | 2 ++ tests/test_store/test_wrapper.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/tests/test_store/test_memory.py b/tests/test_store/test_memory.py index bed548eaac..e520c7d054 100644 --- a/tests/test_store/test_memory.py +++ b/tests/test_store/test_memory.py @@ -78,6 +78,8 @@ async def test_deterministic_size( np.testing.assert_array_equal(a[3:], 0) +# TODO: fix this warning +@pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") @gpu_test class TestGpuMemoryStore(StoreTests[GpuMemoryStore, gpu.Buffer]): store_cls = GpuMemoryStore diff --git a/tests/test_store/test_wrapper.py b/tests/test_store/test_wrapper.py index 71bd8244b5..b7a99580df 100644 --- a/tests/test_store/test_wrapper.py +++ b/tests/test_store/test_wrapper.py @@ -15,6 +15,10 @@ from zarr.core.buffer.core import BufferPrototype +# TODO: fix this warning +@pytest.mark.filterwarnings( + "ignore:coroutine 'ClientCreatorContext.__aexit__' was never awaited:RuntimeWarning" +) class TestWrapperStore(StoreTests[WrapperStore, Buffer]): store_cls = WrapperStore buffer_cls = Buffer From 90685e0414a448ef4dea8140442f508816f10e15 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 18 Feb 2025 08:55:05 +0000 Subject: [PATCH 15/20] Filter another warning --- tests/test_store/test_zip.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_store/test_zip.py b/tests/test_store/test_zip.py index b1cc94e463..0237258ab1 100644 --- a/tests/test_store/test_zip.py +++ b/tests/test_store/test_zip.py @@ -74,6 +74,8 @@ def test_store_supports_partial_writes(self, store: ZipStore) -> None: def test_store_supports_listing(self, store: ZipStore) -> None: assert store.supports_listing + # TODO: fix this warning + @pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") def test_api_integration(self, store: ZipStore) -> None: root = zarr.open_group(store=store, mode="a") From 51b44fd517ed255c04ebce69f8251db5efd0c6a0 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 18 Feb 2025 12:20:22 +0000 Subject: [PATCH 16/20] Filter more warnings --- tests/test_store/test_wrapper.py | 1 + tests/test_sync.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/test_store/test_wrapper.py b/tests/test_store/test_wrapper.py index b7a99580df..c6edd4f4dd 100644 --- a/tests/test_store/test_wrapper.py +++ b/tests/test_store/test_wrapper.py @@ -97,6 +97,7 @@ async def set(self, key: str, value: Buffer) -> None: assert await store_wrapped.get(key, buffer_prototype) == value +@pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") @pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=True) async def test_wrapped_get(store: Store, capsys: pytest.CaptureFixture[str]) -> None: # define a class that prints when it sets diff --git a/tests/test_sync.py b/tests/test_sync.py index e0002fc5a7..13b475f8da 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -90,6 +90,7 @@ def test_sync_raises_if_loop_is_closed() -> None: foo.assert_not_awaited() +@pytest.mark.filterwarnings("ignore:Unclosed client session:ResourceWarning") @pytest.mark.filterwarnings("ignore:coroutine.*was never awaited") def test_sync_raises_if_calling_sync_from_within_a_running_loop( sync_loop: asyncio.AbstractEventLoop | None, From 9ab8377d7f6f6a3d5e3d618e63c8506014334faa Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 18 Feb 2025 13:36:30 +0000 Subject: [PATCH 17/20] Add changelog --- changes/2714.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/2714.misc.rst diff --git a/changes/2714.misc.rst b/changes/2714.misc.rst new file mode 100644 index 0000000000..9ab55089d2 --- /dev/null +++ b/changes/2714.misc.rst @@ -0,0 +1 @@ +Make warning filters in the tests more specific, so warnings emitted by tests added in the future are more likely to be caught instead of ignored. From 75ece04af76f5841c1289a94bad300bec7a21411 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 8 Apr 2025 08:25:50 +0100 Subject: [PATCH 18/20] Ignore unclosed client sessions --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 36d9512e85..72bd16994e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -403,12 +403,11 @@ filterwarnings = [ "ignore:Creating a zarr.buffer.gpu.Buffer with an array that does not support the __cuda_array_interface__.*:UserWarning", "ignore:Automatic shard shape inference is experimental and may change without notice.*:UserWarning", "ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning", - "ignore:The dtype .* is currently not part in the Zarr format 3 specification.*:UserWarning", "ignore:Use zarr.create_array instead.:DeprecationWarning", "ignore:Duplicate name.*:UserWarning", "ignore:The `compressor` argument is deprecated. Use `compressors` instead.:UserWarning", "ignore:Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations.:UserWarning", - + "ignore:Unclosed client session Date: Tue, 8 Apr 2025 08:56:03 +0100 Subject: [PATCH 19/20] Put back dtype filter --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 72bd16994e..5dde0910a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -403,6 +403,7 @@ filterwarnings = [ "ignore:Creating a zarr.buffer.gpu.Buffer with an array that does not support the __cuda_array_interface__.*:UserWarning", "ignore:Automatic shard shape inference is experimental and may change without notice.*:UserWarning", "ignore:The codec .* is currently not part in the Zarr format 3 specification.*:UserWarning", + "ignore:The dtype .* is currently not part in the Zarr format 3 specification.*:UserWarning", "ignore:Use zarr.create_array instead.:DeprecationWarning", "ignore:Duplicate name.*:UserWarning", "ignore:The `compressor` argument is deprecated. Use `compressors` instead.:UserWarning", From e94b92ca632ddef5ca1deb5676eef7950cd0dba5 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 8 Apr 2025 09:15:44 +0100 Subject: [PATCH 20/20] Make client session filter better --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5dde0910a7..1ee5678f82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -408,7 +408,7 @@ filterwarnings = [ "ignore:Duplicate name.*:UserWarning", "ignore:The `compressor` argument is deprecated. Use `compressors` instead.:UserWarning", "ignore:Numcodecs codecs are not in the Zarr version 3 specification and may not be supported by other zarr implementations.:UserWarning", - "ignore:Unclosed client session