Beispiel #1
0
def test_notebook_nodata():
    nbdir = get_notebook_dir()
    path = os.path.join(nbdir, 'test-notebook-nodata.ipynb')
    assert os.path.isfile(path)
    update_notebook_by_run(path)
    rv = notebook_outputs_to_html(path)
    assert 'NoDataFound' in rv
Beispiel #2
0
def _collect_gnbs(gnbs, gk, groups):
    nbs = []
    nbdir = get_notebook_dir()
    logging.debug('_collect_gnbs ' + nbdir)
    # logging.debug(str(groups[gk]))
    for path, url, fname in groups[gk]:
        out = notebook_outputs_to_html(path)
        ri = get_run_info(path)
        logging.debug('get_run_info {}'.format(ri))
        if ri is not None:
            start, elapsed = _get_run_time(ri)
            cur = ri[2]
            total = ri[3]
            err = ri[4].decode('utf8')
            if err != 'None':
                out = '<div class="fail-result">Check error, fix it, '\
                      'and rerun.</div>'
                # logging.debug(u'err {}'.format(err))
            ri = (start, elapsed, cur, total, err)
        path = path.replace(nbdir, '')[1:]
        nbs.append((url, fname, out, ri, path))
    gnbs.append((gk, nbs))
    logging.debug('_collect_gnbs done')
Beispiel #3
0
sol_dir = cfg['sol_dir']
data_dir = cfg['data_dir']


@app.task()
def rerun_notebook(nbpath):
    print(u'rerun_notebook {}'.format(nbpath))
    rerun_notebook.update_state(state='PROGRESS', meta=0)
    try:
        update_notebook_by_run(nbpath)
    except NoDataFound, e:
        logging.debug('NoDataFound')
        return [unicode(e)]
    rerun_notebook.update_state(state='PROGRESS', meta=1)
    print(u'rerun_notebook {} done.'.format(nbpath))
    return [notebook_outputs_to_html(nbpath)]


@app.task()
def run_view_cell(nbpath, formname, kwargs):
    print('run_view_cell {}'.format(formname))
    nb = read(open(nbpath), IPYNB_VER)
    r = NotebookRunner(nb, pylab=True)
    total = float(get_view_cell_cnt(r) + 1)

    run_init(r, nbpath)

    init = "from wzdat.dashboard.control import Form; %s = Form();"\
           "form.init(%s)" % (formname, repr(kwargs))
    print('init {}'.format(init))
    try: