forked from M-Labs/artiq
1
0
Fork 0

browser: basic analyze()

This commit is contained in:
Robert Jördens 2016-05-12 18:44:03 +02:00
parent 1480bb5630
commit 07b80cc5ab
1 changed files with 25 additions and 8 deletions

View File

@ -176,6 +176,8 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
self.layout.setRowStretch(0, 1) self.layout.setRowStretch(0, 1)
self.options = {"log_level": logging.WARNING} self.options = {"log_level": logging.WARNING}
self._worker = None
self._run_task = None
log_level = QtWidgets.QComboBox() log_level = QtWidgets.QComboBox()
log_level.addItems(log_levels) log_level.addItems(log_levels)
@ -263,6 +265,9 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
await self._recompute_arguments(arguments) await self._recompute_arguments(arguments)
def run_clicked(self): def run_clicked(self):
if self._run_task is not None:
logger.error("Analysis already started")
return
class_name, file = self.expurl.split("@", maxsplit=1) class_name, file = self.expurl.split("@", maxsplit=1)
expid = { expid = {
"repo_rev": "N/A", "repo_rev": "N/A",
@ -274,23 +279,35 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
argument["state"]) argument["state"])
for name, argument in self.arguments.items()}, for name, argument in self.arguments.items()},
} }
asyncio.ensure_future(self._run_task(expid)) # TODO self._run_task = asyncio.ensure_future(self._get_run_task(expid))
async def _run_task(self, expid): def done(fut):
worker = Worker(self._area.worker_handlers) logger.info("Analysis done")
self._run_task = None
self._run_task.add_done_callback(done)
async def _get_run_task(self, expid):
self._worker = Worker(self._area.worker_handlers)
try: try:
await worker.build(rid=None, pipeline_name="main", wd=".", await self._worker.build(rid=None, pipeline_name="browser",
expid=expid, priority=0) wd=os.path.abspath("."),
await worker.analyze() expid=expid, priority=0)
await self._worker.analyze()
except: except:
# May happen when experiment has been removed # May happen when experiment has been removed
# from repository/explist # from repository/explist
logger.error("Failed to run '%s'", logger.error("Failed to run '%s'",
self.expurl, exc_info=True) self.expurl, exc_info=True)
finally:
await self._worker.close()
self._worker = None
def terminate_clicked(self): def terminate_clicked(self):
if self._run_task is None:
return
try: try:
pass # TODO self._run_task.cancel()
except: except:
# May happen when experiment has been removed # May happen when experiment has been removed
# from repository/explist # from repository/explist
@ -319,7 +336,7 @@ class LocalDatasetDB:
self._data = data self._data = data
def get(self, key): def get(self, key):
return self._data[key][1] return self._data.backing_store[key][1]
def update(self, mod): def update(self, mod):
process_mod(self._data, mod) process_mod(self._data, mod)