Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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')
Ejemplo n.º 4
0
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')
Ejemplo n.º 5
0
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')
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
def create_folder(ctx):
    br = ctx.browser
    nb = Notebook(br)
    nb.create_folder()
    nb.open_folder('Untitled Folder')
Ejemplo n.º 8
0
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')
Ejemplo n.º 9
0
def open_jupyter(ctx):
    br = ctx.browser
    br.visit(jburl(ctx.feature.jynb_url, ''))
    nb = Notebook(br, password='******')
    nb.login()
    nb.jupyter_home
Ejemplo n.º 10
0
def restart_kernel(ctx):
    br = ctx.browser
    nb = Notebook(br)
    nb.restart(wait=True)