Esempio n. 1
0
def workflow_open_interactive_session(ctx, workflow, interactive_session_type,
                                      image, access_token):
    """Open an interactive session inside the workflow workspace."""
    if not access_token:
        click.secho(ERROR_MESSAGES['missing_access_token'], fg='red', err=True)
        sys.exit(1)
    if workflow:
        try:
            logging.info(
                "Opening an interactive session on {}".format(workflow))
            interactive_session_configuration = {
                "image": image or None,
            }
            path = open_interactive_session(workflow, access_token,
                                            interactive_session_type,
                                            interactive_session_configuration)
            click.secho(format_session_uri(
                reana_server_url=ctx.obj.reana_server_url,
                path=path,
                access_token=access_token),
                        fg="green")
            click.echo("It could take several minutes to start the "
                       "interactive session.")
        except Exception as e:
            logging.debug(traceback.format_exc())
            logging.debug(str(e))
            click.secho("Interactive session could not be opened: \n{}".format(
                str(e)),
                        fg='red',
                        err=True)
    else:
        click.secho("Workflow {} does not exist".format(workflow),
                    fg="red",
                    err=True)
Esempio n. 2
0
def workflow_open_interactive_session(
    ctx, workflow, interactive_session_type, image, access_token
):  # noqa: D301
    """Open an interactive session inside the workspace.

    The ``open`` command allows to open interactive session processes on top of
    the workflow workspace, such as Jupyter notebooks. This is useful to
    quickly inspect and analyse the produced files while the workflow is stlil
    running.

    Examples:\n
    \t $ reana-client open -w myanalysis.42 jupyter
    """
    from reana_client.api.client import open_interactive_session

    if workflow:
        try:
            logging.info("Opening an interactive session on {}".format(workflow))
            interactive_session_configuration = {
                "image": image or None,
            }
            path = open_interactive_session(
                workflow,
                access_token,
                interactive_session_type,
                interactive_session_configuration,
            )
            display_message(
                "Interactive session opened successfully", msg_type="success"
            )
            click.secho(
                format_session_uri(
                    reana_server_url=ctx.obj.reana_server_url,
                    path=path,
                    access_token=access_token,
                ),
                fg="green",
            )
            display_message(
                "It could take several minutes to start the interactive session."
            )
        except Exception as e:
            logging.debug(traceback.format_exc())
            logging.debug(str(e))
            display_message(
                "Interactive session could not be opened: \n{}".format(str(e)),
                msg_type="error",
            )
    else:
        display_message("Cannot find workflow {}".format(workflow), msg_type="error")
Esempio n. 3
0
def workflow_open_interactive_session(ctx, workflow, interactive_session_type,
                                      image, access_token):  # noqa: D301
    """Open an interactive session inside the workspace.

    The `open` command allows to open interactive session processes on top of
    the workflow workspace, such as Jupyter notebooks. This is useful to
    quickly inspect and analyse the produced files while the workflow is stlil
    running.

    Examples:\n
    \t $ reana-client open -w myanalysis.42 jupyter
    """
    if not access_token:
        click.secho(ERROR_MESSAGES['missing_access_token'], fg='red', err=True)
        sys.exit(1)
    if workflow:
        try:
            logging.info(
                "Opening an interactive session on {}".format(workflow))
            interactive_session_configuration = {
                "image": image or None,
            }
            path = open_interactive_session(workflow, access_token,
                                            interactive_session_type,
                                            interactive_session_configuration)
            click.secho(format_session_uri(
                reana_server_url=ctx.obj.reana_server_url,
                path=path,
                access_token=access_token),
                        fg="green")
            click.echo("It could take several minutes to start the "
                       "interactive session.")
        except Exception as e:
            logging.debug(traceback.format_exc())
            logging.debug(str(e))
            click.secho("Interactive session could not be opened: \n{}".format(
                str(e)),
                        fg='red',
                        err=True)
    else:
        click.secho("Workflow {} does not exist".format(workflow),
                    fg="red",
                    err=True)