def _poll_rerun_output(nbapath): rv = [] with open(nbapath, 'r') as f: nb = reads(f.read(), IPYNB_VER) if len(nb) > 0: try: for cell in nb['cells']: _type = cell['cell_type'] if _type == 'code' and 'outputs' in cell: code = cell['source'] logging.debug(cell) if '#!dashboard_view' in code: notebook_cell_outputs_to_html(rv, cell['outputs'], 'view') except IndexError: logging.error(u"Incomplete notebook - {}".format(nbapath)) return '\n'.join(rv)
state = task.state if state == 'PENDING': return 'PROGRESS:0' logging.debug("{} - {}".format(task.state, task.status)) if task.state == 'PROGRESS': return 'PROGRESS:' + str(task.result) outputs = task.get() except Exception, e: logging.debug('poll_view - ' + unicode(e)) err = task.traceback logging.error(err) err = ansi_escape.sub('', err) return Response('<div class="view"><pre class="ds-err">%s</pre></div>' % err) rv = [] notebook_cell_outputs_to_html(rv, outputs, 'view') logging.debug(u"poll view outputs {}".format(outputs)) ret = '\n'.join(rv) return Response(ret) @app.route('/start_rerun/<path:nbrpath>', methods=['POST']) def start_rerun(nbrpath): logging.debug('start_rerun') nbapath = os.path.join(get_notebook_dir(), nbrpath) from wzdat.dashboard.tasks import rerun_notebook task = rerun_notebook.delay(nbapath) rv = nbrpath + '/' + task.task_id logging.debug(u'rv {}'.format(rv)) return Response(rv)