Example #1
0
def workflow_stop(ctx, workflow, force_stop, access_token):
    """Stop given workflow."""
    if not force_stop:
        click.secho(
            'Graceful stop not implement yet. If you really want to '
            'stop your workflow without waiting for jobs to finish'
            ' use: --force option',
            fg='red')
        raise click.Abort()

    if not access_token:
        click.secho(ERROR_MESSAGES['missing_access_token'], fg='red', err=True)
        sys.exit(1)

    if workflow:
        try:
            logging.info(
                'Sending a request to stop workflow {}'.format(workflow))
            response = stop_workflow(workflow, force_stop, access_token)
            click.secho(get_workflow_status_change_msg(workflow, 'stopped'),
                        fg='green')
        except Exception as e:
            logging.debug(traceback.format_exc())
            logging.debug(str(e))
            click.secho('Workflow could not be stopped: \n{}'.format(str(e)),
                        fg='red',
                        err=True)
Example #2
0
def workflow_stop(ctx, workflow, force_stop, access_token):  # noqa: D301
    """Stop a running workflow.

    The `stop` command allows to hard-stop the running workflow process. Note
    that soft-stopping of the workflow is currently not supported. This command
    should be therefore used with care, only if you are absolutely sure that
    there is no point in continuing the running the workflow.

    Example: \n
    \t $ reana-client stop -w myanalysis.42 --force
    """
    from reana_client.api.client import get_workflow_status, stop_workflow

    if not force_stop:
        click.secho(
            'Graceful stop not implement yet. If you really want to '
            'stop your workflow without waiting for jobs to finish'
            ' use: --force option',
            fg='red')
        raise click.Abort()

    if workflow:
        try:
            logging.info(
                'Sending a request to stop workflow {}'.format(workflow))
            response = stop_workflow(workflow, force_stop, access_token)
            click.secho(get_workflow_status_change_msg(workflow, 'stopped'),
                        fg='green')
        except Exception as e:
            logging.debug(traceback.format_exc())
            logging.debug(str(e))
            click.secho('Cannot stop workflow {}: \n{}'.format(
                workflow, str(e)),
                        fg='red',
                        err=True)
def stop_reana_workflow(workflow_id, workflow=None):
    rec_uuid = resolve_uuid(workflow_id)
    token = get_reana_token(rec_uuid)

    try:
        resp = stop_workflow(workflow_id, True, token)
        update_workflow(workflow_id, 'status', 'stopped')
        return jsonify(resp)
    except Exception:
        return jsonify({
            'message':
            'An exception has occured, most probably '
            'the workflow is not running.'
        }), 400
Example #4
0
def workflow_stop(ctx, workflow, force_stop, access_token):  # noqa: D301
    """Stop a running workflow.

    The ``stop`` command allows to hard-stop the running workflow process. Note
    that soft-stopping of the workflow is currently not supported. This command
    should be therefore used with care, only if you are absolutely sure that
    there is no point in continuing the running the workflow.

    Example: \n
    \t $ reana-client stop -w myanalysis.42 --force
    """
    from reana_client.api.client import stop_workflow

    if not force_stop:
        display_message(
            "Graceful stop not implement yet. If you really want to "
            "stop your workflow without waiting for jobs to finish"
            " use: --force option",
            msg_type="error",
        )
        raise click.Abort()

    if workflow:
        try:
            logging.info("Sending a request to stop workflow {}".format(workflow))
            stop_workflow(workflow, force_stop, access_token)
            display_message(
                get_workflow_status_change_msg(workflow, "stopped"), msg_type="success",
            )
        except Exception as e:
            logging.debug(traceback.format_exc())
            logging.debug(str(e))
            display_message(
                "Cannot stop workflow {}: \n{}".format(workflow, str(e)),
                msg_type="error",
            )