Implementation:Bentoml BentoML Deployment Terminate Delete
Appearance
Overview
Deployment Terminate and Delete implements the Principle:Bentoml_BentoML_Deployment_Termination principle by providing two distinct functions: terminate() to stop a running deployment while preserving its record, and delete() to permanently remove a deployment.
API
bentoml.deployment.terminate()bentoml.deployment.delete()
Source
src/bentoml/deployment.py:L301-348
Import
import bentoml
Signatures
terminate()
def terminate(
name: str,
cluster: str = None,
wait: bool = False,
) -> Deployment
delete()
def delete(
name: str,
cluster: str = None,
) -> None
Key Parameters
| Function | Parameter | Type | Default | Description |
|---|---|---|---|---|
| terminate | name |
str | (required) | Name of the deployment to terminate |
| terminate | cluster |
str | None | Cluster where the deployment runs |
| terminate | wait |
bool | False | Block until termination completes |
| delete | name |
str | (required) | Name of the deployment to delete |
| delete | cluster |
str | None | Cluster where the deployment runs |
Inputs and Outputs
terminate()
Inputs:
- Deployment name (required)
- Cluster name (optional, uses default if not specified)
- Wait flag (optional, controls blocking behavior)
Outputs:
- Deployment object in terminated state, with updated status reflecting the stopped service
delete()
Inputs:
- Deployment name (required)
- Cluster name (optional, uses default if not specified)
Outputs:
- None - The deployment is permanently removed
Usage Examples
Terminate a Deployment
import bentoml
# Terminate without waiting (returns immediately)
deployment = bentoml.deployment.terminate("my-llm-service")
print(f"Status: {deployment.status}") # Status: terminating
# Terminate and wait for completion
deployment = bentoml.deployment.terminate(
"my-llm-service",
wait=True,
)
print(f"Status: {deployment.status}") # Status: terminated
Delete a Deployment
import bentoml
# Permanently remove a deployment
bentoml.deployment.delete("my-old-service")
# Returns None; deployment is gone
Terminate Then Delete
import bentoml
# Two-phase cleanup: terminate first, then delete
deployment = bentoml.deployment.terminate("my-service", wait=True)
print(f"Terminated: {deployment.name}")
# After confirming termination, permanently remove
bentoml.deployment.delete("my-service")
print("Deployment deleted")
Specify Cluster
import bentoml
# Terminate a deployment in a specific cluster
deployment = bentoml.deployment.terminate(
"my-service",
cluster="gcp-us-central1",
wait=True,
)
# Delete from a specific cluster
bentoml.deployment.delete(
"my-service",
cluster="gcp-us-central1",
)
CLI Usage
# Terminate a deployment
bentoml deployment terminate my-llm-service
# Terminate and wait
bentoml deployment terminate my-llm-service --wait
# Delete a deployment
bentoml deployment delete my-llm-service
# Specify cluster
bentoml deployment terminate my-service --cluster gcp-us-central1
bentoml deployment delete my-service --cluster gcp-us-central1
Metadata
| Property | Value |
|---|---|
| Implementation | Deployment Terminate and Delete |
| API | bentoml.deployment.terminate(), .delete()
|
| Source | src/bentoml/deployment.py:L301-348
|
| Domain | ML_Serving, Cloud_Deployment, Operations |
| Workflow | BentoCloud_Deployment |
| Principle | Principle:Bentoml_BentoML_Deployment_Termination |
Knowledge Sources
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment