Skip to content

Commit

Permalink
Merge pull request #14 from kthyng/modify_dataset_loader
Browse files Browse the repository at this point in the history
fix to loader for chunks issue
  • Loading branch information
kthyng authored Aug 18, 2023
2 parents b0057fd + d92bb0d commit a7d02c7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions xpublish_host/loaders/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def load_dataset_zarr(json_path: str | Path, chunks=None):
# encoding and dask arrays
# https://github.com/xpublish-community/xpublish/issues/207
chunks = chunks or {}
print(f"Chunks are {chunks}.")
print(f"using json from {json_path}")

L.info(f"Chunks are {chunks}.")

L.info(f"using json from {json_path}")

ds = xr.open_dataset(
"reference://", engine="zarr",
Expand All @@ -30,9 +30,11 @@ def load_dataset_zarr(json_path: str | Path, chunks=None):

# remove chunks encoding, same issue as above
# https://github.com/xpublish-community/xpublish/issues/207
print("removing chunks from all variable encoding")
for varname in ds.data_vars:
del ds[varname].encoding["chunks"]
L.info("removing chunks from all variable encoding...")
for varname in ds.variables:
if "chunks" in ds[varname].encoding:
L.info(f"removing chunks from {varname}")
del ds[varname].encoding["chunks"]

# ds = ds.reset_encoding()
return ds

0 comments on commit a7d02c7

Please sign in to comment.