forked from M-Labs/artiq
1
0
Fork 0

consistent use of 'class name' terminology to select a class within an experiment file. Closes #1348

This commit is contained in:
Sebastien Bourdeauducq 2019-09-09 15:16:33 +08:00
parent 21021beb08
commit 98caaebade
5 changed files with 15 additions and 13 deletions

View File

@ -31,6 +31,8 @@ ARTIQ-5
programs.
* On Kasli the firmware now starts with a unique default MAC address
from EEPROM if `mac` is absent from the flash config.
* The ``-e/--experiment`` switch of ``artiq_run`` and ``artiq_compile``
has been renamed ``-c/--class-name``.
ARTIQ-4

View File

@ -21,8 +21,8 @@ def get_argparser():
parser.add_argument("--dataset-db", default="dataset_db.pyon",
help="dataset file (default: '%(default)s')")
parser.add_argument("-e", "--experiment", default=None,
help="experiment to compile")
parser.add_argument("-c", "--class-name", default=None,
help="name of the class to compile")
parser.add_argument("-o", "--output", default=None,
help="output file")
@ -43,7 +43,7 @@ def main():
try:
module = file_import(args.file, prefix="artiq_run_")
exp = get_experiment(module, args.experiment)
exp = get_experiment(module, args.class_name)
arguments = parse_arguments(args.arguments)
argument_mgr = ProcessArgumentManager(arguments)
exp_inst = exp((device_mgr, dataset_mgr, argument_mgr, {}))

View File

@ -132,8 +132,8 @@ def get_argparser(with_file=True):
parser.add_argument("--dataset-db", default="dataset_db.pyon",
help="dataset file (default: '%(default)s')")
parser.add_argument("-e", "--experiment", default=None,
help="experiment to run")
parser.add_argument("-c", "--class-name", default=None,
help="name of the class to run")
parser.add_argument("-o", "--hdf5", default=None,
help="write results to specified HDF5 file"
" (default: print them)")
@ -157,8 +157,8 @@ def _build_experiment(device_mgr, dataset_mgr, args):
if is_elf or is_ll or is_bc:
if args.arguments:
raise ValueError("arguments not supported for precompiled kernels")
if args.experiment:
raise ValueError("experiment-by-name not supported "
if args.class_name:
raise ValueError("class-name not supported "
"for precompiled kernels")
if is_elf:
return ELFRunner(managers, file=args.file)
@ -175,11 +175,11 @@ def _build_experiment(device_mgr, dataset_mgr, args):
file = getattr(module, "__file__")
expid = {
"file": file,
"experiment": args.experiment,
"class_name": args.class_name,
"arguments": arguments
}
device_mgr.virtual_devices["scheduler"].expid = expid
return get_experiment(module, args.experiment)(managers)
return get_experiment(module, args.class_name)(managers)
def run(with_file=False):

View File

@ -28,7 +28,7 @@ class TestCompile(ExperimentCase):
with tempfile.TemporaryDirectory() as tmp:
db_path = os.path.join(artiq_root, "device_db.py")
subprocess.call([sys.executable, "-m", "artiq.frontend.artiq_compile", "--device-db", db_path,
"-e", "CheckLog", "-o", os.path.join(tmp, "check_log.elf"), __file__])
"-c", "CheckLog", "-o", os.path.join(tmp, "check_log.elf"), __file__])
subprocess.call([sys.executable, "-m", "artiq.frontend.artiq_run", "--device-db", db_path,
os.path.join(tmp, "check_log.elf")])
log = mgmt.get_log()

View File

@ -93,9 +93,9 @@ def file_import(filename, prefix="file_import_"):
return module
def get_experiment(module, experiment=None):
if experiment:
return getattr(module, experiment)
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)]