Skip to content

Commit 48b94d2

Browse files
committed
fix open-meteo kerchunk test
1 parent 7ec0bf6 commit 48b94d2

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

kerchunk/open_meteo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
try:
2525
import omfiles
26+
import omfiles._numcodecs
2627
except ModuleNotFoundError: # pragma: no cover
2728
raise ImportError(
2829
"omfiles is required for kerchunking Open-Meteo files. Please install with "
@@ -191,10 +192,10 @@ def __init__(
191192
fs, path = fsspec.core.url_to_fs(om_file, **(storage_options or {}))
192193
self.input_file = fs.open(path, "rb")
193194
url = om_file
194-
self.reader = omfiles.OmFilePyReader(self.input_file)
195+
self.reader = omfiles.OmFileReader(self.input_file)
195196
elif isinstance(om_file, io.IOBase):
196197
self.input_file = om_file
197-
self.reader = omfiles.OmFilePyReader(self.input_file)
198+
self.reader = omfiles.OmFileReader(self.input_file)
198199
else:
199200
raise ValueError("type of input `om_file` not recognized")
200201

@@ -219,7 +220,7 @@ def translate(self):
219220
# 1. Extract metadata about shape, dtype, chunks, etc.
220221
shape = self.reader.shape
221222
dtype = self.reader.dtype
222-
chunks = self.reader.chunk_dimensions
223+
chunks = self.reader.chunks
223224
scale_factor = self.reader.scale_factor
224225
add_offset = self.reader.add_offset
225226
lut = self.reader.get_complete_lut()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dev = [
5050
"scipy",
5151
"netcdf4",
5252
"pytest-subtests",
53-
"omfiles @ git+https://github.com/open-meteo/python-omfiles.git@codecs"
53+
"omfiles @ git+https://github.com/open-meteo/python-omfiles.git@get-complete-lut"
5454
]
5555

5656
[project.urls]

tests/test_open_meteo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def test_single_om_to_zarr():
4848
print("z.chunks", z.chunks)
4949

5050
# Verify basic metadata matches original file
51-
reader = omfiles.OmFilePyReader(test_file)
52-
assert list(z.shape) == reader.shape, f"Shape mismatch: {z.shape} vs {reader.shape}"
51+
reader = omfiles.OmFileReader(test_file)
52+
assert z.shape == reader.shape, f"Shape mismatch: {z.shape} vs {reader.shape}"
5353
assert str(z.dtype) == str(reader.dtype), f"Dtype mismatch: {z.dtype} vs {reader.dtype}"
54-
assert list(z.chunks) == reader.chunk_dimensions, f"Chunks mismatch: {z.chunks} vs {reader.chunk_dimensions}"
54+
assert z.chunks == reader.chunks, f"Chunks mismatch: {z.chunks} vs {reader.chunks}"
5555

5656
# TODO: Using the following chunk_index leads to a double free / corruption error!
5757
# Even with a concurrency of 1: `zarr.config.config["async"]["concurrency"] = 1`
@@ -127,8 +127,8 @@ def test_multizarr_to_zarr():
127127
z = group["data"]
128128

129129
# Open both original files for comparison
130-
reader1 = omfiles.OmFilePyReader(file1)
131-
reader2 = omfiles.OmFilePyReader(file2)
130+
reader1 = omfiles.OmFileReader(file1)
131+
reader2 = omfiles.OmFileReader(file2)
132132

133133
# Check that the combined shape is the sum along the time axis
134134
expected_shape = list(reader1.shape)
@@ -165,7 +165,7 @@ def test_multizarr_to_zarr():
165165
# ds = xr.open_zarr(store, consolidated=False)
166166

167167
# # Basic validation
168-
# reader = omfiles.OmFilePyReader(test_file)
168+
# reader = omfiles.OmFileReader(test_file)
169169
# assert ds.dims == dict(zip(["time", "y", "x"], reader.shape))
170170

171171
# # Get some data to verify decompression pipeline

0 commit comments

Comments
 (0)