forked from M-Labs/artiq
environment: call prepare for children by default, closes #545
This commit is contained in:
parent
1cb8f642b4
commit
5fbcdacec7
@ -8,6 +8,8 @@ Release notes
|
||||
|
||||
* The --embed option of applets is replaced with the environment variable
|
||||
ARTIQ_APPLET_EMBED.
|
||||
* EnvExperiment's prepare calls prepare for all its children.
|
||||
|
||||
|
||||
2.0rc1
|
||||
------
|
||||
|
@ -194,6 +194,7 @@ class HasEnvironment:
|
||||
"""Provides methods to manage the environment of an experiment (arguments,
|
||||
devices, datasets)."""
|
||||
def __init__(self, managers_or_parent, *args, **kwargs):
|
||||
self.children = []
|
||||
if isinstance(managers_or_parent, tuple):
|
||||
self.__device_mgr = managers_or_parent[0]
|
||||
self.__dataset_mgr = managers_or_parent[1]
|
||||
@ -202,11 +203,15 @@ class HasEnvironment:
|
||||
self.__device_mgr = managers_or_parent.__device_mgr
|
||||
self.__dataset_mgr = managers_or_parent.__dataset_mgr
|
||||
self.__argument_mgr = managers_or_parent.__argument_mgr
|
||||
managers_or_parent.register_child(self)
|
||||
|
||||
self.__in_build = True
|
||||
self.build(*args, **kwargs)
|
||||
self.__in_build = False
|
||||
|
||||
def register_child(self, child):
|
||||
self.children.append(child)
|
||||
|
||||
def build(self):
|
||||
"""Should be implemented by the user to request arguments.
|
||||
|
||||
@ -373,7 +378,11 @@ class EnvExperiment(Experiment, HasEnvironment):
|
||||
environment manager.
|
||||
|
||||
Most experiment should derive from this class."""
|
||||
pass
|
||||
def prepare(self):
|
||||
"""The default prepare method calls prepare for all children, in the
|
||||
order of instantiation."""
|
||||
for child in self.children:
|
||||
child.prepare()
|
||||
|
||||
|
||||
def is_experiment(o):
|
||||
|
Loading…
Reference in New Issue
Block a user