forked from M-Labs/artiq
get_ddb -> get_device_db
This commit is contained in:
parent
5c4ed7a9bd
commit
3cec176318
|
@ -74,12 +74,12 @@ def main():
|
||||||
repo_backend = GitBackend(args.repository)
|
repo_backend = GitBackend(args.repository)
|
||||||
else:
|
else:
|
||||||
repo_backend = FilesystemBackend(args.repository)
|
repo_backend = FilesystemBackend(args.repository)
|
||||||
repository = Repository(repo_backend, device_db.get_ddb, log.log)
|
repository = Repository(repo_backend, device_db.get_device_db, log.log)
|
||||||
atexit.register(repository.close)
|
atexit.register(repository.close)
|
||||||
repository.scan_async()
|
repository.scan_async()
|
||||||
|
|
||||||
worker_handlers = {
|
worker_handlers = {
|
||||||
"get_ddb": device_db.get_ddb,
|
"get_device_db": device_db.get_device_db,
|
||||||
"get_device": device_db.get,
|
"get_device": device_db.get,
|
||||||
"get_dataset": dataset_db.get,
|
"get_dataset": dataset_db.get,
|
||||||
"update_dataset": dataset_db.update,
|
"update_dataset": dataset_db.update,
|
||||||
|
|
|
@ -186,11 +186,11 @@ class HasEnvironment:
|
||||||
attribute are the same."""
|
attribute are the same."""
|
||||||
setattr(self, key, self.get_argument(key, processor, group))
|
setattr(self, key, self.get_argument(key, processor, group))
|
||||||
|
|
||||||
def get_ddb(self):
|
def get_device_db(self):
|
||||||
"""Returns the full contents of the device database."""
|
"""Returns the full contents of the device database."""
|
||||||
if self.__parent is not None:
|
if self.__parent is not None:
|
||||||
return self.__parent.get_ddb()
|
return self.__parent.get_device_db()
|
||||||
return self.__device_mgr.get_ddb()
|
return self.__device_mgr.get_device_db()
|
||||||
|
|
||||||
def get_device(self, key):
|
def get_device(self, key):
|
||||||
"""Creates and returns a device driver."""
|
"""Creates and returns a device driver."""
|
||||||
|
|
|
@ -20,7 +20,7 @@ class DeviceDB:
|
||||||
if k not in self.data.read or self.data.read[k] != new_data[k]:
|
if k not in self.data.read or self.data.read[k] != new_data[k]:
|
||||||
self.data[k] = new_data[k]
|
self.data[k] = new_data[k]
|
||||||
|
|
||||||
def get_ddb(self):
|
def get_device_db(self):
|
||||||
return self.data.read
|
return self.data.read
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
|
|
|
@ -12,13 +12,13 @@ from artiq.tools import exc_to_warning
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def _scan_experiments(wd, get_ddb, log):
|
async def _scan_experiments(wd, get_device_db, log):
|
||||||
r = dict()
|
r = dict()
|
||||||
for f in os.listdir(wd):
|
for f in os.listdir(wd):
|
||||||
if f.endswith(".py"):
|
if f.endswith(".py"):
|
||||||
try:
|
try:
|
||||||
worker = Worker({
|
worker = Worker({
|
||||||
"get_ddb": get_ddb,
|
"get_device_db": get_device_db,
|
||||||
"log": lambda message: log("scan", message)
|
"log": lambda message: log("scan", message)
|
||||||
})
|
})
|
||||||
try:
|
try:
|
||||||
|
@ -56,9 +56,9 @@ def _sync_explist(target, source):
|
||||||
|
|
||||||
|
|
||||||
class Repository:
|
class Repository:
|
||||||
def __init__(self, backend, get_ddb_fn, log_fn):
|
def __init__(self, backend, get_device_db_fn, log_fn):
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.get_ddb_fn = get_ddb_fn
|
self.get_device_db_fn = get_device_db_fn
|
||||||
self.log_fn = log_fn
|
self.log_fn = log_fn
|
||||||
|
|
||||||
self.cur_rev = self.backend.get_head_rev()
|
self.cur_rev = self.backend.get_head_rev()
|
||||||
|
@ -81,7 +81,8 @@ class Repository:
|
||||||
wd, _ = self.backend.request_rev(new_cur_rev)
|
wd, _ = self.backend.request_rev(new_cur_rev)
|
||||||
self.backend.release_rev(self.cur_rev)
|
self.backend.release_rev(self.cur_rev)
|
||||||
self.cur_rev = new_cur_rev
|
self.cur_rev = new_cur_rev
|
||||||
new_explist = await _scan_experiments(wd, self.get_ddb_fn, self.log_fn)
|
new_explist = await _scan_experiments(wd, self.get_device_db_fn,
|
||||||
|
self.log_fn)
|
||||||
|
|
||||||
_sync_explist(self.explist, new_explist)
|
_sync_explist(self.explist, new_explist)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -39,9 +39,9 @@ class DeviceManager:
|
||||||
self.virtual_devices = virtual_devices
|
self.virtual_devices = virtual_devices
|
||||||
self.active_devices = OrderedDict()
|
self.active_devices = OrderedDict()
|
||||||
|
|
||||||
def get_ddb(self):
|
def get_device_db(self):
|
||||||
"""Returns the full contents of the device database."""
|
"""Returns the full contents of the device database."""
|
||||||
return self.ddb.get_ddb()
|
return self.ddb.get_device_db()
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
"""Get the device driver or controller client corresponding to a
|
"""Get the device driver or controller client corresponding to a
|
||||||
|
|
|
@ -63,7 +63,7 @@ class LogForwarder:
|
||||||
|
|
||||||
|
|
||||||
class ParentDeviceDB:
|
class ParentDeviceDB:
|
||||||
get_ddb = make_parent_action("get_ddb", "")
|
get_device_db = make_parent_action("get_device_db", "")
|
||||||
get = make_parent_action("get_device", "key", KeyError)
|
get = make_parent_action("get_device", "key", KeyError)
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ register_experiment = make_parent_action("register_experiment",
|
||||||
|
|
||||||
|
|
||||||
class ExamineDeviceMgr:
|
class ExamineDeviceMgr:
|
||||||
get_ddb = make_parent_action("get_ddb", "")
|
get_device_db = make_parent_action("get_device_db", "")
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -8,8 +8,8 @@ class DDSSetter(EnvExperiment):
|
||||||
def build(self):
|
def build(self):
|
||||||
self.dds = dict()
|
self.dds = dict()
|
||||||
|
|
||||||
ddb = self.get_ddb()
|
device_db = self.get_device_db()
|
||||||
for k, v in sorted(ddb.items(), key=itemgetter(0)):
|
for k, v in sorted(device_db.items(), key=itemgetter(0)):
|
||||||
if (isinstance(v, dict)
|
if (isinstance(v, dict)
|
||||||
and v["type"] == "local"
|
and v["type"] == "local"
|
||||||
and v["module"] == "artiq.coredevice.dds"
|
and v["module"] == "artiq.coredevice.dds"
|
||||||
|
|
Loading…
Reference in New Issue