Skip to content

Commit

Permalink
Added API to set chunking size for datasets in meta writer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgdls authored and GDYendell committed Jan 24, 2023
1 parent 94cc19d commit 0a0c0e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tools/python/odin_data/meta_writer/hdf5dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def __init__(
rank=1,
shape=None,
maxshape=None,
chunks=None,
cache=True,
block_size=1000000,
block_timeout=600,
Expand All @@ -154,6 +155,7 @@ def __init__(
self.dtype = dtype
self.fillvalue = fillvalue
self.shape = shape if shape is not None else (0,) * rank
self.chunks = chunks
self.maxshape = maxshape if maxshape is not None else shape if shape is not None else (None,) * rank
self._cache = None

Expand Down Expand Up @@ -285,6 +287,7 @@ def __init__(
fillvalue=-1,
shape=None,
maxshape=None,
chunks=None,
cache=True,
block_size=1000000,
block_timeout=600,
Expand All @@ -296,6 +299,7 @@ def __init__(
fillvalue=fillvalue,
shape=shape,
maxshape=maxshape,
chunks=chunks,
cache=cache,
block_size=block_size,
block_timeout=block_timeout,
Expand Down
6 changes: 5 additions & 1 deletion tools/python/odin_data/meta_writer/meta_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,15 @@ def _create_datasets(self, dataset_size):
self._logger.debug("%s | Creating datasets", self._name)

for dataset in self._datasets.values():
chunks = dataset.maxshape
chunks = dataset.chunks
if chunks is None:
chunks = dataset.maxshape
if isinstance(chunks, int):
chunks = (chunks,)
if None in chunks:
chunks = None
self._logger.debug("Dataset {} chunking: {}".format(dataset.name, chunks))

dataset_handle = self._hdf5_file.create_dataset(
name=dataset.name,
shape=dataset.shape,
Expand Down

0 comments on commit 0a0c0e6

Please sign in to comment.