From 0b4d06c7a9d749a333c9b5d1e8ce102ce5da3050 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 2 May 2018 12:50:37 +0800 Subject: [PATCH] worker: keep sys.modules untouched until the end of examine() --- artiq/master/worker_impl.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/artiq/master/worker_impl.py b/artiq/master/worker_impl.py index 836ff6050..a3db42d1a 100644 --- a/artiq/master/worker_impl.py +++ b/artiq/master/worker_impl.py @@ -155,26 +155,26 @@ def examine(device_mgr, dataset_mgr, file): previous_keys = set(sys.modules.keys()) try: module = file_import(file) + for class_name, exp_class in module.__dict__.items(): + if class_name[0] == "_": + continue + if is_experiment(exp_class): + if exp_class.__doc__ is None: + name = class_name + else: + name = exp_class.__doc__.splitlines()[0].strip() + if name[-1] == ".": + name = name[:-1] + argument_mgr = TraceArgumentManager() + exp_class((device_mgr, dataset_mgr, argument_mgr)) + arginfo = OrderedDict( + (k, (proc.describe(), group, tooltip)) + for k, (proc, group, tooltip) in argument_mgr.requested_args.items()) + register_experiment(class_name, name, arginfo) finally: new_keys = set(sys.modules.keys()) for key in new_keys - previous_keys: del sys.modules[key] - for class_name, exp_class in module.__dict__.items(): - if class_name[0] == "_": - continue - if is_experiment(exp_class): - if exp_class.__doc__ is None: - name = class_name - else: - name = exp_class.__doc__.splitlines()[0].strip() - if name[-1] == ".": - name = name[:-1] - argument_mgr = TraceArgumentManager() - exp_class((device_mgr, dataset_mgr, argument_mgr)) - arginfo = OrderedDict( - (k, (proc.describe(), group, tooltip)) - for k, (proc, group, tooltip) in argument_mgr.requested_args.items()) - register_experiment(class_name, name, arginfo) def setup_diagnostics(experiment_file, repository_path):