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

View File

@ -66,7 +66,7 @@ def main():
# create connections to master
rpc_clients = dict()
for target in "schedule", "repository", "dataset_db":
for target in "schedule", "experiment_db", "dataset_db":
client = AsyncioClient()
loop.run_until_complete(client.connect_rpc(
args.server, args.port_control, "master_" + target))
@ -99,14 +99,14 @@ def main():
sub_clients["explist"],
sub_clients["schedule"],
rpc_clients["schedule"],
rpc_clients["repository"])
rpc_clients["experiment_db"])
smgr.register(expmgr)
d_shortcuts = shortcuts.ShortcutsDock(win, expmgr)
smgr.register(d_shortcuts)
d_explorer = explorer.ExplorerDock(status_bar, expmgr, d_shortcuts,
sub_clients["explist"],
rpc_clients["schedule"],
rpc_clients["repository"])
rpc_clients["experiment_db"])
d_datasets = datasets.DatasetsDock(win, dock_area, sub_clients["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.scheduler import Scheduler
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():
@ -71,10 +71,10 @@ def main():
repo_backend = GitBackend(args.repository)
else:
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)
atexit.register(repository.close)
repository.scan_async()
atexit.register(experiment_db.close)
experiment_db.scan_repository_async()
worker_handlers = {
"get_device_db": device_db.get_device_db,
@ -97,7 +97,7 @@ def main():
"master_device_db": device_db,
"master_dataset_db": dataset_db,
"master_schedule": scheduler,
"master_repository": repository
"master_experiment_db": experiment_db
})
loop.run_until_complete(server_control.start(
args.bind, args.port_control))
@ -107,7 +107,7 @@ def main():
"schedule": scheduler.notifier,
"devices": device_db.data,
"datasets": dataset_db.data,
"explist": repository.explist,
"explist": experiment_db.explist,
"log": log_buffer.data
})
loop.run_until_complete(server_notify.start(

View File

@ -366,11 +366,11 @@ class _ExperimentDock(dockarea.Dock):
class ExperimentManager:
def __init__(self, status_bar, dock_area,
explist_sub, schedule_sub,
schedule_ctl, repository_ctl):
schedule_ctl, experiment_db_ctl):
self.status_bar = status_bar
self.dock_area = dock_area
self.schedule_ctl = schedule_ctl
self.repository_ctl = repository_ctl
self.experiment_db_ctl = experiment_db_ctl
self.submission_scheduling = dict()
self.submission_options = dict()
@ -497,7 +497,7 @@ class ExperimentManager:
async def recompute_arginfo(self, 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"]
def save_state(self):

View File

@ -23,7 +23,7 @@ class Model(DictSyncTreeSepModel):
class ExplorerDock(dockarea.Dock):
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))
self.layout.setSpacing(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",
self.el)
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")
scan_repository_action.triggered.connect(scan_repository)
self.el.addAction(scan_repository_action)

View File

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