We are trying to submit ndscan experiments programmatically, and are running into trouble formatting the arguments. We can submit other experiments fine, and the ndscan experiment submits fine from the dashboard.
We have extracted the arguments used via the dashboard from the hdf5 file:
b'{"devarg_override": {}, "log_level": 30, "file": "Marlo/rabi_sim_ndscan.py", "class_name": "ScanRabiFlopSimTest", "arguments": {"ndscan_params": "{\\"instances\\": {\\"\\": [\\"rabi_sim_ndscan.RabiFlopSimTest.rabi_freq\\", \\"rabi_sim_ndscan.RabiFlopSimTest.duration\\", \\"rabi_sim_ndscan.RabiFlopSimTest.detuning\\", \\"rabi_sim_ndscan.RabiFlopSimTest.initial_state\\"], \\"readout\\": [\\"rabi_sim_ndscan.Readout.num_shots\\", \\"rabi_sim_ndscan.Readout.mean_0\\", \\"rabi_sim_ndscan.Readout.mean_1\\", \\"rabi_sim_ndscan.Readout.threshold\\"]}, \\"schemata\\": {\\"rabi_sim_ndscan.RabiFlopSimTest.rabi_freq\\": {\\"fqn\\": \\"rabi_sim_ndscan.RabiFlopSimTest.rabi_freq\\", \\"description\\": \\"Rabi frequency\\", \\"type\\": \\"float\\", \\"default\\": \\"1000000.0\\", \\"spec\\": {\\"is_scannable\\": true, \\"scale\\": 1000000.0, \\"step\\": 100000.0, \\"min\\": 0.0, \\"unit\\": \\"MHz\\"}}, \\"rabi_sim_ndscan.RabiFlopSimTest.duration\\": {\\"fqn\\": \\"rabi_sim_ndscan.RabiFlopSimTest.duration\\", \\"description\\": \\"Pulse duration\\", \\"type\\": \\"float\\", \\"default\\": \\"5e-07\\", \\"spec\\": {\\"is_scannable\\": true, \\"scale\\": 1e-06, \\"step\\": 1e-07, \\"min\\": 0.0, \\"unit\\": \\"us\\"}}, \\"rabi_sim_ndscan.RabiFlopSimTest.detuning\\": {\\"fqn\\": \\"rabi_sim_ndscan.RabiFlopSimTest.detuning\\", \\"description\\": \\"Detuning\\", \\"type\\": \\"float\\", \\"default\\": \\"0.0\\", \\"spec\\": {\\"is_scannable\\": true, \\"scale\\": 1000000.0, \\"step\\": 100000.0, \\"unit\\": \\"MHz\\"}}, \\"rabi_sim_ndscan.RabiFlopSimTest.initial_state\\": {\\"fqn\\": \\"rabi_sim_ndscan.RabiFlopSimTest.initial_state\\", \\"description\\": \\"Initial state\\", \\"type\\": \\"enum\\", \\"default\\": \\"\'bright\'\\", \\"spec\\": {\\"members\\": {\\"dark\\": \\"Dark\\", \\"bright\\": \\"Bright\\"}, \\"is_scannable\\": true}}, \\"rabi_sim_ndscan.Readout.num_shots\\": {\\"fqn\\": \\"rabi_sim_ndscan.Readout.num_shots\\", \\"description\\": \\"Number of shots\\", \\"type\\": \\"int\\", \\"default\\": \\"100\\", \\"spec\\": {\\"is_scannable\\": false, \\"scale\\": 1, \\"min\\": 0}}, \\"rabi_sim_ndscan.Readout.mean_0\\": {\\"fqn\\": \\"rabi_sim_ndscan.Readout.mean_0\\", \\"description\\": \\"Dark counts over readout duration\\", \\"type\\": \\"float\\", \\"default\\": \\"0.1\\", \\"spec\\": {\\"is_scannable\\": true, \\"scale\\": 1, \\"step\\": 0.1}}, \\"rabi_sim_ndscan.Readout.mean_1\\": {\\"fqn\\": \\"rabi_sim_ndscan.Readout.mean_1\\", \\"description\\": \\"Bright counts over readout duration\\", \\"type\\": \\"float\\", \\"default\\": \\"20.0\\", \\"spec\\": {\\"is_scannable\\": true, \\"scale\\": 1, \\"step\\": 0.1}}, \\"rabi_sim_ndscan.Readout.threshold\\": {\\"fqn\\": \\"rabi_sim_ndscan.Readout.threshold\\", \\"description\\": \\"Threshold\\", \\"type\\": \\"int\\", \\"default\\": \\"5\\", \\"spec\\": {\\"is_scannable\\": true, \\"scale\\": 1, \\"min\\": 0}}}, \\"always_shown\\": [(\\"rabi_sim_ndscan.RabiFlopSimTest.rabi_freq\\", \\"\\"), (\\"rabi_sim_ndscan.RabiFlopSimTest.duration\\", \\"\\"), (\\"rabi_sim_ndscan.RabiFlopSimTest.detuning\\", \\"\\"), (\\"rabi_sim_ndscan.RabiFlopSimTest.initial_state\\", \\"\\")], \\"overrides\\": {\\"rabi_sim_ndscan.RabiFlopSimTest.rabi_freq\\": [{\\"path\\": \\"\\", \\"value\\": 1000000.0}], \\"rabi_sim_ndscan.RabiFlopSimTest.duration\\": [{\\"path\\": \\"\\", \\"value\\": 5e-07}], \\"rabi_sim_ndscan.RabiFlopSimTest.detuning\\": [{\\"path\\": \\"\\", \\"value\\": 0.0}], \\"rabi_sim_ndscan.RabiFlopSimTest.initial_state\\": [{\\"path\\": \\"\\", \\"value\\": \\"bright\\"}]}, \\"scan\\": {\\"axes\\": [], \\"num_repeats\\": 1, \\"no_axes_mode\\": \\"single\\", \\"randomise_order_globally\\": false, \\"num_repeats_per_point\\": 1, \\"skip_on_persistent_transitory_error\\": false}}"}, "repo_rev": "N/A"}'
However, when we try to submit something like this or with mostly blank args:
'artiq_client', '--port', '3251', 'submit', '--repository', '--class-name', 'ScanRabiFlopSimTest', 'Marlo/rabi_sim_ndscan.py', 'ndscan_params={"\'instances\'": {}, "\'schemata\'": {}, "\'scan\'": {}}'
we get the following eval errors:
root:Terminating with exception (TypeError: eval() arg 1 must be a string, bytes or code object)
Traceback (most recent call last):
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/artiq/master/worker_impl.py", line 349, in main
exp_inst = exp((device_mgr, dataset_mgr, argument_mgr, {}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/artiq/language/environment.py", line 274, in __init__
self.build(*args, **kwargs)
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/ndscan/experiment/entry_point.py", line 547, in build
super().build(lambda: fragment_class(self, [], *args),
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/ndscan/experiment/entry_point.py", line 96, in build
self.args = ArgumentInterface(self, [self.fragment], scannable=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/artiq/language/environment.py", line 274, in __init__
self.build(*args, **kwargs)
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/ndscan/experiment/entry_point.py", line 179, in build
self._params = self.get_argument(PARAMS_ARG_KEY, PYONValue(default=desc))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/artiq/language/environment.py", line 335, in get_argument
return self.__argument_mgr.get(key, processor, group, tooltip)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/artiq/language/environment.py", line 239, in get
r = processor.process(self.unprocessed_arguments[key])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/artiq/language/environment.py", line 69, in process
return pyon.decode(x)
^^^^^^^^^^^^^^
File "/nix/store/s92h8wmqf1qlkrjmsccsbd6jdynpfb2w-python3-3.12.10-env/lib/python3.12/site-packages/sipyco/pyon.py", line 244, in decode
return eval(s, _eval_dict, {})
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: eval() arg 1 must be a string, bytes or code object
How do we need to adjust the formatting/escaping to prevent these eval errors and have the experiment run successfully?