forked from M-Labs/artiq
master: implement devarg_override
This commit is contained in:
parent
5df0721811
commit
8dd8cfa6b0
|
@ -19,12 +19,13 @@ class DummyDevice:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _create_device(desc, device_mgr):
|
def _create_device(desc, device_mgr, argument_overrides):
|
||||||
ty = desc["type"]
|
ty = desc["type"]
|
||||||
if ty == "local":
|
if ty == "local":
|
||||||
module = importlib.import_module(desc["module"])
|
module = importlib.import_module(desc["module"])
|
||||||
device_class = getattr(module, desc["class"])
|
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":
|
elif ty == "controller":
|
||||||
if desc.get("best_effort", False):
|
if desc.get("best_effort", False):
|
||||||
cls = BestEffortClient
|
cls = BestEffortClient
|
||||||
|
@ -60,6 +61,7 @@ class DeviceManager:
|
||||||
self.ddb = ddb
|
self.ddb = ddb
|
||||||
self.virtual_devices = virtual_devices
|
self.virtual_devices = virtual_devices
|
||||||
self.active_devices = []
|
self.active_devices = []
|
||||||
|
self.devarg_override = {}
|
||||||
|
|
||||||
def get_device_db(self):
|
def get_device_db(self):
|
||||||
"""Returns the full contents of the device database."""
|
"""Returns the full contents of the device database."""
|
||||||
|
@ -85,7 +87,7 @@ class DeviceManager:
|
||||||
return existing_dev
|
return existing_dev
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dev = _create_device(desc, self)
|
dev = _create_device(desc, self, self.devarg_override.get(name, {}))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise DeviceError("Failed to create device '{}'"
|
raise DeviceError("Failed to create device '{}'"
|
||||||
.format(name)) from e
|
.format(name)) from e
|
||||||
|
|
|
@ -306,6 +306,8 @@ def main():
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
rid = obj["rid"]
|
rid = obj["rid"]
|
||||||
expid = obj["expid"]
|
expid = obj["expid"]
|
||||||
|
if "devarg_override" in expid:
|
||||||
|
device_mgr.devarg_override = expid["devarg_override"]
|
||||||
if "file" in expid:
|
if "file" in expid:
|
||||||
if obj["wd"] is not None:
|
if obj["wd"] is not None:
|
||||||
# Using repository
|
# Using repository
|
||||||
|
|
Loading…
Reference in New Issue