diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index bbd2cd113..c0cd659a5 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -15,7 +15,7 @@ Highlights: - Exposes upconverter calibration and enabling/disabling of upconverter LO & RF outputs. * HDF5 options can now be passed when creating datasets with ``set_dataset``. This allows in particular to use transparent compression filters as follows: - ``set_dataset(name, value, compression="gzip")``. + ``set_dataset(name, value, hdf5_options={"compression": "gzip"})``. Breaking changes: diff --git a/artiq/language/environment.py b/artiq/language/environment.py index fa64c7906..9647325cb 100644 --- a/artiq/language/environment.py +++ b/artiq/language/environment.py @@ -332,7 +332,7 @@ class HasEnvironment: @rpc(flags={"async"}) def set_dataset(self, key, value, broadcast=False, persist=False, archive=True, save=None, - **hdf5_options): + hdf5_options=None): """Sets the contents and handling modes of a dataset. Datasets must be scalars (``bool``, ``int``, ``float`` or NumPy scalar) @@ -345,8 +345,8 @@ class HasEnvironment: :param archive: the data is saved into the local storage of the current run (archived as a HDF5 file). :param save: deprecated. - :param hdf5_options: additional keyword arguments are passed to - :meth:`h5py.Group.create_dataset`. For example, pass ``compression="gzip"`` + :param hdf5_options: dict of keyword arguments to pass to + :meth:`h5py.Group.create_dataset`. For example, pass ``{"compression": "gzip"}`` to enable transparent zlib compression of this dataset in the HDF5 archive. See the `h5py documentation `_ for a list of valid options. diff --git a/artiq/master/databases.py b/artiq/master/databases.py index 310b5caec..8ef71c6a2 100644 --- a/artiq/master/databases.py +++ b/artiq/master/databases.py @@ -87,7 +87,7 @@ class DatasetDB(TaskObject): process_mod(self.data, mod) # convenience functions (update() can be used instead) - def set(self, key, value, persist=None, **hdf5_options): + def set(self, key, value, persist=None, hdf5_options=None): if persist is None: if key in self.data.raw_view: persist = self.data.raw_view[key]["persist"] diff --git a/artiq/test/test_dataset_db.py b/artiq/test/test_dataset_db.py index 3fa4b1f8a..3d087a806 100644 --- a/artiq/test/test_dataset_db.py +++ b/artiq/test/test_dataset_db.py @@ -21,8 +21,8 @@ class TestDatasetDB(unittest.TestCase): self.ddb = DatasetDB(self.persist_file.name) self.ddb.set(KEY1, DATA, persist=True) - self.ddb.set(KEY2, DATA, persist=True, compression=COMP) - self.ddb.set(KEY3, DATA, shuffle=True) + self.ddb.set(KEY2, DATA, persist=True, hdf5_options=dict(compression=COMP)) + self.ddb.set(KEY3, DATA, hdf5_options=dict(shuffle=True)) self.save_ddb_to_disk() diff --git a/artiq/test/test_datasets.py b/artiq/test/test_datasets.py index 0d86a4b7c..3fa6d6bb7 100644 --- a/artiq/test/test_datasets.py +++ b/artiq/test/test_datasets.py @@ -108,9 +108,16 @@ class ExperimentDatasetCase(unittest.TestCase): def test_write_hdf5_options(self): data = np.random.randint(0, 1024, 1024) - self.exp.set(KEY, data, - compression="gzip", compression_opts=6, - shuffle=True, fletcher32=True) + self.exp.set( + KEY, + data, + hdf5_options=dict( + compression="gzip", + compression_opts=6, + shuffle=True, + fletcher32=True + ), + ) with h5py.File("test.h5", "a", "core", backing_store=False) as f: self.dataset_mgr.write_hdf5(f)