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
50 changes: 50 additions & 0 deletions src/sagemaker_core/main/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3855,6 +3855,56 @@ def update_software(
response = client.update_cluster_software(**operation_input_args)
logger.debug(f"Response: {response}")

@Base.add_validate_call
def batch_delete_nodes(
self,
node_ids: List[str],
session: Optional[Session] = None,
region: Optional[str] = None,
) -> Optional[BatchDeleteClusterNodesResponse]:
"""
Deletes specific nodes within a SageMaker HyperPod cluster.

Parameters:
node_ids: A list of node IDs to be deleted from the specified cluster. For SageMaker HyperPod clusters using the Slurm workload manager, you cannot remove instances that are configured as Slurm controller nodes.
session: Boto3 session.
region: Region name.

Returns:
BatchDeleteClusterNodesResponse

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']
```
ResourceNotFound: Resource being access is not found.
"""

operation_input_args = {
"ClusterName": self.cluster_name,
"NodeIds": node_ids,
}
# serialize the input request
operation_input_args = serialize(operation_input_args)
logger.debug(f"Serialized input request: {operation_input_args}")

client = Base.get_sagemaker_client(
session=session, region_name=region, service_name="sagemaker"
)

logger.debug(f"Calling batch_delete_cluster_nodes API")
response = client.batch_delete_cluster_nodes(**operation_input_args)
logger.debug(f"Response: {response}")

transformed_response = transform(response, "BatchDeleteClusterNodesResponse")
return BatchDeleteClusterNodesResponse(**transformed_response)


class CodeRepository(Base):
"""
Expand Down
14 changes: 14 additions & 0 deletions src/sagemaker_core/main/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,20 @@ class BatchDeleteClusterNodesError(Base):
node_id: str


class BatchDeleteClusterNodesResponse(Base):
"""
BatchDeleteClusterNodesResponse

Attributes
----------------------
failed: A list of errors encountered when deleting the specified nodes.
successful: A list of node IDs that were successfully deleted from the specified cluster.
"""

failed: Optional[List[BatchDeleteClusterNodesError]] = Unassigned()
successful: Optional[List[str]] = Unassigned()


class BatchDescribeModelPackageError(Base):
"""
BatchDescribeModelPackageError
Expand Down
8 changes: 8 additions & 0 deletions src/sagemaker_core/tools/additional_operations.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"return_type": "None",
"method_type": "object",
"service_name": "sagemaker"
},
"BatchDeleteClusterNodes": {
"operation_name": "BatchDeleteClusterNodes",
"resource_name": "Cluster",
"method_name": "batch_delete_nodes",
"return_type": "BatchDeleteClusterNodesResponse",
"method_type": "object",
"service_name": "sagemaker"
}
},
"PipelineExecution": {
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": 339, "UnsupportedAPIs": 6}
{"SupportedAPIs": 340, "UnsupportedAPIs": 5}
Loading