def run_notebook(args, ssh_config_check):
    """
    Launch the notebook server.
    """
    # Check that ssh is setup.  Currently notebooks require ssh for tunelling.
    ssh_config_check()
    if args.only_check_config:
        return

    # If the user requested a specific version of the notebook server,
    # get the executable id.
    if args.version is not None:
        executable = get_app_from_path('app-{0}/{1}'.format(NOTEBOOK_APP, args.version))
        if executable is not None and 'id' in executable:
            executable = executable['id']
        else:
            msg = RED('Warning:') + ' Invalid notebook version: {0}\nValid versions are: '.format(args.version)
            msg += BOLD('{0}'.format(str(get_notebook_app_versions())))
            err_exit(msg)
    else:
        executable = 'app-{0}'.format(NOTEBOOK_APP)

    # Compose the command to launch the notebook
    cmd = ['dx', 'run', executable, '-inotebook_type={0}'.format(args.notebook_type)]
    cmd += ['-iinput_files={0}'.format(f) for f in args.notebook_files]
    cmd += ['-itimeout={0}'.format(args.timeout), '-y', '--brief', '--allow-ssh', '--instance-type', args.instance_type]
    if args.spark:
        cmd += ['-iinstall_spark=true']
    if args.snapshot:
        cmd += ['-isnapshot={0}'.format(args.snapshot)]
    job_id = subprocess.check_output(cmd).strip()

    poll_for_server_running(job_id)

    if args.notebook_type in {'jupyter', 'jupyter_lab', 'jupyter_notebook'}:
        remote_port = 8888

    setup_ssh_tunnel(job_id, args.port, remote_port)

    if args.open_server:
        multi_platform_open('http://localhost:{0}'.format(args.port))
        print('A web browser should have opened to connect you to your notebook.')
    print('If no browser appears, or if you need to reopen a browser at any point, you should be able to point your browser to http://localhost:{0}'.format(args.port))
def run_notebook ( args , ssh_config_check ) : ssh_config_check ( ) if args . only_check_config : return if args . version is not None : executable = get_app_from_path ( 'app-{0}/{1}' . format ( NOTEBOOK_APP , args . version ) ) if executable is not None and 'id' in executable : executable = executable [ 'id' ] else : msg = RED ( 'Warning:' ) + ' Invalid notebook version: {0}\nValid versions are: ' . format ( args . version ) msg += BOLD ( '{0}' . format ( str ( get_notebook_app_versions ( ) ) ) ) err_exit ( msg ) else : executable = 'app-{0}' . format ( NOTEBOOK_APP ) cmd = [ 'dx' , 'run' , executable , '-inotebook_type={0}' . format ( args . notebook_type ) ] cmd += [ '-iinput_files={0}' . format ( f ) for f in args . notebook_files ] cmd += [ '-itimeout={0}' . format ( args . timeout ) , '-y' , '--brief' , '--allow-ssh' , '--instance-type' , args . instance_type ] if args . spark : cmd += [ '-iinstall_spark=true' ] if args . snapshot : cmd += [ '-isnapshot={0}' . format ( args . snapshot ) ] job_id = subprocess . check_output ( cmd ) . strip ( ) poll_for_server_running ( job_id ) if args . notebook_type in { 'jupyter' , 'jupyter_lab' , 'jupyter_notebook' } : remote_port = 8888 setup_ssh_tunnel ( job_id , args . port , remote_port ) if args . open_server : multi_platform_open ( 'http://localhost:{0}' . format ( args . port ) ) print ( 'A web browser should have opened to connect you to your notebook.' ) print ( 'If no browser appears, or if you need to reopen a browser at any point, you should be able to point your browser to http://localhost:{0}' . format ( args . port ) )
Launch the notebook server.