2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

master: implement devarg_override

This commit is contained in:
Sebastien Bourdeauducq 2023-12-18 12:11:40 +08:00
parent 5df0721811
commit 8dd8cfa6b0
2 changed files with 7 additions and 3 deletions

View File

@ -19,12 +19,13 @@ class DummyDevice:
pass
def _create_device(desc, device_mgr):
def _create_device(desc, device_mgr, argument_overrides):
ty = desc["type"]
if ty == "local":
module = importlib.import_module(desc["module"])
device_class = getattr(module, desc["class"])
return device_class(device_mgr, **desc.get("arguments", {}))
arguments = desc.get("arguments", {}) | argument_overrides
return device_class(device_mgr, **arguments)
elif ty == "controller":
if desc.get("best_effort", False):
cls = BestEffortClient
@ -60,6 +61,7 @@ class DeviceManager:
self.ddb = ddb
self.virtual_devices = virtual_devices
self.active_devices = []
self.devarg_override = {}
def get_device_db(self):
"""Returns the full contents of the device database."""
@ -85,7 +87,7 @@ class DeviceManager:
return existing_dev
try:
dev = _create_device(desc, self)
dev = _create_device(desc, self, self.devarg_override.get(name, {}))
except Exception as e:
raise DeviceError("Failed to create device '{}'"
.format(name)) from e

View File

@ -306,6 +306,8 @@ def main():
start_time = time.time()
rid = obj["rid"]
expid = obj["expid"]
if "devarg_override" in expid:
device_mgr.devarg_override = expid["devarg_override"]
if "file" in expid:
if obj["wd"] is not None:
# Using repository