Skip to content

stop_inference_experiment

stop_inference_experiment(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    name: Optional[InferenceExperimentName] = None,
    model_variant_actions: Optional[ModelVariantActionMap] = None,
    desired_model_variants: Optional[ModelVariantConfigList] = None,
    desired_state: Optional[InferenceExperimentStopDesiredState] = None,
    reason: Optional[InferenceExperimentStatusReason] = None,
) -> StopInferenceExperimentResponse

Stops an inference experiment.

Parameters:

  • name (Optional[InferenceExperimentName], default: None ) –

    The name of the inference experiment to stop.

  • model_variant_actions (Optional[ModelVariantActionMap], default: None ) –

    Array of key-value pairs, with names of variants mapped to actions. The possible actions are the following:

    • Promote - Promote the shadow variant to a production variant

    • Remove - Delete the variant

    • Retain - Keep the variant as it is

  • desired_model_variants (Optional[ModelVariantConfigList], default: None ) –

    An array of ModelVariantConfig objects. There is one for each variant that you want to deploy after the inference experiment stops. Each ModelVariantConfig describes the infrastructure configuration for deploying the corresponding variant.

  • desired_state (Optional[InferenceExperimentStopDesiredState], default: None ) –

    The desired state of the experiment after stopping. The possible states are the following:

    • Completed: The experiment completed successfully

    • Cancelled: The experiment was canceled

  • reason (Optional[InferenceExperimentStatusReason], default: None ) –

    The reason for stopping the experiment.

Raises:

  • ConflictException –

    There was a conflict when you attempted to modify a SageMaker entity such as an Experiment or Artifact.

  • ResourceNotFound –

    Resource being access is not found.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def stop_inference_experiment(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    name: Optional[
        "capo_sagemaker.types.inference_experiment_name.InferenceExperimentName"
    ] = None,
    model_variant_actions: Optional[
        "capo_sagemaker.types.model_variant_action_map.ModelVariantActionMap"
    ] = None,
    desired_model_variants: Optional[
        "capo_sagemaker.types.model_variant_config_list.ModelVariantConfigList"
    ] = None,
    desired_state: Optional[
        "capo_sagemaker.types.inference_experiment_stop_desired_state.InferenceExperimentStopDesiredState"
    ] = None,
    reason: Optional[
        "capo_sagemaker.types.inference_experiment_status_reason.InferenceExperimentStatusReason"
    ] = None,
) -> "capo_sagemaker.types.stop_inference_experiment_response.StopInferenceExperimentResponse":
    """<p>Stops an inference experiment.</p>

    Args:
        name: <p>The name of the inference experiment to stop.</p>
        model_variant_actions: <p> Array of key-value pairs, with names of variants mapped to actions. The possible actions are the following: </p> <ul> <li> <p> <code>Promote</code> - Promote the shadow variant to a production variant</p> </li> <li> <p> <code>Remove</code> - Delete the variant</p> </li> <li> <p> <code>Retain</code> - Keep the variant as it is</p> </li> </ul>
        desired_model_variants: <p> An array of <code>ModelVariantConfig</code> objects. There is one for each variant that you want to deploy after the inference experiment stops. Each <code>ModelVariantConfig</code> describes the infrastructure configuration for deploying the corresponding variant. </p>
        desired_state: <p> The desired state of the experiment after stopping. The possible states are the following: </p> <ul> <li> <p> <code>Completed</code>: The experiment completed successfully</p> </li> <li> <p> <code>Cancelled</code>: The experiment was canceled</p> </li> </ul>
        reason: <p>The reason for stopping the experiment.</p>

    Raises:
        capo_sagemaker.errors.conflict_exception.ConflictException: <p>There was a conflict when you attempted to modify a SageMaker entity such as an <code>Experiment</code> or <code>Artifact</code>.</p>
        capo_sagemaker.errors.resource_not_found.ResourceNotFound: <p>Resource being access is not found.</p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.stop_inference_experiment_request.StopInferenceExperimentRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.stop_inference_experiment_response.StopInferenceExperimentResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.stop_inference_experiment

        output, http_response = (
            capo_sagemaker._operations.sage_maker.stop_inference_experiment.stop_inference_experiment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StopInferenceExperiment")
    )
    input_: capo_sagemaker.types.stop_inference_experiment_request.StopInferenceExperimentRequest = {}
    if name is not None:
        input_["name"] = name
    if model_variant_actions is not None:
        input_["model_variant_actions"] = model_variant_actions
    if desired_model_variants is not None:
        input_["desired_model_variants"] = desired_model_variants
    if desired_state is not None:
        input_["desired_state"] = desired_state
    if reason is not None:
        input_["reason"] = reason

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