From 98caaebaded20ebc02e9200a9e31ea8f47a8b84a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 9 Sep 2019 15:16:33 +0800 Subject: [PATCH] consistent use of 'class name' terminology to select a class within an experiment file. Closes #1348 --- RELEASE_NOTES.rst | 2 ++ artiq/frontend/artiq_compile.py | 6 +++--- artiq/frontend/artiq_run.py | 12 ++++++------ artiq/test/coredevice/test_compile.py | 2 +- artiq/tools.py | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index 647930883..82fd78832 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -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 diff --git a/artiq/frontend/artiq_compile.py b/artiq/frontend/artiq_compile.py index c49f60b6e..cf7335474 100755 --- a/artiq/frontend/artiq_compile.py +++ b/artiq/frontend/artiq_compile.py @@ -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, {})) diff --git a/artiq/frontend/artiq_run.py b/artiq/frontend/artiq_run.py index 263b3cf08..76954e56c 100755 --- a/artiq/frontend/artiq_run.py +++ b/artiq/frontend/artiq_run.py @@ -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): diff --git a/artiq/test/coredevice/test_compile.py b/artiq/test/coredevice/test_compile.py index 0efb5eb8b..060cd1b8f 100644 --- a/artiq/test/coredevice/test_compile.py +++ b/artiq/test/coredevice/test_compile.py @@ -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() diff --git a/artiq/tools.py b/artiq/tools.py index 30941e7a6..192658661 100644 --- a/artiq/tools.py +++ b/artiq/tools.py @@ -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)]