def open_jupyter(ctx): br = ctx.browser br.visit(ctx.feature.jynb_url) nb = Notebook(br) login_required = br.is_text_present('Password', wait_time=2) login_required |= br.is_text_present('token', wait_time=2) if login_required: nb.login() nb.jupyter_home
def list_datasets(ctx): # test omegaml functionality br = ctx.browser nb = Notebook(br) code = """ import omegaml as om om.datasets.put(['sample'], 'sample', append=False) om.datasets.list('sample') """.strip() nb.new_cell_exec(code) sleep(10) current = nb.current_cell_output() expected = "['sample']" assert current == expected, "Expected {expected}, got {current}".format(**locals)
def runnotebook(ctx, nbname): br = ctx.browser om = ctx.feature.om br.visit(ctx.feature.jynb_url) 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 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 add_notebook_in_folder(ctx): br = ctx.browser br.visit(ctx.feature.jynb_url) 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 open_jupyter(ctx): br = ctx.browser br.visit(ctx.feature.jynb_url) nb = Notebook(br) if br.is_text_present('JupyterHub', wait_time=10): login_required = br.is_element_present_by_id('username_input', wait_time=30) if login_required: nb.login_hub() else: # fallback to juypter notebook login_required = br.is_text_present('Password', wait_time=2) login_required |= br.is_text_present('token', wait_time=2) if login_required: nb.login_nb() nb.jupyter_home
def create_folder(ctx): br = ctx.browser nb = Notebook(br) nb.create_folder() nb.open_folder('Untitled Folder')
def create_notebook(ctx): br = ctx.browser nb = Notebook(br) nb.create_notebook() nb.save_notebook() assert not br.is_text_present('error while saving') # test code execution code = """ print('hello') """.strip() nb.current_cell_exec(code) sleep(1) assert nb.current_cell_output() == 'hello' nb.save_notebook() assert not br.is_text_present('error while saving')
def open_jupyter(ctx): br = ctx.browser br.visit(jburl(ctx.feature.jynb_url, '')) nb = Notebook(br, password='******') nb.login() nb.jupyter_home
def restart_kernel(ctx): br = ctx.browser nb = Notebook(br) nb.restart(wait=True)