aiaccel.torch.h5py.HDF5Writer#

class aiaccel.torch.h5py.HDF5Writer[source]#

Abstract base class for writing data to an HDF5 file.

This class provides methods to write data into HDF5 format, supporting both single-process and parallel (MPI-based) writing. Subclasses must implement prepare_globals and prepare_group to define how data is structured.

Typical usage is supposed to be:

class FooHDF5Writer(HDF5Writer):
    def prepare_globals(self):
        item_list = list(range(100))

        offset = 10
        maximum = 50

        return item_list, (offset, maximum)

    def prepare_group(self, item, context):
        offset, maximum = context

        group_name = f"{item:04d}

        return {group_name: {"data": np.full([10, 10], offset + item).clip(maximum)}}

writer = FooHDF5Writer()
writer.write("test.hdf5", parallel=False)
__init__()#

Methods

__init__()

prepare_globals()

Prepare the global data required for writing.

prepare_group(item, context)

Prepare groups of datasets for writing to HDF5.

write(filename[, parallel])

Write data to an HDF5 file, optionally using parallel processing.

Attributes

h5