Skip to content
Snippets Groups Projects
Commit 6b594adb authored by Martin Bergemann's avatar Martin Bergemann :speech_balloon:
Browse files

Catch error if something goes wrong with the rechunking

parent 52851be7
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ from typing import Iterator, Optional
from dask.utils import format_bytes
import xarray as xr
__version__ = "2206.0.1"
__version__ = "2206.0.2"
ProgramName = "rechunk-data"
logging.basicConfig(
......@@ -56,7 +56,9 @@ def parse_args() -> argparse.Namespace:
type=str,
)
parser.add_argument(
"-v", action="count", default=0,
"-v",
action="count",
default=0,
)
parser.add_argument(
"-V",
......@@ -93,7 +95,10 @@ def _rechunk_dataset(dset: xr.Dataset, engine: str = "h5netcdf") -> xr.Dataset:
chunks[i] = None
else:
chunks[i] = "auto"
dset[var].data = dset[var].data.rechunk(chunks)
try:
dset[var].data = dset[var].data.rechunk(chunks)
except Exception as error:
logger.warning("Could not set chunk size for %s: ", var, error.__str__())
logger.debug("Settings encoding of variable %s", var)
dset[var].encoding["chunksizes"] = dset[var].data.chunksize
dset[var].encoding["zlib"] = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment