Skip to content

stop_experiment_run

stop_experiment_run(
    experiment_id: ExperimentId,
    run_id: ExperimentRunId,
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    detail: Optional[DetailText] = None,
) -> StopExperimentRunOutput

Stops a run. Applies to runs reported from the caller's code and to hosted runs. The run ends as DID_NOT_FINISH with statusReason STOPPED; a hosted run is STOPPING until its batch evaluation has stopped. Stopping a run that is STOPPING or has ended returns its current state. Fails with a ConflictException (RUN_TERMINAL) while a CompleteExperimentRun call is finishing the run; retry CompleteExperimentRun instead.

Parameters:

  • experiment_id (ExperimentId) –

    The ID of the experiment the run belongs to.

  • run_id (ExperimentRunId) –

    The ID of the run to stop.

  • detail (Optional[DetailText], default: None ) –

    An optional reason for stopping the run, stored as the run's statusDetail. For example, "agent unreachable after 5 consecutive errors".

Raises:

Examples:

Stop a reported run The following example stops a run reported from the caller's code after the agent under test became unreachable. The run ends as DID_NOT_FINISH, and cases that were never reported count as not run. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> client.stop_experiment_run(experiment_id='exp-01JD8K3M5N7P9Q2R4S6T8V0W1X', run_id='ci-build-4821', detail='agent unreachable after 5 consecutive errors')
Source code in docs_src/capo_cloudwatchomni/_services/cloud_watch_omni.py
def stop_experiment_run(
    self,
    experiment_id: "capo_cloudwatchomni.types.experiment_id.ExperimentId",
    run_id: "capo_cloudwatchomni.types.experiment_run_id.ExperimentRunId",
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    detail: Optional["capo_cloudwatchomni.types.detail_text.DetailText"] = None,
) -> "capo_cloudwatchomni.types.stop_experiment_run_output.StopExperimentRunOutput":
    """Stops a run. Applies to runs reported from the caller's code and to hosted runs. The run ends as DID_NOT_FINISH with statusReason STOPPED; a hosted run is STOPPING until its batch evaluation has stopped. Stopping a run that is STOPPING or has ended returns its current state. Fails with a ConflictException (RUN_TERMINAL) while a CompleteExperimentRun call is finishing the run; retry CompleteExperimentRun instead.

    Args:
        experiment_id: The ID of the experiment the run belongs to.
        run_id: The ID of the run to stop.
        detail: An optional reason for stopping the run, stored as the run's statusDetail. For example, "agent unreachable after 5 consecutive errors".

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.conflict_exception.ConflictException: The operation could not be completed because of a conflict with the current state of the resource.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource does not exist.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Stop a reported run
        The following example stops a run reported from the caller's code after the agent under test became unreachable. The run ends as DID_NOT_FINISH, and cases that were never reported count as not run. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.stop_experiment_run(experiment_id='exp-01JD8K3M5N7P9Q2R4S6T8V0W1X', run_id='ci-build-4821', detail='agent unreachable after 5 consecutive errors')
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatchomni.types.stop_experiment_run_input.StopExperimentRunInput]",
    ) -> OperationResponse[
        "capo_cloudwatchomni.types.stop_experiment_run_output.StopExperimentRunOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.stop_experiment_run

        output, http_response = (
            capo_cloudwatchomni._operations.cloud_watch_omni_frontend.stop_experiment_run.stop_experiment_run(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cloudwatchomni.types.stop_experiment_run_input.StopExperimentRunInput",
    ) -> dict[str, Any]:
        import capo_cloudwatchomni.types.stop_experiment_run_input

        return capo_cloudwatchomni.types.stop_experiment_run_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_cloudwatchomni.types.stop_experiment_run_output.StopExperimentRunOutput",
    ) -> dict[str, Any]:
        import capo_cloudwatchomni.types.stop_experiment_run_output

        return (
            capo_cloudwatchomni.types.stop_experiment_run_output.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "StopExperimentRun",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cloudwatchomni.types.stop_experiment_run_input.StopExperimentRunInput = {
        "experiment_id": experiment_id,
        "run_id": run_id,
    }
    if detail is not None:
        input_["detail"] = detail

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output