From 979363228288c836229578bb183928671250be7c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 21 Oct 2018 12:08:34 +0800 Subject: [PATCH] enviromnment: rename 'save' in set_dataset to 'archive'. Closes #1171 --- RELEASE_NOTES.rst | 2 ++ artiq/examples/no_hardware/repository/code_applet.py | 2 +- .../no_hardware/repository/flopping_f_simulation.py | 10 +++++----- artiq/examples/no_hardware/repository/histograms.py | 6 +++--- .../no_hardware/repository/remote_exec_demo.py | 12 ++++++------ artiq/language/environment.py | 12 +++++++++--- artiq/master/worker_db.py | 4 ++-- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 0c96a5cd4..ab4196181 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -39,6 +39,8 @@ ARTIQ-4 is no longer necessary. * The configuration entry ``startup_clock`` is renamed ``rtio_clock``. Switching clocks dynamically (i.e. without device restart) is no longer supported. +* ``set_dataset(..., save=True)`` has been renamed + ``set_dataset(..., archive=True)``. ARTIQ-3 diff --git a/artiq/examples/no_hardware/repository/code_applet.py b/artiq/examples/no_hardware/repository/code_applet.py index a1e5f2f56..4026cea55 100644 --- a/artiq/examples/no_hardware/repository/code_applet.py +++ b/artiq/examples/no_hardware/repository/code_applet.py @@ -23,7 +23,7 @@ class CreateCodeApplet(EnvExperiment): "code_applet_dataset", code=f.read(), group="autoapplet") for i in reversed(range(10)): self.set_dataset("code_applet_dataset", i, - broadcast=True, save=False) + broadcast=True, archive=False) time.sleep(1) self.ccb.issue("disable_applet", "code_applet_example", group="autoapplet") diff --git a/artiq/examples/no_hardware/repository/flopping_f_simulation.py b/artiq/examples/no_hardware/repository/flopping_f_simulation.py index c8f9b94ea..d79aa11ba 100644 --- a/artiq/examples/no_hardware/repository/flopping_f_simulation.py +++ b/artiq/examples/no_hardware/repository/flopping_f_simulation.py @@ -35,12 +35,12 @@ class FloppingF(EnvExperiment): l = len(self.frequency_scan) self.set_dataset("flopping_f_frequency", np.full(l, np.nan), - broadcast=True, save=False) + broadcast=True, archive=False) self.set_dataset("flopping_f_brightness", np.full(l, np.nan), broadcast=True) self.set_dataset("flopping_f_fit", np.full(l, np.nan), - broadcast=True, save=False) + broadcast=True, archive=False) self.ccb.issue("create_applet", "flopping_f", "${artiq_applet}plot_xy " @@ -66,14 +66,14 @@ class FloppingF(EnvExperiment): frequency = np.fromiter(self.frequency_scan, np.float) assert frequency.shape == brightness.shape self.set_dataset("flopping_f_frequency", frequency, - broadcast=True, save=False) + broadcast=True, archive=False) popt, pcov = curve_fit(model, frequency, brightness, p0=[self.get_dataset("flopping_freq", 1500.0, archive=False)]) perr = np.sqrt(np.diag(pcov)) if perr < 0.1: F0 = float(popt) - self.set_dataset("flopping_freq", F0, persist=True, save=False) + self.set_dataset("flopping_freq", F0, persist=True, archive=False) self.set_dataset("flopping_f_fit", np.array([model(x, F0) for x in frequency]), - broadcast=True, save=False) + broadcast=True, archive=False) diff --git a/artiq/examples/no_hardware/repository/histograms.py b/artiq/examples/no_hardware/repository/histograms.py index c7a0d1a3c..8f12d8eb6 100644 --- a/artiq/examples/no_hardware/repository/histograms.py +++ b/artiq/examples/no_hardware/repository/histograms.py @@ -13,15 +13,15 @@ class Histograms(EnvExperiment): bin_boundaries = np.linspace(-10, 30, nbins + 1) self.set_dataset("hd_bins", bin_boundaries, - broadcast=True, save=False) + broadcast=True, archive=False) xs = np.empty(npoints) xs.fill(np.nan) self.set_dataset("hd_xs", xs, - broadcast=True, save=False) + broadcast=True, archive=False) self.set_dataset("hd_counts", np.empty((npoints, nbins)), - broadcast=True, save=False) + broadcast=True, archive=False) for i in range(npoints): histogram, _ = np.histogram(np.random.normal(i, size=1000), diff --git a/artiq/examples/no_hardware/repository/remote_exec_demo.py b/artiq/examples/no_hardware/repository/remote_exec_demo.py index a4028f764..c347d43be 100644 --- a/artiq/examples/no_hardware/repository/remote_exec_demo.py +++ b/artiq/examples/no_hardware/repository/remote_exec_demo.py @@ -25,10 +25,10 @@ class RemoteExecDemo(EnvExperiment): def transfer_parameters(self, parameters): w, h, cx, cy = parameters - self.set_dataset("rexec_demo.gaussian_w", w, save=False, broadcast=True) - self.set_dataset("rexec_demo.gaussian_h", h, save=False, broadcast=True) - self.set_dataset("rexec_demo.gaussian_cx", cx, save=False, broadcast=True) - self.set_dataset("rexec_demo.gaussian_cy", cy, save=False, broadcast=True) + self.set_dataset("rexec_demo.gaussian_w", w, archive=False, broadcast=True) + self.set_dataset("rexec_demo.gaussian_h", h, archive=False, broadcast=True) + self.set_dataset("rexec_demo.gaussian_cx", cx, archive=False, broadcast=True) + self.set_dataset("rexec_demo.gaussian_cy", cy, archive=False, broadcast=True) def fps_meter(self): t = time.monotonic() @@ -37,7 +37,7 @@ class RemoteExecDemo(EnvExperiment): dt = t - self.last_pt_update if dt >= 5: pt = dt/self.iter_count - self.set_dataset("rexec_demo.picture_pt", pt, save=False, broadcast=True) + self.set_dataset("rexec_demo.picture_pt", pt, archive=False, broadcast=True) self.last_pt_update = t self.iter_count = 0 else: @@ -50,7 +50,7 @@ class RemoteExecDemo(EnvExperiment): data = self.camera_sim.get_picture() if self.show_picture: self.set_dataset("rexec_demo.picture", data, - save=False, broadcast=True) + archive=False, broadcast=True) if self.enable_fit: p = remote_exec_processing.fit(data, self.get_dataset) self.transfer_parameters(p) diff --git a/artiq/language/environment.py b/artiq/language/environment.py index 3bb33647d..b7db5d54d 100644 --- a/artiq/language/environment.py +++ b/artiq/language/environment.py @@ -1,3 +1,4 @@ +import warnings from collections import OrderedDict from inspect import isclass @@ -286,7 +287,7 @@ class HasEnvironment: @rpc(flags={"async"}) def set_dataset(self, key, value, - broadcast=False, persist=False, save=True): + broadcast=False, persist=False, archive=True, save=None): """Sets the contents and handling modes of a dataset. Datasets must be scalars (``bool``, ``int``, ``float`` or NumPy scalar) @@ -296,10 +297,15 @@ class HasEnvironment: dispatches it. :param persist: the master should store the data on-disk. Implies broadcast. - :param save: the data is saved into the local storage of the current + :param archive: the data is saved into the local storage of the current run (archived as a HDF5 file). + :param save: deprecated. """ - self.__dataset_mgr.set(key, value, broadcast, persist, save) + if save is not None: + warnings.warn("set_dataset save parameter is deprecated, " + "use archive instead", DeprecationWarning) + archive = save + self.__dataset_mgr.set(key, value, broadcast, persist, archive) @rpc(flags={"async"}) def mutate_dataset(self, key, index, value): diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index 3551d4fc9..356a79bef 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -117,7 +117,7 @@ class DatasetManager: self.ddb = ddb self.broadcast.publish = ddb.update - def set(self, key, value, broadcast=False, persist=False, save=True): + def set(self, key, value, broadcast=False, persist=False, archive=True): if key in self.archive: logger.warning("Modifying dataset '%s' which is in archive, " "archive will remain untouched", @@ -129,7 +129,7 @@ class DatasetManager: self.broadcast[key] = persist, value elif key in self.broadcast.read: del self.broadcast[key] - if save: + if archive: self.local[key] = value elif key in self.local: del self.local[key]