diff --git a/sample/sagemaker/2017-07-24/service-2.json b/sample/sagemaker/2017-07-24/service-2.json index 9dcb41a..793f9a6 100644 --- a/sample/sagemaker/2017-07-24/service-2.json +++ b/sample/sagemaker/2017-07-24/service-2.json @@ -1542,6 +1542,19 @@ ], "documentation":"

Deletes a pipeline if there are no running instances of the pipeline. To delete a pipeline, you must stop all running instances of the pipeline using the StopPipelineExecution API. When you delete a pipeline, all instances of the pipeline are deleted.

" }, + "DeleteProcessingJob":{ + "name":"DeleteProcessingJob", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DeleteProcessingJobRequest"}, + "errors":[ + {"shape":"ResourceNotFound"}, + {"shape":"ResourceInUse"} + ], + "documentation":"

Deletes a processing job. After Amazon SageMaker deletes a processing job, all of the metadata for the processing job is lost. You can delete only processing jobs that are in a terminal state (Stopped, Failed, or Completed). You cannot delete a job that is in the InProgress or Stopping state. After deleting the job, you can reuse its name to create another processing job.

" + }, "DeleteProject":{ "name":"DeleteProject", "http":{ @@ -1590,6 +1603,19 @@ "output":{"shape":"DeleteTagsOutput"}, "documentation":"

Deletes the specified tags from an SageMaker resource.

To list a resource's tags, use the ListTags API.

When you call this API to delete tags from a hyperparameter tuning job, the deleted tags are not removed from training jobs that the hyperparameter tuning job launched before you called this API.

When you call this API to delete tags from a SageMaker Domain or User Profile, the deleted tags are not removed from Apps that the SageMaker Domain or User Profile launched before you called this API.

" }, + "DeleteTrainingJob":{ + "name":"DeleteTrainingJob", + "http":{ + "method":"POST", + "requestUri":"/" + }, + "input":{"shape":"DeleteTrainingJobRequest"}, + "errors":[ + {"shape":"ResourceNotFound"}, + {"shape":"ResourceInUse"} + ], + "documentation":"

Deletes a training job. After SageMaker deletes a training job, all of the metadata for the training job is lost. You can delete only training jobs that are in a terminal state (Stopped, Failed, or Completed) and don't retain an Available managed warm pool. You cannot delete a job that is in the InProgress or Stopping state. After deleting the job, you can reuse its name to create another training job.

" + }, "DeleteTrial":{ "name":"DeleteTrial", "http":{ @@ -14682,6 +14708,16 @@ } } }, + "DeleteProcessingJobRequest":{ + "type":"structure", + "required":["ProcessingJobName"], + "members":{ + "ProcessingJobName":{ + "shape":"ProcessingJobName", + "documentation":"

The name of the processing job to delete.

" + } + } + }, "DeleteProjectInput":{ "type":"structure", "required":["ProjectName"], @@ -14740,6 +14776,16 @@ "type":"structure", "members":{} }, + "DeleteTrainingJobRequest":{ + "type":"structure", + "required":["TrainingJobName"], + "members":{ + "TrainingJobName":{ + "shape":"TrainingJobName", + "documentation":"

The name of the training job to delete.

