Skip to content

Commit 5c9949b

Browse files
committed
[SDK] Document in-place replica scaling in create examples
Show how Inference/CServe/Dynamo updates that only change min/max replicas reuse the selected revision without a rolling update.
1 parent ad8e09b commit 5c9949b

4 files changed

Lines changed: 39 additions & 3 deletions

File tree

examples/sdk/create_cserve.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ def main():
5151
print("Deployment details: ", deployment)
5252

5353
"""
54+
### Scale replicas in place (no new revision / no rolling update)
55+
# Changing only min_replicas and/or max_replicas on the same Create*
56+
# request updates the selected revision in place; revision_number stays put.
57+
# Any other field change still creates a new revision.
58+
qwen_config.min_replicas = 2
59+
qwen_config.max_replicas = 4
60+
cclient.update_cserve(deployment.id, qwen_config)
61+
scaled = cclient.get_cserve(deployment.id)
62+
print(f"Scaled to {scaled.min_replicas}-{scaled.max_replicas}; revision {scaled.revision_number}")
63+
5464
### Pause the deployment
5565
cclient.pause(deployment.id)
5666

examples/sdk/create_dynamo.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ def main():
5858
# client.resume(deployment.id)
5959
# client.delete(deployment.id)
6060
#
61-
# To update a Dynamo deployment, construct a new
62-
# CreateDynamoDeploymentRequest and call:
63-
# client.update_dynamo(deployment.id, updated_request)
61+
# Scale replicas in place (no new revision / no rolling update):
62+
# Changing only min_replicas and/or max_replicas on the same Create*
63+
# request updates the selected revision in place; revision_number stays put.
64+
# Any other field change still creates a new revision.
65+
# request.min_replicas = 2
66+
# request.max_replicas = 4
67+
# client.update_dynamo(deployment.id, request)
68+
# scaled = client.get_dynamo(deployment.id)
69+
# print(f"Scaled to {scaled.min_replicas}-{scaled.max_replicas}; revision {scaled.revision_number}")
6470

6571
print(f"Created Dynamo deployment {deployment.id}: {deployment.endpoint_url}")
6672
print(f"Model: {deployment.model}")

examples/sdk/create_inference.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ def main():
3838
print("Deployment details: ", deployment)
3939

4040
'''
41+
### Scale replicas in place (no new revision / no rolling update)
42+
# Changing only min_replicas and/or max_replicas on the same Create*
43+
# request updates the selected revision in place; revision_number stays put.
44+
# Any other field change still creates a new revision.
45+
request.min_replicas = 2
46+
request.max_replicas = 5
47+
cclient.update_inference(deployment.id, request)
48+
scaled = cclient.get_inference(deployment.id)
49+
print(f"Scaled to {scaled.min_replicas}-{scaled.max_replicas}; revision {scaled.revision_number}")
50+
4151
### Pause the deployment
4252
cclient.pause(deployment.id)
4353

examples/sdk/create_inference_vllm.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def main():
3737
print("Deployment details: ", deployment)
3838

3939
'''
40+
### Scale replicas in place (no new revision / no rolling update)
41+
# Changing only min_replicas and/or max_replicas on the same Create*
42+
# request updates the selected revision in place; revision_number stays put.
43+
# Any other field change still creates a new revision.
44+
request.min_replicas = 1
45+
request.max_replicas = 3
46+
cclient.update_inference(deployment.id, request)
47+
scaled = cclient.get_inference(deployment.id)
48+
print(f"Scaled to {scaled.min_replicas}-{scaled.max_replicas}; revision {scaled.revision_number}")
49+
4050
### Pause the deployment
4151
cclient.pause(deployment.id)
4252

0 commit comments

Comments
 (0)