Skip to content

Commit 111e5c2

Browse files
authored
Fix Deployment model definition (#271)
#258 added fields to the `Deployment` model provided by the new `deployments.{get,list,update}` endpoints. However, those were implemented against a version of the OpenAPI specification that disagreed with the actual API responses. Specifically, the `min_instances` and `max_instances` properties were listed as subproperties of a `scaling` object rather than direct fields. The result — as reported in #270 — was Pydantic validation errors like this: ``` raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for Deployment current_release -> configuration -> scaling field required (type=value_error.missing)" ``` This PR updates the `Deployment` model to correctly locate `min_instances` and `max_instances` as properties of `current_release.configuration`. Signed-off-by: Mattt Zmuda <[email protected]>
1 parent e8147b3 commit 111e5c2

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

replicate/deployment.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,14 @@ class Configuration(Resource):
7979
The SKU for the hardware used to run the model.
8080
"""
8181

82-
class Scaling(Resource):
83-
"""
84-
A scaling configuration for a deployment.
85-
"""
86-
87-
min_instances: int
88-
"""
89-
The minimum number of instances for scaling.
90-
"""
91-
92-
max_instances: int
93-
"""
94-
The maximum number of instances for scaling.
95-
"""
96-
97-
scaling: Scaling
82+
min_instances: int
9883
"""
99-
The scaling configuration for the deployment.
84+
The minimum number of instances for scaling.
85+
"""
86+
87+
max_instances: int
88+
"""
89+
The maximum number of instances for scaling.
10090
"""
10191

10292
configuration: Configuration

tests/test_deployment.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"configuration": {
3333
"hardware": "gpu-t4",
34-
"scaling": {"min_instances": 1, "max_instances": 5},
34+
"min_instances": 1,
35+
"max_instances": 5,
3536
},
3637
},
3738
},
@@ -86,7 +87,8 @@
8687
},
8788
"configuration": {
8889
"hardware": "gpu-t4",
89-
"scaling": {"min_instances": 1, "max_instances": 5},
90+
"min_instances": 1,
91+
"max_instances": 5,
9092
},
9193
},
9294
},
@@ -105,7 +107,8 @@
105107
},
106108
"configuration": {
107109
"hardware": "cpu",
108-
"scaling": {"min_instances": 2, "max_instances": 10},
110+
"min_instances": 2,
111+
"max_instances": 10,
109112
},
110113
},
111114
},
@@ -136,7 +139,8 @@
136139
},
137140
"configuration": {
138141
"hardware": "gpu-t4",
139-
"scaling": {"min_instances": 1, "max_instances": 5},
142+
"min_instances": 1,
143+
"max_instances": 5,
140144
},
141145
},
142146
},
@@ -166,7 +170,8 @@
166170
},
167171
"configuration": {
168172
"hardware": "gpu-v100",
169-
"scaling": {"min_instances": 2, "max_instances": 10},
173+
"min_instances": 2,
174+
"max_instances": 10,
170175
},
171176
},
172177
},
@@ -352,8 +357,8 @@ async def test_create_deployment(async_flag):
352357
assert deployment.current_release.created_by.username == "acme"
353358
assert deployment.current_release.created_by.name == "Acme, Inc."
354359
assert deployment.current_release.configuration.hardware == "gpu-t4"
355-
assert deployment.current_release.configuration.scaling.min_instances == 1
356-
assert deployment.current_release.configuration.scaling.max_instances == 5
360+
assert deployment.current_release.configuration.min_instances == 1
361+
assert deployment.current_release.configuration.max_instances == 5
357362

358363

359364
@respx.mock
@@ -392,5 +397,5 @@ async def test_update_deployment(async_flag):
392397
assert updated_deployment.current_release.model == "acme/esrgan-updated"
393398
assert updated_deployment.current_release.version == "new-version-id"
394399
assert updated_deployment.current_release.configuration.hardware == "gpu-v100"
395-
assert updated_deployment.current_release.configuration.scaling.min_instances == 2
396-
assert updated_deployment.current_release.configuration.scaling.max_instances == 10
400+
assert updated_deployment.current_release.configuration.min_instances == 2
401+
assert updated_deployment.current_release.configuration.max_instances == 10

0 commit comments

Comments
 (0)