2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-24 19:04:02 +08:00

master: add an argument to set an experiment subdirectory

Signed-off-by: Mingyu Fan <mingyufan@ucsb.edu>
This commit is contained in:
fanmingyu212 2021-10-13 22:17:52 -07:00 committed by Sébastien Bourdeauducq
parent 35d21c98d3
commit 178a86bcda
3 changed files with 14 additions and 5 deletions

View File

@ -24,6 +24,8 @@ Highlights:
- HVAMP_8CH 8 channel HV amplifier for Fastino / Zotino - HVAMP_8CH 8 channel HV amplifier for Fastino / Zotino
* ``artiq_ddb_template`` generates edge-counter keys that start with the key of the corresponding * ``artiq_ddb_template`` generates edge-counter keys that start with the key of the corresponding
TTL device (e.g. ``"ttl_0_counter"`` for the edge counter on TTL device``"ttl_0"``) TTL device (e.g. ``"ttl_0_counter"`` for the edge counter on TTL device``"ttl_0"``)
* ``artiq_master`` now has an ``--experiment-subdir`` option to scan only a subdirectory of the
repository when building the list of experiments.
Breaking changes: Breaking changes:

View File

@ -50,6 +50,10 @@ def get_argparser():
group.add_argument( group.add_argument(
"-r", "--repository", default="repository", "-r", "--repository", default="repository",
help="path to the repository (default: '%(default)s')") help="path to the repository (default: '%(default)s')")
group.add_argument(
"--experiment-subdir", default="",
help=("path to the experiment folder from the repository root "
"(default: '%(default)s')"))
log_args(parser) log_args(parser)
@ -104,7 +108,8 @@ def main():
repo_backend = GitBackend(args.repository) repo_backend = GitBackend(args.repository)
else: else:
repo_backend = FilesystemBackend(args.repository) repo_backend = FilesystemBackend(args.repository)
experiment_db = ExperimentDB(repo_backend, worker_handlers) experiment_db = ExperimentDB(
repo_backend, worker_handlers, args.experiment_subdir)
atexit.register(experiment_db.close) atexit.register(experiment_db.close)
scheduler = Scheduler(RIDCounter(), worker_handlers, experiment_db) scheduler = Scheduler(RIDCounter(), worker_handlers, experiment_db)

View File

@ -74,19 +74,20 @@ class _RepoScanner:
entry_dict.update(entries) entry_dict.update(entries)
return entry_dict return entry_dict
async def scan(self, root): async def scan(self, root, subdir=""):
self.worker = Worker(self.worker_handlers) self.worker = Worker(self.worker_handlers)
try: try:
r = await self._scan(root) r = await self._scan(root, subdir)
finally: finally:
await self.worker.close() await self.worker.close()
return r return r
class ExperimentDB: class ExperimentDB:
def __init__(self, repo_backend, worker_handlers): def __init__(self, repo_backend, worker_handlers, experiment_subdir=""):
self.repo_backend = repo_backend self.repo_backend = repo_backend
self.worker_handlers = worker_handlers self.worker_handlers = worker_handlers
self.experiment_subdir = experiment_subdir
self.cur_rev = self.repo_backend.get_head_rev() self.cur_rev = self.repo_backend.get_head_rev()
self.repo_backend.request_rev(self.cur_rev) self.repo_backend.request_rev(self.cur_rev)
@ -115,7 +116,8 @@ class ExperimentDB:
self.cur_rev = new_cur_rev self.cur_rev = new_cur_rev
self.status["cur_rev"] = new_cur_rev self.status["cur_rev"] = new_cur_rev
t1 = time.monotonic() t1 = time.monotonic()
new_explist = await _RepoScanner(self.worker_handlers).scan(wd) new_explist = await _RepoScanner(self.worker_handlers).scan(
wd, self.experiment_subdir)
logger.info("repository scan took %d seconds", time.monotonic()-t1) logger.info("repository scan took %d seconds", time.monotonic()-t1)
update_from_dict(self.explist, new_explist) update_from_dict(self.explist, new_explist)
finally: finally: