Skip to content

stop_training_job

stop_training_job(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    training_job_name: Optional[TrainingJobName] = None,
) -> None

Stops a training job. To stop a job, SageMaker sends the algorithm the SIGTERM signal, which delays job termination for 120 seconds. Algorithms might use this 120-second window to save the model artifacts, so the results of the training is not lost.

When it receives a StopTrainingJob request, SageMaker changes the status of the job to Stopping. After SageMaker stops the job, it sets the status to Stopped.

Parameters:

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def stop_training_job(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    training_job_name: Optional[
        "capo_sagemaker.types.training_job_name.TrainingJobName"
    ] = None,
) -> None:
    """<p>Stops a training job. To stop a job, SageMaker sends the algorithm the <code>SIGTERM</code> signal, which delays job termination for 120 seconds. Algorithms might use this 120-second window to save the model artifacts, so the results of the training is not lost. </p> <p>When it receives a <code>StopTrainingJob</code> request, SageMaker changes the status of the job to <code>Stopping</code>. After SageMaker stops the job, it sets the status to <code>Stopped</code>.</p>

    Args:
        training_job_name: <p>The name of the training job to stop.</p>

    Raises:
        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_training_job_request.StopTrainingJobRequest]",
    ) -> OperationResponse[None]:
        import capo_sagemaker._operations.sage_maker.stop_training_job

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StopTrainingJob")
    )
    input_: capo_sagemaker.types.stop_training_job_request.StopTrainingJobRequest = {}
    if training_job_name is not None:
        input_["training_job_name"] = training_job_name

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