Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit e9078fe

Browse files
bbathaBartoszCki
authored andcommitted
fix: remove under specified update command PS-10086
1 parent 9cf1e05 commit e9078fe

File tree

3 files changed

+0
-125
lines changed

3 files changed

+0
-125
lines changed

paperspace/cli/deployments.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -110,47 +110,6 @@ def get_deployments_list(api_key=None, **filters):
110110
command.execute(filters=filters)
111111

112112

113-
@deployments.command("update", help="Update deployment properties")
114-
@click.option(
115-
"--id",
116-
"id_",
117-
required=True,
118-
help="Deployment ID",
119-
)
120-
@click.option(
121-
"--modelId",
122-
"modelId",
123-
help="ID of a trained model",
124-
)
125-
@click.option(
126-
"--name",
127-
"name",
128-
help="Human-friendly name for new model deployment",
129-
)
130-
@click.option(
131-
"--machineType",
132-
"machineType",
133-
help="Type of machine for new deployment",
134-
)
135-
@click.option(
136-
"--imageUrl",
137-
"imageUrl",
138-
help="Docker image for model serving",
139-
)
140-
@click.option(
141-
"--instanceCount",
142-
"instanceCount",
143-
type=int,
144-
help="Number of machine instances",
145-
)
146-
@api_key_option
147-
def update_deployment_model(id_, api_key, **kwargs):
148-
del_if_value_is_none(kwargs)
149-
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
150-
command = deployments_commands.UpdateDeploymentCommand(api=deployments_api)
151-
command.execute(id_, kwargs)
152-
153-
154113
@deployments.command("start", help="Start deployment")
155114
@click.option(
156115
"--id",

paperspace/commands/deployments.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ def _get_table_data(self, deployments):
6565
return data
6666

6767

68-
class UpdateDeploymentCommand(_DeploymentCommandBase):
69-
def execute(self, deployment_id, kwargs):
70-
if not kwargs:
71-
self.logger.log("No parameters to update were given. Use --help for more information.")
72-
return
73-
74-
json_ = {"id": deployment_id,
75-
"upd": kwargs}
76-
response = self.api.post("/deployments/updateDeployment/", json=json_)
77-
self._log_message(response,
78-
"Deployment model updated.",
79-
"Unknown error occurred.")
80-
81-
8268
class StartDeploymentCommand(_DeploymentCommandBase):
8369
def execute(self, deployment_id):
8470
json_ = {"id": deployment_id,

tests/functional/test_deployments.py

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -205,76 +205,6 @@ def test_should_print_proper_message_when_wrong_api_key_was_used(self, get_patch
205205
assert result.output == "Invalid API token\n"
206206

207207

208-
class TestDeploymentsUpdate(object):
209-
URL = "https://api.paperspace.io/deployments/updateDeployment/"
210-
COMMAND = [
211-
"deployments", "update",
212-
"--id", "some_id",
213-
"--name", "new_name",
214-
]
215-
BASIC_OPTIONS_REQUEST_JSON = {"upd": {"name": u"new_name"}, "id": u"some_id"}
216-
217-
COMMAND_WITH_API_KEY = [
218-
"deployments", "update",
219-
"--id", "some_id",
220-
"--name", "new_name",
221-
"--apiKey", "some_key"
222-
]
223-
EXPECTED_HEADERS_WITH_CHANGED_API_KEY = paperspace.client.default_headers.copy()
224-
EXPECTED_HEADERS_WITH_CHANGED_API_KEY["X-API-Key"] = "some_key"
225-
226-
RESPONSE_JSON_200 = {"upd": {"name": u"asd"}, "id": u"dennaw0wzbvvg3"}
227-
EXPECTED_STDOUT = "Deployment model updated.\n"
228-
229-
RESPONSE_JSON_400 = {"error": {"name": "Error", "status": 400, "message": "Unable to access deployment"}}
230-
EXPECTED_STDOUT_WITH_WRONG_ID = "Unable to access deployment\n"
231-
232-
@mock.patch("paperspace.cli.deployments.deployments_commands.client.requests.post")
233-
def test_should_send_proper_data_and_print_message_when_update_deployment(self, post_patched):
234-
post_patched.return_value = MockResponse(self.RESPONSE_JSON_200, 200, "fake content")
235-
236-
runner = CliRunner()
237-
result = runner.invoke(cli.cli, self.COMMAND)
238-
239-
post_patched.assert_called_once_with(self.URL,
240-
headers=EXPECTED_HEADERS,
241-
json=self.BASIC_OPTIONS_REQUEST_JSON,
242-
params=None,
243-
files=None)
244-
assert result.output == self.EXPECTED_STDOUT
245-
assert result.exit_code == 0
246-
247-
@mock.patch("paperspace.cli.deployments.deployments_commands.client.requests.post")
248-
def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_provided(self, post_patched):
249-
post_patched.return_value = MockResponse(self.RESPONSE_JSON_200, 200, "fake content")
250-
251-
runner = CliRunner()
252-
result = runner.invoke(cli.cli, self.COMMAND_WITH_API_KEY)
253-
254-
post_patched.assert_called_once_with(self.URL,
255-
headers=self.EXPECTED_HEADERS_WITH_CHANGED_API_KEY,
256-
json=self.BASIC_OPTIONS_REQUEST_JSON,
257-
params=None,
258-
files=None)
259-
assert result.output == self.EXPECTED_STDOUT
260-
assert result.exit_code == 0
261-
262-
@mock.patch("paperspace.cli.deployments.deployments_commands.client.requests.post")
263-
def test_should_send_proper_data_and_print_message_when_update_deployment_used_with_wrong_id(self, post_patched):
264-
post_patched.return_value = MockResponse(self.RESPONSE_JSON_400, 400, "fake content")
265-
266-
runner = CliRunner()
267-
result = runner.invoke(cli.cli, self.COMMAND)
268-
269-
post_patched.assert_called_once_with(self.URL,
270-
headers=EXPECTED_HEADERS,
271-
json=self.BASIC_OPTIONS_REQUEST_JSON,
272-
params=None,
273-
files=None)
274-
assert result.output == self.EXPECTED_STDOUT_WITH_WRONG_ID
275-
assert result.exit_code == 0
276-
277-
278208
class TestStartDeployment(object):
279209
URL = "https://api.paperspace.io/deployments/updateDeployment/"
280210
COMMAND = ["deployments", "start",

0 commit comments

Comments
 (0)