Skip to content

Commit 4be931b

Browse files
committed
test clarity
1 parent 5bffb4d commit 4be931b

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

tests/io/test_store_abstractions.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
labels, shapes, points, and a full sdata. The write-read-write cycle specifically pins
1616
the categorical-schema invariant that the arrow-filesystem migration (this PR) had to
1717
re-establish in ``_read_points``.
18-
- Writing to a ``UPath`` lands the root metadata artifact in the backend. The read-time
19-
consumption of consolidated metadata is an xfail placeholder for the cloud-native
20-
follow-up.
18+
- Writing to a ``UPath`` lands the root metadata artifact in the backend. Reading via
19+
consolidated metadata is left as a failing test on purpose: the invariant is stated,
20+
but the fix (threading ``use_consolidated=True`` through ``read_zarr`` / the store
21+
opener) is intentionally open for review discussion rather than silently suppressed.
2122
- A ``MemoryFileSystem`` subclass that refuses listing proves that ``SpatialData.read``
2223
does not depend on directory listing for basic elements (the precondition for serving
2324
public HTTPS zarrs).
@@ -181,9 +182,12 @@ def test_roundtrip_full_sdata(self, full_sdata: SpatialData) -> None:
181182
class TestConsolidatedMetadataOnRead:
182183
"""Writing produces a consolidated-metadata artifact; the read path does not consume it yet.
183184
184-
The follow-up cloud-native PR will thread ``use_consolidated=True`` through
185-
``open_read_store`` / ``read_zarr``. When that lands, the xfail here flips to a pass
186-
and the assertion becomes strict.
185+
The second test in this class is intentionally left to fail (not xfail-ed): it pins
186+
the invariant we want -- that reading a remote store uses the consolidated metadata
187+
artifact so small-GET traffic stays bounded -- and leaves the implementation detail
188+
(threading ``use_consolidated=True`` through ``read_zarr`` / ``open_read_store``)
189+
open for reviewer discussion. Please comment on the right place to wire it in; we
190+
would rather the gap be visible than hidden behind ``@pytest.mark.xfail``.
187191
"""
188192

189193
def test_write_produces_root_metadata_on_memory_upath(self, images: SpatialData) -> None:
@@ -197,33 +201,32 @@ def test_write_produces_root_metadata_on_memory_upath(self, images: SpatialData)
197201
root_keys = [p.rsplit("/", 1)[-1] for p in fs.find(upath.path)]
198202
assert "zarr.json" in root_keys or ".zmetadata" in root_keys, root_keys
199203

200-
@pytest.mark.xfail(
201-
reason=(
202-
"read_zarr opens the root group with zarr.open_group(store, mode='r') without "
203-
"use_consolidated=True, so a consolidated metadata artifact is ignored on remote "
204-
"reads. The cloud-native follow-up will thread use_consolidated through open_read_store."
205-
),
206-
strict=True,
207-
)
208204
def test_read_zarr_opens_via_consolidated_metadata(self, images: SpatialData) -> None:
205+
# Left to fail intentionally: read_zarr currently opens the root group with
206+
# zarr.open_group(store, mode="r") without use_consolidated=True, so a written
207+
# consolidated-metadata artifact is ignored on read. The fix site (wiring
208+
# use_consolidated through open_read_store / read_zarr) is left open for review
209+
# discussion rather than hidden behind @pytest.mark.xfail.
209210
upath = _fresh_memory_upath("consolidated-read")
210211
images.write(upath, overwrite=True)
211212

212213
# Count store GETs on the memory fs to detect that consolidated metadata is used:
213214
# without consolidation, reading one image requires many small zarr.json / .zgroup GETs.
215+
# We monkeypatch the public ``cat_file`` method (the one MemoryFileSystem actually
216+
# exposes); targeting ``_cat_file`` would silently miss every call.
214217
fs = upath.fs
215-
original_cat_file = fs._cat_file
218+
original_cat_file = fs.cat_file
216219
call_count = {"n": 0}
217220

218221
def counting_cat_file(path, *args, **kwargs):
219222
call_count["n"] += 1
220223
return original_cat_file(path, *args, **kwargs)
221224

222-
fs._cat_file = counting_cat_file
225+
fs.cat_file = counting_cat_file
223226
try:
224227
SpatialData.read(upath)
225228
finally:
226-
fs._cat_file = original_cat_file
229+
fs.cat_file = original_cat_file
227230

228231
# With consolidated metadata, we expect very few small-metadata GETs for a
229232
# trivial 1-image sdata. Without it, typical count is >> 10. The exact bound is

0 commit comments

Comments
 (0)