Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion sample/sagemaker/2017-07-24/service-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,19 @@
],
"documentation":"<p>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 <code>StopPipelineExecution</code> API. When you delete a pipeline, all instances of the pipeline are deleted.</p>"
},
"DeleteProcessingJob":{
"name":"DeleteProcessingJob",
"http":{
"method":"POST",
"requestUri":"/"
},
"input":{"shape":"DeleteProcessingJobRequest"},
"errors":[
{"shape":"ResourceNotFound"},
{"shape":"ResourceInUse"}
],
"documentation":"<p>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 (<code>Stopped</code>, <code>Failed</code>, or <code>Completed</code>). You cannot delete a job that is in the <code>InProgress</code> or <code>Stopping</code> state. After deleting the job, you can reuse its name to create another processing job.</p>"
},
"DeleteProject":{
"name":"DeleteProject",
"http":{
Expand Down Expand Up @@ -1590,6 +1603,19 @@
"output":{"shape":"DeleteTagsOutput"},
"documentation":"<p>Deletes the specified tags from an SageMaker resource.</p> <p>To list a resource's tags, use the <code>ListTags</code> API. </p> <note> <p>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.</p> </note> <note> <p>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.</p> </note>"
},
"DeleteTrainingJob":{
"name":"DeleteTrainingJob",
"http":{
"method":"POST",
"requestUri":"/"
},
"input":{"shape":"DeleteTrainingJobRequest"},
"errors":[
{"shape":"ResourceNotFound"},
{"shape":"ResourceInUse"}
],
"documentation":"<p>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 (<code>Stopped</code>, <code>Failed</code>, or <code>Completed</code>) and don't retain an <code>Available</code> <a href=\"https://docs.aws.amazon.com/sagemaker/latest/dg/train-warm-pools.html\">managed warm pool</a>. You cannot delete a job that is in the <code>InProgress</code> or <code>Stopping</code> state. After deleting the job, you can reuse its name to create another training job.</p>"
},
"DeleteTrial":{
"name":"DeleteTrial",
"http":{
Expand Down Expand Up @@ -14682,6 +14708,16 @@
}
}
},
"DeleteProcessingJobRequest":{
"type":"structure",
"required":["ProcessingJobName"],
"members":{
"ProcessingJobName":{
"shape":"ProcessingJobName",
"documentation":"<p>The name of the processing job to delete.</p>"
}
}
},
"DeleteProjectInput":{
"type":"structure",
"required":["ProjectName"],
Expand Down Expand Up @@ -14740,6 +14776,16 @@
"type":"structure",
"members":{}
},
"DeleteTrainingJobRequest":{
"type":"structure",
"required":["TrainingJobName"],
"members":{
"TrainingJobName":{
"shape":"TrainingJobName",
"documentation":"<p>The name of the training job to delete.</p>"
}
}
},
"DeleteTrialComponentRequest":{
"type":"structure",
"required":["TrialComponentName"],
Expand Down Expand Up @@ -42006,7 +42052,8 @@
"Completed",
"Failed",
"Stopping",
"Stopped"
"Stopped",
"Deleting"
]
},
"TrainingJobStatusCounter":{
Expand Down
8 changes: 8 additions & 0 deletions src/sagemaker_core/main/code_injection/shape_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"}
Expand Down
131 changes: 131 additions & 0 deletions src/sagemaker_core/main/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker_core/tools/api_coverage.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"SupportedAPIs": 363, "UnsupportedAPIs": 15}
{"SupportedAPIs": 365, "UnsupportedAPIs": 15}
Loading