-
Notifications
You must be signed in to change notification settings - Fork 49
Write to parquet #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write to parquet #110
Changes from 6 commits
26f2723
e371fb0
c540bc4
abfed2f
690b648
5b8b9a6
6fea195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,8 @@ test = [ | |
"scipy", | ||
"pooch", | ||
"ruff", | ||
"fastparquet", | ||
"s3fs" | ||
|
||
] | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
import ujson # type: ignore | ||
import xarray as xr | ||
|
@@ -127,6 +128,47 @@ def test_accessor_to_kerchunk_json(self, tmp_path): | |
} | ||
assert loaded_refs == expected_ds_refs | ||
|
||
def test_accessor_to_kerchunk_parquet(self, tmp_path): | ||
chunks_dict = { | ||
"0.0": {"path": "foo.nc", "offset": 100, "length": 100}, | ||
"0.1": {"path": "foo.nc", "offset": 200, "length": 100}, | ||
} | ||
manifest = ChunkManifest(entries=chunks_dict) | ||
arr = ManifestArray( | ||
chunkmanifest=manifest, | ||
zarray=dict( | ||
shape=(2, 4), | ||
dtype=np.dtype("<i8"), | ||
chunks=(2, 2), | ||
compressor=None, | ||
filters=None, | ||
fill_value=None, | ||
order="C", | ||
), | ||
) | ||
ds = xr.Dataset({"a": (["x", "y"], arr)}) | ||
|
||
filepath = tmp_path / "refs" | ||
|
||
ds.virtualize.to_kerchunk(filepath, format="parquet", record_size=2) | ||
|
||
with open(tmp_path / "refs" / ".zmetadata") as f: | ||
meta = ujson.load(f) | ||
assert list(meta) == ["metadata", "record_size"] | ||
assert meta["record_size"] == 2 | ||
|
||
df0 = pd.read_parquet(filepath / "a" / "refs.0.parq") | ||
|
||
assert df0.to_dict() == { | ||
"offset": {0: 100, 1: 200}, | ||
"path": { | ||
0: "foo.nc", | ||
1: "foo.nc", | ||
}, | ||
"size": {0: 100, 1: 100}, | ||
"raw": {0: None, 1: None}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it means "inlined" in the kerchunk library tests this ref: |
||
} | ||
|
||
|
||
def test_kerchunk_roundtrip_in_memory_no_concat(): | ||
# Set up example xarray dataset | ||
|
Uh oh!
There was an error while loading. Please reload this page.