forked from M-Labs/artiq
1
0
Fork 0

master: repository -> experiment_db

This commit is contained in:
Sebastien Bourdeauducq 2015-12-06 18:39:27 +08:00
parent 8467013160
commit ea6dcb2743
6 changed files with 31 additions and 31 deletions

View File

@ -151,7 +151,7 @@ def _action_scan_devices(remote, args):
def _action_scan_repository(remote, args): def _action_scan_repository(remote, args):
remote.scan_async(args.revision) remote.scan_repository_async(args.revision)
def _show_schedule(schedule): def _show_schedule(schedule):
@ -285,7 +285,7 @@ def main():
"set_dataset": "master_dataset_db", "set_dataset": "master_dataset_db",
"del_dataset": "master_dataset_db", "del_dataset": "master_dataset_db",
"scan_devices": "master_device_db", "scan_devices": "master_device_db",
"scan_repository": "master_repository" "scan_repository": "master_experiment_db"
}[action] }[action]
remote = Client(args.server, port, target_name) remote = Client(args.server, port, target_name)
try: try:

View File

@ -66,7 +66,7 @@ def main():
# create connections to master # create connections to master
rpc_clients = dict() rpc_clients = dict()
for target in "schedule", "repository", "dataset_db": for target in "schedule", "experiment_db", "dataset_db":
client = AsyncioClient() client = AsyncioClient()
loop.run_until_complete(client.connect_rpc( loop.run_until_complete(client.connect_rpc(
args.server, args.port_control, "master_" + target)) args.server, args.port_control, "master_" + target))
@ -99,14 +99,14 @@ def main():
sub_clients["explist"], sub_clients["explist"],
sub_clients["schedule"], sub_clients["schedule"],
rpc_clients["schedule"], rpc_clients["schedule"],
rpc_clients["repository"]) rpc_clients["experiment_db"])
smgr.register(expmgr) smgr.register(expmgr)
d_shortcuts = shortcuts.ShortcutsDock(win, expmgr) d_shortcuts = shortcuts.ShortcutsDock(win, expmgr)
smgr.register(d_shortcuts) smgr.register(d_shortcuts)
d_explorer = explorer.ExplorerDock(status_bar, expmgr, d_shortcuts, d_explorer = explorer.ExplorerDock(status_bar, expmgr, d_shortcuts,
sub_clients["explist"], sub_clients["explist"],
rpc_clients["schedule"], rpc_clients["schedule"],
rpc_clients["repository"]) rpc_clients["experiment_db"])
d_datasets = datasets.DatasetsDock(win, dock_area, sub_clients["datasets"]) d_datasets = datasets.DatasetsDock(win, dock_area, sub_clients["datasets"])
smgr.register(d_datasets) smgr.register(d_datasets)

View File

