Skip to content

Commit 744a161

Browse files
authored
fix(deployments): require clusterId on deployment create (#346)
* fix(deployments): require clusterId on deployment create * fix test * fixup * fixed test * fix test
1 parent fe69377 commit 744a161

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

gradient/cli/deployments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def deployments_metrics():
206206
@click.option(
207207
"--clusterId",
208208
"cluster_id",
209+
required=True,
209210
help="Cluster ID",
210211
cls=common.GradientOption,
211212
)

tests/functional/test_deployments.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class TestDeploymentsCreate(object):
7171
"--name", "some_name",
7272
"--machineType", "G1",
7373
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
74+
"--clusterId", "some_cluster_id",
7475
"--instanceCount", "666",
7576
]
7677
BASIC_OPTIONS_COMMAND_WITH_CURRENT_DIR_AS_WORKSPACE = [
@@ -80,6 +81,7 @@ class TestDeploymentsCreate(object):
8081
"--name", "some_name",
8182
"--machineType", "G1",
8283
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
84+
"--clusterId", "some_cluster_id",
8385
"--instanceCount", "666",
8486
"--workspace", ".",
8587
]
@@ -90,6 +92,7 @@ class TestDeploymentsCreate(object):
9092
"--name", "some_name",
9193
"--machineType", "G1",
9294
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
95+
"--clusterId", "some_cluster_id",
9396
"--instanceCount", "666",
9497
"--tag", "test0",
9598
"--tag", "test1",
@@ -112,6 +115,7 @@ class TestDeploymentsCreate(object):
112115
"--name", "some_name",
113116
"--machineType", "G1",
114117
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
118+
"--clusterId", "some_cluster_id",
115119
"--instanceCount", "666",
116120
"--apiKey", "some_key",
117121
]
@@ -153,6 +157,7 @@ class TestDeploymentsCreate(object):
153157
"--machineType", "G1",
154158
"--imageUrl", "https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
155159
"--instanceCount", "666",
160+
"--clusterId", "some_cluster_id",
156161
"--minInstanceCount", "4",
157162
"--maxInstanceCount", "64",
158163
"--scaleCooldownPeriod", "123",
@@ -165,6 +170,7 @@ class TestDeploymentsCreate(object):
165170
"machineType": u"G1",
166171
"name": u"some_name",
167172
"imageUrl": u"https://www.latlmes.com/breaking/paperspace-now-has-a-100-bilion-valuation",
173+
"cluster": "some_cluster_id",
168174
"deploymentType": "TFServing",
169175
"instanceCount": 666,
170176
"modelId": u"some_model_id",
@@ -217,6 +223,7 @@ class TestDeploymentsCreate(object):
217223
"deploymentType": "TFServing",
218224
"instanceCount": 666,
219225
"modelId": u"some_model_id",
226+
"cluster": "some_cluster_id",
220227
"autoscaling": {
221228
"minInstanceCount": 4,
222229
"maxInstanceCount": 64,
@@ -266,7 +273,7 @@ def test_should_send_proper_data_and_print_message_when_create_deployment_with_b
266273
result = runner.invoke(cli.cli, self.BASIC_OPTIONS_COMMAND)
267274

268275
assert result.output == self.EXPECTED_STDOUT, result.exc_info
269-
post_patched.assert_called_once_with(self.URL,
276+
post_patched.assert_called_once_with(self.URL_V2,
270277
headers=EXPECTED_HEADERS,
271278
json=self.BASIC_OPTIONS_REQUEST,
272279
params=None,
@@ -334,10 +341,11 @@ def test_should_send_proper_data_and_print_message_when_create_deployment_with_z
334341
params={
335342
"contentType": content_type,
336343
"fileName": archive_name,
344+
"clusterHandle": 'some_cluster_id',
337345
})
338346
]
339347
)
340-
post_patched.assert_called_once_with(self.URL,
348+
post_patched.assert_called_once_with(self.URL_V2,
341349
headers=EXPECTED_HEADERS,
342350
json=post_params,
343351
params=None,
@@ -360,7 +368,7 @@ def test_should_send_proper_data_and_print_message_when_create_deployment_with_w
360368
archive_location = '/temp_foo'
361369
archive_name = "workspace.zip"
362370
uuid = 111
363-
content_type = "application/zip"
371+
content_type = "application/zip",
364372
presigned_url = "https://{bucket_name}.s3.amazonaws.com/{team_handle}/deployments/{uuid}/{archive_name}?AWSAccessKeyId=AWSKEY&Content-Type={content_type}&Expires=0&Signature=bar".format(
365373
bucket_name=bucket_name,
366374
team_handle=team_handle,
@@ -401,12 +409,13 @@ def test_should_send_proper_data_and_print_message_when_create_deployment_with_w
401409
headers=EXPECTED_HEADERS,
402410
json=None,
403411
params={
404-
"contentType": content_type,
412+
"contentType": 'application/zip',
405413
"fileName": archive_name,
414+
"clusterHandle": 'some_cluster_id',
406415
})
407416
]
408417
)
409-
post_patched.assert_called_once_with(self.URL,
418+
post_patched.assert_called_once_with(self.URL_V2,
410419
headers=EXPECTED_HEADERS,
411420
json=post_params,
412421
params=None,
@@ -457,7 +466,7 @@ def test_should_send_different_api_key_when_api_key_parameter_was_used(self, pos
457466
result = runner.invoke(cli.cli, self.BASIC_OPTIONS_COMMAND_WITH_API_KEY)
458467

459468
assert result.output == self.EXPECTED_STDOUT, result.exc_info
460-
post_patched.assert_called_once_with(self.URL,
469+
post_patched.assert_called_once_with(self.URL_V2,
461470
headers=EXPECTED_HEADERS_WITH_CHANGED_API_KEY,
462471
json=self.BASIC_OPTIONS_REQUEST,
463472
params=None,
@@ -490,7 +499,7 @@ def test_should_send_proper_data_and_print_message_when_create_wrong_model_id_wa
490499
runner = CliRunner()
491500
result = runner.invoke(cli.cli, self.BASIC_OPTIONS_COMMAND)
492501

493-
post_patched.assert_called_once_with(self.URL,
502+
post_patched.assert_called_once_with(self.URL_V2,
494503
headers=EXPECTED_HEADERS,
495504
json=self.BASIC_OPTIONS_REQUEST,
496505
params=None,
@@ -511,7 +520,7 @@ def test_should_send_proper_data_and_tag_deployment(self, post_patched, get_patc
511520
result = runner.invoke(cli.cli, self.BASIC_OPTIONS_COMMAND_WITH_TAGS)
512521

513522
assert result.output == self.EXPECTED_STDOUT, result.exc_info
514-
post_patched.assert_called_once_with(self.URL,
523+
post_patched.assert_called_once_with(self.URL_V2,
515524
headers=EXPECTED_HEADERS,
516525
json=self.BASIC_OPTIONS_REQUEST,
517526
params=None,
@@ -536,7 +545,7 @@ def test_should_send_autoscaling_options_with_metric_and_resource_requirements(s
536545
result = runner.invoke(cli.cli, self.BASIC_OPTIONS_COMMAND_WITH_AUTOSCALING)
537546

538547
assert result.output == self.EXPECTED_STDOUT, result.exc_info
539-
post_patched.assert_called_once_with(self.URL,
548+
post_patched.assert_called_once_with(self.URL_V2,
540549
headers=EXPECTED_HEADERS,
541550
json=self.BASIC_OPTIONS_COMMAND_WITH_AUTOSCALING_REQUEST,
542551
params=None,

0 commit comments

Comments
 (0)