From adeb88619cf49fd912ba0bfb8848ac871b4d35a2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 3 May 2016 16:27:24 +0800 Subject: [PATCH] language/environment: update kernel_invariants in setattr_argument and setattr_device --- RELEASE_NOTES.rst | 7 +++++++ artiq/language/environment.py | 12 ++++++++++-- artiq/test/coredevice/test_rtio.py | 4 ---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 2d376240b..e04e3cbd9 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -3,6 +3,13 @@ Release notes ============= + +1.0rc4 (unreleased) +------------------- + +* setattr_argument and setattr_device add their key to kernel_invariants. + + 1.0rc3 ------ diff --git a/artiq/language/environment.py b/artiq/language/environment.py index 9f54bab15..80ce8c877 100644 --- a/artiq/language/environment.py +++ b/artiq/language/environment.py @@ -227,8 +227,12 @@ class HasEnvironment: def setattr_argument(self, key, processor=None, group=None): """Sets an argument as attribute. The names of the argument and of the - attribute are the same.""" + attribute are the same. + + The key is added to the instance's kernel invariants.""" setattr(self, key, self.get_argument(key, processor, group)) + kernel_invariants = getattr(self, "kernel_invariants", set()) + self.kernel_invariants = kernel_invariants | {key} def get_device_db(self): """Returns the full contents of the device database.""" @@ -248,8 +252,12 @@ class HasEnvironment: def setattr_device(self, key): """Sets a device driver as attribute. The names of the device driver - and of the attribute are the same.""" + and of the attribute are the same. + + The key is added to the instance's kernel invariants.""" setattr(self, key, self.get_device(key)) + kernel_invariants = getattr(self, "kernel_invariants", set()) + self.kernel_invariants = kernel_invariants | {key} def set_dataset(self, key, value, broadcast=False, persist=False, save=True): diff --git a/artiq/test/coredevice/test_rtio.py b/artiq/test/coredevice/test_rtio.py index d1ca16220..ef0d58ebe 100644 --- a/artiq/test/coredevice/test_rtio.py +++ b/artiq/test/coredevice/test_rtio.py @@ -83,8 +83,6 @@ class ClockGeneratorLoopback(EnvExperiment): class PulseRate(EnvExperiment): - kernel_invariants = {"core", "ttl_out"} - def build(self): self.setattr_device("core") self.setattr_device("ttl_out") @@ -107,8 +105,6 @@ class PulseRate(EnvExperiment): class PulseRateDDS(EnvExperiment): - kernel_invariants = {"core", "core_dds", "dds0", "dds1"} - def build(self): self.setattr_device("core") self.setattr_device("core_dds")