@ -13,7 +13,7 @@ from artiq.master.log import log_args, init_log, log_worker
from artiq.master.databases import DeviceDB, DatasetDB from artiq.master.databases import DeviceDB, DatasetDB
from artiq.master.scheduler import Scheduler from artiq.master.scheduler import Scheduler
from artiq.master.worker_db import get_last_rid from artiq.master.worker_db import get_last_rid
from artiq.master.repository import FilesystemBackend, GitBackend, Repository from artiq.master.experiments import FilesystemBackend, GitBackend, ExperimentDB
def get_argparser(): def get_argparser():
@ -71,10 +71,10 @@ 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_device_db, experiment_db = ExperimentDB(repo_backend, device_db.get_device_db,
log_worker) log_worker)
atexit.register(repository.close) atexit.register(experiment_db.close)
repository.scan_async() experiment_db.scan_repository_async()
worker_handlers = { worker_handlers = {
"get_device_db": device_db.get_device_db, "get_device_db": device_db.get_device_db,
@ -97,7 +97,7 @@ def main():
"master_device_db": device_db, "master_device_db": device_db,
"master_dataset_db": dataset_db, "master_dataset_db": dataset_db,
"master_schedule": scheduler, "master_schedule": scheduler,
"master_repository": repository "master_experiment_db": experiment_db
}) })
loop.run_until_complete(server_control.start( loop.run_until_complete(server_control.start(
args.bind, args.port_control)) args.bind, args.port_control))
@ -107,7 +107,7 @@ def main():
"schedule": scheduler.notifier, "schedule": scheduler.notifier,
"devices": device_db.data, "devices": device_db.data,
"datasets": dataset_db.data, "datasets": dataset_db.data,
"explist": repository.explist, "explist": experiment_db.explist,
"log": log_buffer.data "log": log_buffer.data
}) })
loop.run_until_complete(server_notify.start( loop.run_until_complete(server_notify.start(

View File

@ -366,11 +366,11 @@ class _ExperimentDock(dockarea.Dock):
class ExperimentManager: class ExperimentManager:
def __init__(self, status_bar, dock_area, def __init__(self, status_bar, dock_area,
explist_sub, schedule_sub, explist_sub, schedule_sub,
schedule_ctl, repository_ctl): schedule_ctl, experiment_db_ctl):
self.status_bar = status_bar self.status_bar = status_bar
self.dock_area = dock_area self.dock_area = dock_area
self.schedule_ctl = schedule_ctl self.schedule_ctl = schedule_ctl
self.repository_ctl = repository_ctl self.experiment_db_ctl = experiment_db_ctl
self.submission_scheduling = dict() self.submission_scheduling = dict()
self.submission_options = dict() self.submission_options = dict()
@ -497,7 +497,7 @@ class ExperimentManager:
async def recompute_arginfo(self, expname): async def recompute_arginfo(self, expname):
expinfo = self.explist[expname] expinfo = self.explist[expname]
description = await self.repository_ctl.examine(expinfo["file"]) description = await self.experiment_db_ctl.examine(expinfo["file"])
return description[expinfo["class_name"]]["arginfo"] return description[expinfo["class_name"]]["arginfo"]
def save_state(self): def save_state(self):

View File

@ -23,7 +23,7 @@ class Model(DictSyncTreeSepModel):
class ExplorerDock(dockarea.Dock): class ExplorerDock(dockarea.Dock):
def __init__(self, status_bar, exp_manager, d_shortcuts, def __init__(self, status_bar, exp_manager, d_shortcuts,
explist_sub, schedule_ctl, repository_ctl): explist_sub, schedule_ctl, experiment_db_ctl):
dockarea.Dock.__init__(self, "Explorer", size=(1500, 500)) dockarea.Dock.__init__(self, "Explorer", size=(1500, 500))
self.layout.setSpacing(5) self.layout.setSpacing(5)
self.layout.setContentsMargins(5, 5, 5, 5) self.layout.setContentsMargins(5, 5, 5, 5)
@ -86,7 +86,7 @@ class ExplorerDock(dockarea.Dock):
scan_repository_action = QtGui.QAction("(Re)scan repository HEAD", scan_repository_action = QtGui.QAction("(Re)scan repository HEAD",
self.el) self.el)
def scan_repository(): def scan_repository():
asyncio.ensure_future(repository_ctl.scan_async()) asyncio.ensure_future(experiment_db_ctl.scan_repository_async())
self.status_bar.showMessage("Requested repository scan") self.status_bar.showMessage("Requested repository scan")
scan_repository_action.triggered.connect(scan_repository) scan_repository_action.triggered.connect(scan_repository)
self.el.addAction(scan_repository_action) self.el.addAction(scan_repository_action)

View File

@ -75,31 +75,31 @@ def _sync_explist(target, source):
target[k] = source[k] target[k] = source[k]
class Repository: class ExperimentDB:
def __init__(self, backend, get_device_db_fn, log_fn): def __init__(self, repo_backend, get_device_db_fn, log_fn):
self.backend = backend self.repo_backend = repo_backend
self.get_device_db_fn = get_device_db_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.repo_backend.get_head_rev()
self.backend.request_rev(self.cur_rev) self.repo_backend.request_rev(self.cur_rev)
self.explist = Notifier(dict()) self.explist = Notifier(dict())
self._scanning = False self._scanning = False
def close(self): def close(self):
# The object cannot be used anymore after calling this method. # The object cannot be used anymore after calling this method.
self.backend.release_rev(self.cur_rev) self.repo_backend.release_rev(self.cur_rev)
async def scan(self, new_cur_rev=None): async def scan_repository(self, new_cur_rev=None):
if self._scanning: if self._scanning:
return return
self._scanning = True self._scanning = True
try: try:
if new_cur_rev is None: if new_cur_rev is None:
new_cur_rev = self.backend.get_head_rev() new_cur_rev = self.repo_backend.get_head_rev()
wd, _ = self.backend.request_rev(new_cur_rev) wd, _ = self.repo_backend.request_rev(new_cur_rev)
self.backend.release_rev(self.cur_rev) self.repo_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_device_db_fn, new_explist = await _scan_experiments(wd, self.get_device_db_fn,
self.log_fn) self.log_fn)
@ -108,13 +108,13 @@ class Repository:
finally: finally:
self._scanning = False self._scanning = False
def scan_async(self, new_cur_rev=None): def scan_repository_async(self, new_cur_rev=None):
asyncio.ensure_future(exc_to_warning(self.scan(new_cur_rev))) asyncio.ensure_future(exc_to_warning(self.scan_repository(new_cur_rev)))
async def examine(self, filename, use_repository=True): async def examine(self, filename, use_repository=True):
if use_repository: if use_repository:
revision = self.cur_rev revision = self.cur_rev
wd, _ = self.backend.request_rev(revision) wd, _ = self.repo_backend.request_rev(revision)
filename = os.path.join(wd, filename) filename = os.path.join(wd, filename)
worker = Worker({ worker = Worker({
"get_device_db": self.get_device_db_fn, "get_device_db": self.get_device_db_fn,
@ -125,7 +125,7 @@ class Repository:
finally: finally:
await worker.close() await worker.close()
if use_repository: if use_repository:
self.backend.release_rev(revision) self.repo_backend.release_rev(revision)
return description return description