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
24 changes: 7 additions & 17 deletions replicate/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,14 @@ class Configuration(Resource):
The SKU for the hardware used to run the model.
"""

class Scaling(Resource):
"""
A scaling configuration for a deployment.
"""

min_instances: int
"""
The minimum number of instances for scaling.
"""

max_instances: int
"""
The maximum number of instances for scaling.
"""

scaling: Scaling
min_instances: int
"""
The scaling configuration for the deployment.
The minimum number of instances for scaling.
"""

max_instances: int
"""
The maximum number of instances for scaling.
"""

configuration: Configuration
Expand Down
23 changes: 14 additions & 9 deletions tests/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
},
"configuration": {
"hardware": "gpu-t4",
"scaling": {"min_instances": 1, "max_instances": 5},
"min_instances": 1,
"max_instances": 5,
},
},
},
Expand Down Expand Up @@ -86,7 +87,8 @@
},
"configuration": {
"hardware": "gpu-t4",
"scaling": {"min_instances": 1, "max_instances": 5},
"min_instances": 1,
"max_instances": 5,
},
},
},
Expand All @@ -105,7 +107,8 @@
},
"configuration": {
"hardware": "cpu",
"scaling": {"min_instances": 2, "max_instances": 10},
"min_instances": 2,
"max_instances": 10,
},
},
},
Expand Down Expand Up @@ -136,7 +139,8 @@
},
"configuration": {
"hardware": "gpu-t4",
"scaling": {"min_instances": 1, "max_instances": 5},
"min_instances": 1,
"max_instances": 5,
},
},
},
Expand Down Expand Up @@ -166,7 +170,8 @@
},
"configuration": {
"hardware": "gpu-v100",
"scaling": {"min_instances": 2, "max_instances": 10},
"min_instances": 2,
"max_instances": 10,
},
},
},
Expand Down Expand Up @@ -352,8 +357,8 @@ async def test_create_deployment(async_flag):
assert deployment.current_release.created_by.username == "acme"
assert deployment.current_release.created_by.name == "Acme, Inc."
assert deployment.current_release.configuration.hardware == "gpu-t4"
assert deployment.current_release.configuration.scaling.min_instances == 1
assert deployment.current_release.configuration.scaling.max_instances == 5
assert deployment.current_release.configuration.min_instances == 1
assert deployment.current_release.configuration.max_instances == 5


@respx.mock
Expand Down Expand Up @@ -392,5 +397,5 @@ async def test_update_deployment(async_flag):
assert updated_deployment.current_release.model == "acme/esrgan-updated"
assert updated_deployment.current_release.version == "new-version-id"
assert updated_deployment.current_release.configuration.hardware == "gpu-v100"
assert updated_deployment.current_release.configuration.scaling.min_instances == 2
assert updated_deployment.current_release.configuration.scaling.max_instances == 10
assert updated_deployment.current_release.configuration.min_instances == 2
assert updated_deployment.current_release.configuration.max_instances == 10