def add_notebook_in_folder(ctx): br = ctx.browser br.visit(jburl(ctx.feature.jynb_url, '', nbstyle='tree')) nb = Notebook(br) nb.jupyter_home nb.open_folder('Untitled Folder') nb.create_notebook() nb.last_notebook assert not br.is_text_present('No such directory')
def uploadtutorial(ctx, nbname): # uploading does not work because a native dialogue is opened # br.find_by_css('input.fileinput') # br.find_by_css('input.fileinput').click() # opens a native file dialoge from nbformat import read as nbread br = ctx.browser om = ctx.feature.om # upload directly nbfname = os.path.join(ctx.nbfiles, '{nbname}.ipynb'.format(**locals())) nbcells = nbread(nbfname, as_version=4) om.jobs.put(nbcells, nbname) # now run the notebook userid = getattr(om.runtime.auth, 'userid', '') br.visit(jburl(ctx.feature.jynb_url, userid, nbstyle='tree')) assert br.is_text_present(nbname)
def runnotebook(ctx, nbname): br = ctx.browser om = ctx.feature.om userid = getattr(om.runtime.auth, 'userid', '') br.visit(jburl(ctx.feature.jynb_url, userid, nbstyle='tree')) nb = Notebook(br) # FIXME sometimes it takes long for the nb to appear. why? nb.open_notebook(nbname, retry=10) nb.run_all_cells(wait=True) nb.save_notebook() assert not br.is_text_present('Error') assert not br.is_text_present('Exception') assert not br.is_text_present('failed') assert not br.is_text_present('MissingSchema') assert not br.is_text_present('error')
def open_jupyter(ctx): br = ctx.browser br.visit(jburl(ctx.feature.jynb_url, '')) nb = Notebook(br, password='******') nb.login() nb.jupyter_home