diff --git a/kerchunk/combine.py b/kerchunk/combine.py index 7bdf9bc2..6dc71be7 100644 --- a/kerchunk/combine.py +++ b/kerchunk/combine.py @@ -383,13 +383,8 @@ def store_coords(self): """ Write coordinate arrays into the output """ - fs = fsspec.filesystem( - "reference", - fo=self.out, - remote_protocol=self.remote_protocol, - remote_options=self.remote_options, - ) - store = zarr.storage.FSStore("", fs=fs) + kv = {} + store = zarr.storage.KVStore(kv) group = zarr.open(store) m = self.fss[0].get_mapper("") z = zarr.open(m) @@ -442,6 +437,7 @@ def store_coords(self): else: arr.attrs.update(self.cf_units[k]) # TODO: rewrite .zarray/.zattrs with ujson to save space. Maybe make them by hand anyway. + self.out.update(kv) logger.debug("Written coordinates") for fn in [".zgroup", ".zattrs"]: # top-level group attributes from first input diff --git a/kerchunk/tests/test_combine.py b/kerchunk/tests/test_combine.py index 5715a135..efd7e051 100644 --- a/kerchunk/tests/test_combine.py +++ b/kerchunk/tests/test_combine.py @@ -475,10 +475,9 @@ def test_lazy_filler(tmpdir, refs): mzz.second_pass() # actual references don't show - assert set(out) == { + assert set(out.zmetadata) == { ".zattrs", ".zgroup", - ".zmetadata", "data/.zarray", "data/.zattrs", "static/.zarray", @@ -486,11 +485,11 @@ def test_lazy_filler(tmpdir, refs): "time/.zarray", "time/.zattrs", } + assert out._items out.flush() - assert set(out) == { + assert set(out.zmetadata) == { ".zattrs", ".zgroup", - ".zmetadata", "data/.zarray", "data/.zattrs", "static/.zarray", @@ -498,6 +497,7 @@ def test_lazy_filler(tmpdir, refs): "time/.zarray", "time/.zattrs", } + assert set(out._items) == {".zmetadata"} allfiles = fs.find(tmpdir) assert [ f"{tmpdir}/{a}" in allfiles for a in ["static/refs.0.parq", "data/refs.0.parq"]