Ejemplo n.º 1
0
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__.strip().splitlines()[0].strip()
                    if name[-1] == ".":
                        name = name[:-1]
                argument_mgr = TraceArgumentManager()
                scheduler_defaults = {}
                cls = exp_class((device_mgr, dataset_mgr, argument_mgr,
                                 scheduler_defaults))
                arginfo = OrderedDict(
                    (k, (proc.describe(), group, tooltip))
                    for k, (proc, group,
                            tooltip) in argument_mgr.requested_args.items())
                register_experiment(class_name, name, arginfo,
                                    scheduler_defaults)
    finally:
        new_keys = set(sys.modules.keys())
        for key in new_keys - previous_keys:
            del sys.modules[key]
Ejemplo n.º 2
0
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()
                scheduler_defaults = {}
                cls = exp_class((device_mgr, dataset_mgr, argument_mgr, scheduler_defaults))
                arginfo = OrderedDict(
                    (k, (proc.describe(), group, tooltip))
                    for k, (proc, group, tooltip) in argument_mgr.requested_args.items())
                register_experiment(class_name, name, arginfo, scheduler_defaults)
    finally:
        new_keys = set(sys.modules.keys())
        for key in new_keys - previous_keys:
            del sys.modules[key]
Ejemplo n.º 3
0
def get_exp(file, class_name):
    module = file_import(file)
    if class_name is None:
        exps = [v for k, v in module.__dict__.items() if is_experiment(v)]
        if len(exps) != 1:
            raise ValueError("Found {} experiments in module".format(
                len(exps)))
        return exps[0]
    else:
        return getattr(module, class_name)
Ejemplo n.º 4
0
def get_experiment(module, experiment=None):
    if experiment:
        return getattr(module, experiment)

    exps = [(k, v) for k, v in module.__dict__.items()
            if k[0] != "_" and is_experiment(v)]
    if not exps:
        raise ValueError("No experiments in module")
    if len(exps) > 1:
        raise ValueError("More than one experiment found in module")
    return exps[0][1]
Ejemplo n.º 5
0
def get_experiment(module, class_name=None):
    if class_name:
        return getattr(module, class_name)

    exps = [(k, v) for k, v in module.__dict__.items()
            if k[0] != "_" and is_experiment(v)]
    if not exps:
        raise ValueError("No experiments in module")
    if len(exps) > 1:
        raise ValueError("More than one experiment found in module")
    return exps[0][1]
Ejemplo n.º 6
0
def get_exp(file, class_name):
    module = file_import(file, prefix="artiq_worker_")
    if class_name is None:
        exps = [v for k, v in module.__dict__.items()
                if is_experiment(v)]
        if len(exps) != 1:
            raise ValueError("Found {} experiments in module"
                             .format(len(exps)))
        return exps[0]
    else:
        return getattr(module, class_name)
Ejemplo n.º 7
0
def get_experiment(module, experiment=None):
    if experiment:
        return getattr(module, experiment)

    exps = [(k, v) for k, v in module.__dict__.items()
            if is_experiment(v)]
    if not exps:
        raise ValueError("No experiments in module")
    if len(exps) > 1:
        raise ValueError("More than one experiment found in module")
    return exps[0][1]
Ejemplo n.º 8
0
def examine(device_mgr, dataset_mgr, file):
    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]
            exp_inst = exp_class(device_mgr, dataset_mgr, default_arg_none=True)
            arguments = [(k, (proc.describe(), group))
                         for k, (proc, group) in exp_inst.requested_args.items()]
            register_experiment(class_name, name, arguments)
Ejemplo n.º 9
0
def examine(dmgr, pdb, rdb, file):
    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]
            exp_inst = exp_class(dmgr, pdb, rdb, default_arg_none=True)
            arguments = [(k, (proc.describe(), group))
                         for k, (proc,
                                 group) in exp_inst.requested_args.items()]
            register_experiment(class_name, name, arguments)
Ejemplo n.º 10
0
def examine(device_mgr, dataset_mgr, file):
    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)
Ejemplo n.º 11
0
def examine(device_mgr, dataset_mgr, file):
    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_inst = exp_class((device_mgr, dataset_mgr, argument_mgr))
            arginfo = OrderedDict(
                (k, (proc.describe(), group))
                for k, (proc, group) in argument_mgr.requested_args.items())
            register_experiment(class_name, name, arginfo)