Пример #1
0
 def _clear_externally_stopped(self):
     for nb in self.notebooks:
         path = nb.path
         # reset run info if previous run stopped externally
         info = get_run_info(path)
         if info is not None:
             start, elapsed, cur, total, error = info
             if error is None and cur > 0 and elapsed is None:
                 reset_run(path)
Пример #2
0
def test_notebook_error():
    path = os.path.join(get_notebook_dir(), 'test-notebook-error.ipynb')
    assert os.path.isfile(path)
    try:
        update_notebook_by_run(path)
    except ValueError:
        pass
    assert check_notebook_error_and_changed(path) == (True, False)
    touch(path)
    assert check_notebook_error_and_changed(path) == (True, True)

    from wzdat import rundb
    redis_ri = rundb.get_run_info(path)
    rundb.remove_run_info(path)
    manifest_ri = get_run_info(path)
    # both elapsed time is equal
    assert redis_ri[1] == manifest_ri[1]
    # both error msg is equal
    assert redis_ri[-1] == manifest_ri[-1]
Пример #3
0
def poll_rerun(task_info):
    task_id = 0
    # logging.debug(u'poll_rerun {}'.format(task_info))
    from wzdat import rundb
    from wzdat.dashboard.tasks import rerun_notebook
    task_id = task_info.split('/')[-1]
    nbrpath = '/'.join(task_info.split('/')[:-1])
    nbapath = os.path.join(get_notebook_dir(), nbrpath)

    try:
        task = rerun_notebook.AsyncResult(task_id)
        state = task.state
        if state == 'PENDING':
            logging.debug('task pending')
            return 'PROGRESS:0'
        elif task.state == 'PROGRESS':
            ri = rundb.get_run_info(nbapath)
            if ri is not None:
                logging.debug(u"run info exist")
                err = ri[4]
                logging.debug(u'err: {}'.format(err))
                if err == 'None':
                    cur = int(ri[2])
                    total = int(ri[3]) + 1
                    logging.debug(u'cur {} total {}'.format(cur, total))
                    return 'PROGRESS:' + str(cur/float(total))
                else:
                    logging.debug(u"ri error {}".format(err))
                    return Response('<div class="view"><pre '
                                    'class="ds-err">%s</pre></div>' % err)
            else:
                logging.debug(u"run info not exist")
                return 'PROGRESS:0'
        nodata = task.get()
        if nodata is not None:
            return Response(nodata)
    except NoDataFound, e:
        logging.debug(unicode(e))
        return Response(u'<div class="view"><pre class="ds-err">{}</pre></div>'
                        .format(unicode(e)))