Skip to content

Commit

Permalink
Add directory of device db to the module search paths when devices ar…
Browse files Browse the repository at this point in the history
…e resolved

Signed-off-by: Egor Savkin <[email protected]>
  • Loading branch information
thomasfire committed Dec 17, 2024
1 parent 366bb0f commit b3898bb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion artiq/master/databases.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import pathlib

import lmdb

Expand All @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion artiq/master/worker_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion artiq/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b3898bb

Please sign in to comment.