From ea6dcb2743240c0fa8fd455e9c03b8983f013fb1 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 6 Dec 2015 18:39:27 +0800 Subject: [PATCH] master: repository -> experiment_db --- artiq/frontend/artiq_client.py | 4 +-- artiq/frontend/artiq_gui.py | 6 ++-- artiq/frontend/artiq_master.py | 14 +++++----- artiq/gui/experiments.py | 6 ++-- artiq/gui/explorer.py | 4 +-- .../master/{repository.py => experiments.py} | 28 +++++++++---------- 6 files changed, 31 insertions(+), 31 deletions(-) rename artiq/master/{repository.py => experiments.py} (86%) diff --git a/artiq/frontend/artiq_client.py b/artiq/frontend/artiq_client.py index 2324bcdee..dae3ea343 100755 --- a/artiq/frontend/artiq_client.py +++ b/artiq/frontend/artiq_client.py @@ -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: diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index 46658d60b..474629587 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -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) diff --git a/artiq/frontend/artiq_master.py b/artiq/frontend/artiq_master.py index 77ec35a38..2f138a27e 100755 --- a/artiq/frontend/artiq_master.py +++ b/artiq/frontend/artiq_master.py @@ -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, - log_worker) - atexit.register(repository.close) - repository.scan_async() + experiment_db = ExperimentDB(repo_backend, device_db.get_device_db, + log_worker) + 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( diff --git a/artiq/gui/experiments.py b/artiq/gui/experiments.py index 8e718d6f9..af9e7c7eb 100644 --- a/artiq/gui/experiments.py +++ b/artiq/gui/experiments.py @@ -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): diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index f6ef8050e..d592a14d4 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -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) diff --git a/artiq/master/repository.py b/artiq/master/experiments.py similarity index 86% rename from artiq/master/repository.py rename to artiq/master/experiments.py index 10dfaf6d6..0dc96d7ab 100644 --- a/artiq/master/repository.py +++ b/artiq/master/experiments.py @@ -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