diff --git a/artiq/master/databases.py b/artiq/master/databases.py index d889933d7..5cb866dd7 100644 --- a/artiq/master/databases.py +++ b/artiq/master/databases.py @@ -1,4 +1,5 @@ import asyncio +import pathlib import lmdb @@ -21,7 +22,7 @@ def device_db_from_file(filename): class DeviceDB: def __init__(self, backing_file): - self.backing_file = backing_file + self.backing_file = pathlib.Path(backing_file).resolve() self.data = Notifier(device_db_from_file(self.backing_file)) def scan(self): diff --git a/artiq/master/worker_db.py b/artiq/master/worker_db.py index af316e4cf..375a78ab9 100644 --- a/artiq/master/worker_db.py +++ b/artiq/master/worker_db.py @@ -3,7 +3,7 @@ These artefacts are intended for out-of-process use (i.e. from workers or the standalone command line tools). """ - +import sys from operator import setitem import importlib import logging @@ -22,9 +22,12 @@ class DummyDevice: def _create_device(desc, device_mgr, argument_overrides): ty = desc["type"] if ty == "local": + path = str(device_mgr.ddb.backing_file.parent) + sys.path.insert(0, path) module = importlib.import_module(desc["module"]) device_class = getattr(module, desc["class"]) arguments = desc.get("arguments", {}) | argument_overrides + sys.path.pop(0) return device_class(device_mgr, **arguments) elif ty == "controller": if desc.get("best_effort", False): diff --git a/artiq/tools.py b/artiq/tools.py index e11afe2bb..a983cdae1 100644 --- a/artiq/tools.py +++ b/artiq/tools.py @@ -122,7 +122,7 @@ def short_format(v, metadata={}): def file_import(filename, prefix="file_import_"): - filename = pathlib.Path(filename) + filename = pathlib.Path(filename) if not isinstance(filename, pathlib.Path) else filename modname = prefix + filename.stem path = str(filename.resolve().parent)