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

Commit b2ea53b

Browse files
bbathaBartoszCki
authored andcommitted
fix: stop deployments for full cleanup PS-10081
1 parent e9078fe commit b2ea53b

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

paperspace/cli/deployments.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ def start_deployment(id_, api_key=None):
124124
command.execute(id_)
125125

126126

127-
@deployments.command("delete", help="Delete deployment")
127+
@deployments.command("stop", help="Stop deployment")
128128
@click.option(
129129
"--id",
130130
"id_",
131131
required=True,
132132
help="Deployment ID",
133133
)
134134
@api_key_option
135-
def delete_deployment(id_, api_key=None):
135+
def stop_deployment(id_, api_key=None):
136136
deployments_api = client.API(config.CONFIG_HOST, api_key=api_key)
137-
command = deployments_commands.DeleteDeploymentCommand(api=deployments_api)
138-
command.execute(id_)
137+
command = deployments_commands.StopDeploymentCommand(api=deployments_api)
138+
command.execute(id_)

paperspace/commands/deployments.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ def execute(self, deployment_id):
7474
"Deployment started",
7575
"Unknown error occurred.")
7676

77-
78-
class DeleteDeploymentCommand(_DeploymentCommandBase):
77+
class StopDeploymentCommand(_DeploymentCommandBase):
7978
def execute(self, deployment_id):
8079
json_ = {"id": deployment_id,
81-
"upd": {"isDeleted": True}}
80+
"isRunning": False}
8281
response = self.api.post("/deployments/updateDeployment/", json=json_)
8382
self._log_message(response,
84-
"Deployment deleted.",
83+
"Deployment stopped",
8584
"Unknown error occurred.")

tests/functional/test_deployments.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ def test_should_send_proper_data_and_print_message_when_deployments_start_was_us
228228
assert result.exit_code == 0
229229

230230

231-
class TestDeleteDeployment(object):
231+
class TestStopDeployment(object):
232232
URL = "https://api.paperspace.io/deployments/updateDeployment/"
233-
COMMAND = ["deployments", "delete",
233+
COMMAND = ["deployments", "stop",
234234
"--id", "some_id"]
235-
REQUEST_JSON = {"upd": {"isDeleted": True}, "id": u"some_id"}
236-
EXPECTED_STDOUT = "Deployment deleted.\n"
235+
REQUEST_JSON = {"isRunning": False, "id": u"some_id"}
236+
EXPECTED_STDOUT = "Deployment stopped\n"
237237

238238
COMMAND_WITH_API_KEY = [
239-
"deployments", "delete",
239+
"deployments", "stop",
240240
"--id", "some_id",
241241
"--apiKey", "some_key",
242242
]
@@ -247,7 +247,7 @@ class TestDeleteDeployment(object):
247247
EXPECTED_STDOUT_WITH_WRONG_ID = "Unable to access deployment\n"
248248

249249
@mock.patch("paperspace.cli.deployments.deployments_commands.client.requests.post")
250-
def test_should_send_proper_data_and_print_message_when_deployments_delete_was_used(self, post_patched):
250+
def test_should_send_proper_data_and_print_message_when_deployments_stop_was_used(self, post_patched):
251251
post_patched.return_value = MockResponse(status_code=204)
252252

253253
runner = CliRunner()
@@ -277,7 +277,7 @@ def test_should_send_proper_data_with_custom_api_key_when_api_key_parameter_was_
277277
assert result.exit_code == 0
278278

279279
@mock.patch("paperspace.cli.deployments.deployments_commands.client.requests.post")
280-
def test_should_send_proper_data_and_print_message_when_deployments_delete_used_with_wrong_id(self, post_patched):
280+
def test_should_send_proper_data_and_print_message_when_deployments_stop_used_with_wrong_id(self, post_patched):
281281
post_patched.return_value = MockResponse(self.RESPONSE_JSON_400, 400, "fake content")
282282

283283
runner = CliRunner()

0 commit comments

Comments
 (0)