mirror of https://github.com/m-labs/artiq.git
devices: introduce notify_run_end API
This commit is contained in:
parent
795c4372fa
commit
ede0b37c6e
|
@ -222,6 +222,7 @@ def run(with_file=False):
|
||||||
exp_inst = _build_experiment(device_mgr, dataset_mgr, args)
|
exp_inst = _build_experiment(device_mgr, dataset_mgr, args)
|
||||||
exp_inst.prepare()
|
exp_inst.prepare()
|
||||||
exp_inst.run()
|
exp_inst.run()
|
||||||
|
device_mgr.notify_run_end()
|
||||||
exp_inst.analyze()
|
exp_inst.analyze()
|
||||||
except CompileError as error:
|
except CompileError as error:
|
||||||
return
|
return
|
||||||
|
|
|
@ -804,6 +804,7 @@ def main():
|
||||||
experiment = SinaraTester((device_mgr, None, None, None))
|
experiment = SinaraTester((device_mgr, None, None, None))
|
||||||
experiment.prepare()
|
experiment.prepare()
|
||||||
experiment.run(tests)
|
experiment.run(tests)
|
||||||
|
device_mgr.notify_run_end()
|
||||||
experiment.analyze()
|
experiment.analyze()
|
||||||
finally:
|
finally:
|
||||||
device_mgr.close_devices()
|
device_mgr.close_devices()
|
||||||
|
|
|
@ -92,6 +92,13 @@ class DeviceManager:
|
||||||
self.active_devices.append((desc, dev))
|
self.active_devices.append((desc, dev))
|
||||||
return dev
|
return dev
|
||||||
|
|
||||||
|
def notify_run_end(self):
|
||||||
|
"""Sends a "end of Experiment run stage" notification to
|
||||||
|
all active devices."""
|
||||||
|
for _desc, dev in self.active_devices:
|
||||||
|
if hasattr(dev, "notify_run_end"):
|
||||||
|
dev.notify_run_end()
|
||||||
|
|
||||||
def close_devices(self):
|
def close_devices(self):
|
||||||
"""Closes all active devices, in the opposite order as they were
|
"""Closes all active devices, in the opposite order as they were
|
||||||
requested."""
|
requested."""
|
||||||
|
|
|
@ -343,6 +343,8 @@ def main():
|
||||||
# for end of analyze stage.
|
# for end of analyze stage.
|
||||||
write_results()
|
write_results()
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
|
device_mgr.notify_run_end()
|
||||||
put_completed()
|
put_completed()
|
||||||
elif action == "analyze":
|
elif action == "analyze":
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -55,6 +55,7 @@ class ExperimentCase(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
exp = self.create(cls, *args, **kwargs)
|
exp = self.create(cls, *args, **kwargs)
|
||||||
exp.run()
|
exp.run()
|
||||||
|
self.device_mgr.notify_run_end()
|
||||||
exp.analyze()
|
exp.analyze()
|
||||||
return exp
|
return exp
|
||||||
except CompileError as error:
|
except CompileError as error:
|
||||||
|
|
Loading…
Reference in New Issue