@@ -103,7 +103,10 @@ def test_write_new_virtual_variable(
103
103
104
104
105
105
def test_set_single_virtual_ref_without_encoding (
106
- icechunk_filestore : "IcechunkStore" , simple_netcdf4 : Path , array_v3_metadata
106
+ icechunk_filestore : "IcechunkStore" ,
107
+ icechunk_repo : "Repository" ,
108
+ simple_netcdf4 : Path ,
109
+ array_v3_metadata ,
107
110
):
108
111
# TODO kerchunk doesn't work with zarr-python v3 yet so we can't use open_virtual_dataset and icechunk together!
109
112
# vds = open_virtual_dataset(netcdf4_file, indexes={})
@@ -128,15 +131,20 @@ def test_set_single_virtual_ref_without_encoding(
128
131
129
132
vds .virtualize .to_icechunk (icechunk_filestore )
130
133
131
- root_group = zarr .group (store = icechunk_filestore )
134
+ icechunk_filestore .session .commit ("test" )
135
+
136
+ icechunk_readonly_session = icechunk_repo .readonly_session ("main" )
137
+ root_group = zarr .open_group (store = icechunk_readonly_session .store , mode = "r" )
132
138
array = root_group ["foo" ]
133
139
134
140
# check chunk references
135
141
# TODO we can't explicitly check that the path/offset/length is correct because
136
142
# icechunk doesn't yet expose any get_virtual_refs method
137
143
138
144
with (
139
- xr .open_zarr (store = icechunk_filestore , zarr_format = 3 , consolidated = False ) as ds ,
145
+ xr .open_zarr (
146
+ store = icechunk_readonly_session .store , zarr_format = 3 , consolidated = False
147
+ ) as ds ,
140
148
xr .open_dataset (simple_netcdf4 ) as expected_ds ,
141
149
):
142
150
expected_array = expected_ds ["foo" ].to_numpy ()
@@ -149,7 +157,10 @@ def test_set_single_virtual_ref_without_encoding(
149
157
150
158
151
159
def test_set_single_virtual_ref_with_encoding (
152
- icechunk_filestore : "IcechunkStore" , netcdf4_file : Path , array_v3_metadata
160
+ icechunk_filestore : "IcechunkStore" ,
161
+ icechunk_repo : "Repository" ,
162
+ netcdf4_file : Path ,
163
+ array_v3_metadata ,
153
164
):
154
165
with xr .open_dataset (netcdf4_file ) as ds :
155
166
# We drop the coordinates because we don't have them in the zarr test case
@@ -179,7 +190,10 @@ def test_set_single_virtual_ref_with_encoding(
179
190
180
191
vds .virtualize .to_icechunk (icechunk_filestore )
181
192
182
- root_group = zarr .group (store = icechunk_filestore )
193
+ icechunk_filestore .session .commit ("test" )
194
+
195
+ icechunk_readonly_session = icechunk_repo .readonly_session ("main" )
196
+ root_group = zarr .open_group (store = icechunk_readonly_session .store , mode = "r" )
183
197
air_array = root_group ["air" ]
184
198
assert isinstance (air_array , zarr .Array )
185
199
@@ -195,7 +209,7 @@ def test_set_single_virtual_ref_with_encoding(
195
209
196
210
# check the data
197
211
with xr .open_zarr (
198
- store = icechunk_filestore , zarr_format = 3 , consolidated = False
212
+ store = icechunk_readonly_session . store , zarr_format = 3 , consolidated = False
199
213
) as actual_ds :
200
214
# Because we encode attributes, attributes may differ, for example
201
215
# actual_range for expected_ds.air is array([185.16, 322.1 ], dtype=float32)
@@ -429,7 +443,9 @@ def test_generate_chunk_key_append_axis_out_of_bounds():
429
443
generate_chunk_key (index , append_axis = append_axis , existing_num_chunks = 1 )
430
444
431
445
432
- def test_roundtrip_coords (manifest_array , icechunk_filestore : "IcechunkStore" ):
446
+ def test_roundtrip_coords (
447
+ manifest_array , icechunk_filestore : "IcechunkStore" , icechunk_repo : "Repository"
448
+ ):
433
449
# regression test for GH issue #574
434
450
435
451
vds = xr .Dataset (
@@ -450,8 +466,10 @@ def test_roundtrip_coords(manifest_array, icechunk_filestore: "IcechunkStore"):
450
466
},
451
467
)
452
468
vds .virtualize .to_icechunk (icechunk_filestore )
469
+ icechunk_filestore .session .commit ("test" )
453
470
454
- roundtrip = xr .open_zarr (icechunk_filestore , consolidated = False )
471
+ icechunk_readonly_session = icechunk_repo .readonly_session ("main" )
472
+ roundtrip = xr .open_zarr (icechunk_readonly_session .store , consolidated = False )
455
473
assert set (roundtrip .coords ) == set (vds .coords )
456
474
457
475
0 commit comments