enviromnment: rename 'save' in set_dataset to 'archive'. Closes #1171

This commit is contained in:
Sebastien Bourdeauducq 2018-10-21 12:08:34 +08:00
parent 029f9d983a
commit 9793632282
7 changed files with 28 additions and 20 deletions

View File

@ -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

View File

@ -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")

View File

@ -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)

View File

@ -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),

View File

@ -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)

View File

@ -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):

View File

@ -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]