From 9261254653248cbd2bc0c1c1ec800343a61b2671 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 6 Aug 2015 18:43:27 +0800 Subject: [PATCH] language/environment: support non-stored results --- artiq/language/environment.py | 6 +++++- artiq/master/worker_db.py | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/artiq/language/environment.py b/artiq/language/environment.py index 2d567312f..1132e7f72 100644 --- a/artiq/language/environment.py +++ b/artiq/language/environment.py @@ -201,13 +201,15 @@ class HasEnvironment: raise ValueError("Parameter database not present") self.__pdb.set(key, value) - def set_result(self, key, value, realtime=False): + def set_result(self, key, value, realtime=False, store=True): """Writes the value of a result. :param realtime: Marks the result as real-time, making it immediately available to clients such as the user interface. Returns a ``Notifier`` instance that can be used to modify mutable results (such as lists) and synchronize the modifications with the clients. + :param store: Defines if the result should be stored permanently, + e.g. in HDF5 output. Default is to store. """ if self.__rdb is None: raise ValueError("Result database not present") @@ -217,11 +219,13 @@ class HasEnvironment: self.__rdb.rt[key] = value notifier = self.__rdb.rt[key] notifier.kernel_attr_init = False + self.__rdb.set_store(key, store) return notifier else: if key in self.__rdb.rt.read: raise ValueError("Result is already realtime") self.__rdb.nrt[key] = value + self.__rdb.set_store(key, store) def get_result(self, key): """Retrieves the value of a result. diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index 0da07dcf7..a4664415a 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -91,6 +91,7 @@ class ResultDB: def __init__(self): self.rt = Notifier(dict()) self.nrt = dict() + self.store = set() def get(self, key): try: @@ -98,9 +99,17 @@ class ResultDB: except KeyError: return self.rt[key].read + def set_store(self, key, store): + if store: + self.store.add(key) + else: + self.store.discard(key) + def write_hdf5(self, f): - result_dict_to_hdf5(f, self.rt.read) - result_dict_to_hdf5(f, self.nrt) + result_dict_to_hdf5( + f, {k: v for k, v in self.rt.read.items() if k in self.store}) + result_dict_to_hdf5( + f, {k: v for k, v in self.nrt.items() if k in self.store}) def _create_device(desc, dmgr):