" + } + } + }, "DeleteTrialComponentRequest":{ "type":"structure", "required":["TrialComponentName"], @@ -42006,7 +42052,8 @@ "Completed", "Failed", "Stopping", - "Stopped" + "Stopped", + "Deleting" ] }, "TrainingJobStatusCounter":{ diff --git a/src/sagemaker_core/main/code_injection/shape_dag.py b/src/sagemaker_core/main/code_injection/shape_dag.py index 0ade0b6..9a6d08b 100644 --- a/src/sagemaker_core/main/code_injection/shape_dag.py +++ b/src/sagemaker_core/main/code_injection/shape_dag.py @@ -4213,6 +4213,10 @@ "members": [{"name": "PipelineArn", "shape": "PipelineArn", "type": "string"}], "type": "structure", }, + "DeleteProcessingJobRequest": { + "members": [{"name": "ProcessingJobName", "shape": "ProcessingJobName", "type": "string"}], + "type": "structure", + }, "DeleteProjectInput": { "members": [{"name": "ProjectName", "shape": "ProjectEntityName", "type": "string"}], "type": "structure", @@ -4252,6 +4256,10 @@ "type": "structure", }, "DeleteTagsOutput": {"members": [], "type": "structure"}, + "DeleteTrainingJobRequest": { + "members": [{"name": "TrainingJobName", "shape": "TrainingJobName", "type": "string"}], + "type": "structure", + }, "DeleteTrialComponentRequest": { "members": [ {"name": "TrialComponentName", "shape": "ExperimentEntityName", "type": "string"} diff --git a/src/sagemaker_core/main/resources.py b/src/sagemaker_core/main/resources.py index 7e3ee68..63fbdf7 100644 --- a/src/sagemaker_core/main/resources.py +++ b/src/sagemaker_core/main/resources.py @@ -26308,6 +26308,40 @@ def refresh( transform(response, "DescribeProcessingJobResponse", self) return self + @Base.add_validate_call + def delete( + self, + ) -> None: + """ + Delete a ProcessingJob resource + + Raises: + botocore.exceptions.ClientError: This exception is raised for AWS service related errors. + The error message and error code can be parsed from the exception as follows: + ``` + try: + # AWS service call here + except botocore.exceptions.ClientError as e: + error_message = e.response['Error']['Message'] + error_code = e.response['Error']['Code'] + ``` + ResourceInUse: Resource being accessed is in use. + ResourceNotFound: Resource being access is not found. + """ + + client = Base.get_sagemaker_client() + + operation_input_args = { + "ProcessingJobName": self.processing_job_name, + } + # serialize the input request + operation_input_args = serialize(operation_input_args) + logger.debug(f"Serialized input request: {operation_input_args}") + + client.delete_processing_job(**operation_input_args) + + logger.info(f"Deleting {self.__class__.__name__} - {self.get_name()}") + @Base.add_validate_call def stop(self) -> None: """ @@ -28708,6 +28742,40 @@ def update( return self + @Base.add_validate_call + def delete( + self, + ) -> None: + """ + Delete a TrainingJob resource + + Raises: + botocore.exceptions.ClientError: This exception is raised for AWS service related errors. + The error message and error code can be parsed from the exception as follows: + ``` + try: + # AWS service call here + except botocore.exceptions.ClientError as e: + error_message = e.response['Error']['Message'] + error_code = e.response['Error']['Code'] + ``` + ResourceInUse: Resource being accessed is in use. + ResourceNotFound: Resource being access is not found. + """ + + client = Base.get_sagemaker_client() + + operation_input_args = { + "TrainingJobName": self.training_job_name, + } + # serialize the input request + operation_input_args = serialize(operation_input_args) + logger.debug(f"Serialized input request: {operation_input_args}") + + client.delete_training_job(**operation_input_args) + + logger.info(f"Deleting {self.__class__.__name__} - {self.get_name()}") + @Base.add_validate_call def stop(self) -> None: """ @@ -28822,6 +28890,69 @@ def wait( raise TimeoutExceededError(resouce_type="TrainingJob", status=current_status) time.sleep(poll) + @Base.add_validate_call + def wait_for_delete( + self, + poll: int = 5, + timeout: Optional[int] = None, + ) -> None: + """ + Wait for a TrainingJob resource to be deleted. + + Parameters: + poll: The number of seconds to wait between each poll. + timeout: The maximum number of seconds to wait before timing out. + + Raises: + botocore.exceptions.ClientError: This exception is raised for AWS service related errors. + The error message and error code can be parsed from the exception as follows: + ``` + try: + # AWS service call here + except botocore.exceptions.ClientError as e: + error_message = e.response['Error']['Message'] + error_code = e.response['Error']['Code'] + ``` + TimeoutExceededError: If the resource does not reach a terminal state before the timeout. + DeleteFailedStatusError: If the resource reaches a failed state. + WaiterError: Raised when an error occurs while waiting. + """ + start_time = time.time() + + progress = Progress( + SpinnerColumn("bouncingBar"), + TextColumn("{task.description}"), + TimeElapsedColumn(), + ) + progress.add_task("Waiting for TrainingJob to be deleted...") + status = Status("Current status:") + + with Live( + Panel( + Group(progress, status), + title="Wait Log Panel", + border_style=Style(color=Color.BLUE.value), + ) + ): + while True: + try: + self.refresh() + current_status = self.training_job_status + status.update(f"Current status: [bold]{current_status}") + + if timeout is not None and time.time() - start_time >= timeout: + raise TimeoutExceededError( + resouce_type="TrainingJob", status=current_status + ) + except botocore.exceptions.ClientError as e: + error_code = e.response["Error"]["Code"] + + if "ResourceNotFound" in error_code or "ValidationException" in error_code: + logger.info("Resource was not found. It may have been deleted.") + return + raise e + time.sleep(poll) + @classmethod @Base.add_validate_call def get_all( diff --git a/src/sagemaker_core/tools/api_coverage.json b/src/sagemaker_core/tools/api_coverage.json index 1ade2d3..22cda04 100644 --- a/src/sagemaker_core/tools/api_coverage.json +++ b/src/sagemaker_core/tools/api_coverage.json @@ -1 +1 @@ -{"SupportedAPIs": 363, "UnsupportedAPIs": 15} \ No newline at end of file +{"SupportedAPIs": 365, "UnsupportedAPIs": 15} \ No newline at end of file