cgcsdk 0.7.0__py3-none-any.whl → 0.8.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cgc/.env +1 -1
- cgc/CHANGELOG.md +15 -0
- cgc/__init__.py +7 -0
- cgc/cgc.py +4 -0
- cgc/commands/auth/auth_cmd.py +0 -1
- cgc/commands/billing/__init__.py +2 -2
- cgc/commands/billing/billing_cmd.py +6 -6
- cgc/commands/billing/billing_responses.py +3 -3
- cgc/commands/billing/billing_utils.py +1 -1
- cgc/commands/cgc_cmd.py +4 -4
- cgc/commands/cgc_cmd_responses.py +7 -10
- cgc/commands/compute/compute_cmd.py +6 -120
- cgc/commands/compute/compute_models.py +21 -9
- cgc/commands/compute/compute_responses.py +29 -2
- cgc/commands/compute/compute_utills.py +6 -3
- cgc/commands/db/db_cmd.py +100 -0
- cgc/commands/debug/debug_cmd.py +1 -1
- cgc/commands/resource/__init__.py +0 -0
- cgc/commands/resource/resource_cmd.py +145 -0
- cgc/telemetry/basic.py +5 -3
- cgc/tests/__init__.py +34 -34
- cgc/tests/responses_tests.py +9 -9
- cgc/utils/consts/message_consts.py +3 -2
- cgc/utils/response_utils.py +8 -6
- cgcsdk-0.8.0.dist-info/LICENSE +0 -0
- {cgcsdk-0.7.0.dist-info → cgcsdk-0.8.0.dist-info}/METADATA +1 -1
- {cgcsdk-0.7.0.dist-info → cgcsdk-0.8.0.dist-info}/RECORD +31 -27
- /cgcsdk-0.7.0.dist-info/LICENSE → /cgc/commands/db/__init__.py +0 -0
- {cgcsdk-0.7.0.dist-info → cgcsdk-0.8.0.dist-info}/WHEEL +0 -0
- {cgcsdk-0.7.0.dist-info → cgcsdk-0.8.0.dist-info}/entry_points.txt +0 -0
- {cgcsdk-0.7.0.dist-info → cgcsdk-0.8.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,145 @@
|
|
1
|
+
import click
|
2
|
+
import json
|
3
|
+
|
4
|
+
from cgc.commands.compute.compute_models import EntityList, DatabasesList
|
5
|
+
from cgc.commands.compute.compute_responses import (
|
6
|
+
template_list_response,
|
7
|
+
template_get_start_path_response,
|
8
|
+
compute_logs_response,
|
9
|
+
compute_restart_response,
|
10
|
+
compute_delete_response,
|
11
|
+
compute_list_response,
|
12
|
+
)
|
13
|
+
|
14
|
+
from cgc.commands.compute.compute_utills import compute_delete_payload
|
15
|
+
|
16
|
+
from cgc.utils.prepare_headers import get_api_url_and_prepare_headers
|
17
|
+
from cgc.utils.response_utils import retrieve_and_validate_response_send_metric
|
18
|
+
from cgc.utils.click_group import CustomGroup, CustomCommand
|
19
|
+
from cgc.utils.requests_helper import call_api, EndpointTypes
|
20
|
+
|
21
|
+
|
22
|
+
@click.group(name="resource", cls=CustomGroup)
|
23
|
+
def resource_group():
|
24
|
+
"""
|
25
|
+
Management of templates.
|
26
|
+
"""
|
27
|
+
|
28
|
+
|
29
|
+
@resource_group.command("list_templates", cls=CustomCommand)
|
30
|
+
def template_list():
|
31
|
+
"""Lists all available templates"""
|
32
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
33
|
+
url = f"{api_url}/v1/api/resource/list_available_templates"
|
34
|
+
metric = "resource.template.list"
|
35
|
+
__res = call_api(request=EndpointTypes.get, url=url, headers=headers)
|
36
|
+
click.echo(
|
37
|
+
template_list_response(
|
38
|
+
retrieve_and_validate_response_send_metric(__res, metric)
|
39
|
+
)
|
40
|
+
)
|
41
|
+
|
42
|
+
|
43
|
+
@resource_group.command("list", cls=CustomCommand)
|
44
|
+
@click.option(
|
45
|
+
"-d", "--detailed", "detailed", type=click.BOOL, is_flag=True, default=False
|
46
|
+
)
|
47
|
+
def resource_list(detailed: bool):
|
48
|
+
"""
|
49
|
+
List all apps for user namespace.
|
50
|
+
"""
|
51
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
52
|
+
url = f"{api_url}/v1/api/resource/list"
|
53
|
+
metric = "resource.list"
|
54
|
+
__res = call_api(
|
55
|
+
request=EndpointTypes.get,
|
56
|
+
url=url,
|
57
|
+
headers=headers,
|
58
|
+
)
|
59
|
+
table = compute_list_response(
|
60
|
+
detailed,
|
61
|
+
retrieve_and_validate_response_send_metric(__res, metric),
|
62
|
+
)
|
63
|
+
|
64
|
+
click.echo(table)
|
65
|
+
|
66
|
+
|
67
|
+
@resource_group.command("get_start_path", cls=CustomCommand)
|
68
|
+
@click.argument(
|
69
|
+
"template", type=click.Choice([*EntityList.get_list(), *DatabasesList.get_list()])
|
70
|
+
)
|
71
|
+
def template_get_start_path(template: str):
|
72
|
+
"""Displays start path of specified template"""
|
73
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
74
|
+
url = f"{api_url}/v1/api/resource/get_template_start_path?template_name={template}"
|
75
|
+
metric = "resource.template.get_start_path"
|
76
|
+
__res = call_api(request=EndpointTypes.get, url=url, headers=headers)
|
77
|
+
click.echo(
|
78
|
+
template_get_start_path_response(
|
79
|
+
retrieve_and_validate_response_send_metric(__res, metric)
|
80
|
+
)
|
81
|
+
)
|
82
|
+
|
83
|
+
|
84
|
+
@resource_group.command("logs", cls=CustomCommand)
|
85
|
+
@click.argument("app_name", type=click.STRING)
|
86
|
+
def compute_logs(app_name: str):
|
87
|
+
"""Get logs of given app"""
|
88
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
89
|
+
url = f"{api_url}/v1/api/resource/get_pod_events"
|
90
|
+
metric = "resource.logs"
|
91
|
+
__payload = {"name": app_name}
|
92
|
+
__res = call_api(
|
93
|
+
request=EndpointTypes.get,
|
94
|
+
url=url,
|
95
|
+
headers=headers,
|
96
|
+
data=json.dumps(__payload),
|
97
|
+
)
|
98
|
+
click.echo(
|
99
|
+
compute_logs_response(retrieve_and_validate_response_send_metric(__res, metric))
|
100
|
+
)
|
101
|
+
|
102
|
+
|
103
|
+
@resource_group.command("restart", cls=CustomCommand)
|
104
|
+
@click.argument("name", type=click.STRING)
|
105
|
+
def compute_restart(name: str):
|
106
|
+
"""Restarts the specified app"""
|
107
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
108
|
+
url = f"{api_url}/v1/api/resource/restart"
|
109
|
+
metric = "resource.restart"
|
110
|
+
__payload = {"name": name}
|
111
|
+
__res = call_api(
|
112
|
+
request=EndpointTypes.post,
|
113
|
+
url=url,
|
114
|
+
headers=headers,
|
115
|
+
data=json.dumps(__payload),
|
116
|
+
)
|
117
|
+
click.echo(
|
118
|
+
compute_restart_response(
|
119
|
+
retrieve_and_validate_response_send_metric(__res, metric)
|
120
|
+
)
|
121
|
+
)
|
122
|
+
|
123
|
+
|
124
|
+
def resource_delete(name: str):
|
125
|
+
"""
|
126
|
+
Delete an app using backend endpoint.
|
127
|
+
\f
|
128
|
+
:param name: name of app to delete
|
129
|
+
:type name: str
|
130
|
+
"""
|
131
|
+
api_url, headers = get_api_url_and_prepare_headers()
|
132
|
+
url = f"{api_url}/v1/api/resource/delete"
|
133
|
+
metric = "resource.delete"
|
134
|
+
__payload = compute_delete_payload(name=name)
|
135
|
+
__res = call_api(
|
136
|
+
request=EndpointTypes.delete,
|
137
|
+
url=url,
|
138
|
+
headers=headers,
|
139
|
+
data=json.dumps(__payload),
|
140
|
+
)
|
141
|
+
click.echo(
|
142
|
+
compute_delete_response(
|
143
|
+
retrieve_and_validate_response_send_metric(__res, metric)
|
144
|
+
)
|
145
|
+
)
|
cgc/telemetry/basic.py
CHANGED
@@ -21,11 +21,13 @@ def telemetry_permission_set():
|
|
21
21
|
"""
|
22
22
|
while True:
|
23
23
|
permission = input(
|
24
|
-
"
|
24
|
+
"We would like to make your experience with CGC even better! :)\n\
|
25
|
+
We would like to know which commands are utilized most often and if they have finished properly. Nothing else is collected. Only raw numbers.\n\
|
26
|
+
Would you agree to send us these numbers? (YES/no) [YES]: \n"
|
25
27
|
)
|
26
|
-
if permission in ["yes", "no"]:
|
28
|
+
if permission.lower() in ["yes", "no", ""]:
|
27
29
|
break
|
28
|
-
permission = True if permission == "yes" else False
|
30
|
+
permission = True if permission == "" or permission == "yes" else False
|
29
31
|
|
30
32
|
f = open(file=ENV_FILE_PATH, mode="r")
|
31
33
|
replaced_content = f.read()
|
cgc/tests/__init__.py
CHANGED
@@ -16,7 +16,7 @@ class ResponsesData:
|
|
16
16
|
"rent_start_cost": "2023-02-03 16:25:17",
|
17
17
|
"rent_end_cost": "2023-02-09 10:15:24",
|
18
18
|
"rent_time_cost": 496207.06346,
|
19
|
-
"type": "
|
19
|
+
"type": "events_resource",
|
20
20
|
"resources": {
|
21
21
|
"name": "test",
|
22
22
|
"entity": "tensorflow-jupyter",
|
@@ -53,7 +53,7 @@ class ResponsesData:
|
|
53
53
|
"rent_start_cost": "2023-02-07 14:33:57",
|
54
54
|
"rent_end_cost": "2023-02-09 10:15:24",
|
55
55
|
"rent_time_cost": 157287.06558,
|
56
|
-
"type": "
|
56
|
+
"type": "events_resource",
|
57
57
|
"resources": {
|
58
58
|
"name": "test",
|
59
59
|
"entity": "tensorflow-jupyter",
|
@@ -73,7 +73,7 @@ class ResponsesData:
|
|
73
73
|
"rent_start_cost": "2023-02-08 13:57:02",
|
74
74
|
"rent_end_cost": "2023-02-09 10:15:24",
|
75
75
|
"rent_time_cost": 73102.066748,
|
76
|
-
"type": "
|
76
|
+
"type": "events_resource",
|
77
77
|
"resources": {
|
78
78
|
"name": "test2",
|
79
79
|
"entity": "tensorflow-jupyter",
|
@@ -93,7 +93,7 @@ class ResponsesData:
|
|
93
93
|
"rent_start_cost": "2023-02-08 14:00:13",
|
94
94
|
"rent_end_cost": "2023-02-09 10:15:24",
|
95
95
|
"rent_time_cost": 72911.068128,
|
96
|
-
"type": "
|
96
|
+
"type": "events_resource",
|
97
97
|
"resources": {
|
98
98
|
"name": "test2",
|
99
99
|
"entity": "tensorflow-jupyter",
|
@@ -113,7 +113,7 @@ class ResponsesData:
|
|
113
113
|
"rent_start_cost": "2023-02-08 15:28:08",
|
114
114
|
"rent_end_cost": "2023-02-09 10:15:24",
|
115
115
|
"rent_time_cost": 67636.069558,
|
116
|
-
"type": "
|
116
|
+
"type": "events_resource",
|
117
117
|
"resources": {
|
118
118
|
"name": "test2",
|
119
119
|
"entity": "tensorflow-jupyter",
|
@@ -167,7 +167,7 @@ class ResponsesData:
|
|
167
167
|
"rent_start_cost": "2023-02-02 15:32:50",
|
168
168
|
"rent_end_cost": "2023-02-03 15:38:32",
|
169
169
|
"rent_time_cost": 86742,
|
170
|
-
"type": "
|
170
|
+
"type": "events_resource",
|
171
171
|
"resources": {
|
172
172
|
"name": "test",
|
173
173
|
"entity": "tensorflow-jupyter",
|
@@ -187,7 +187,7 @@ class ResponsesData:
|
|
187
187
|
"rent_start_cost": "2023-02-03 15:38:53",
|
188
188
|
"rent_end_cost": "2023-02-03 16:06:05",
|
189
189
|
"rent_time_cost": 1632,
|
190
|
-
"type": "
|
190
|
+
"type": "events_resource",
|
191
191
|
"resources": {
|
192
192
|
"name": "test",
|
193
193
|
"entity": "tensorflow-jupyter",
|
@@ -207,7 +207,7 @@ class ResponsesData:
|
|
207
207
|
"rent_start_cost": "2023-02-03 16:06:13",
|
208
208
|
"rent_end_cost": "2023-02-03 16:18:49",
|
209
209
|
"rent_time_cost": 756,
|
210
|
-
"type": "
|
210
|
+
"type": "events_resource",
|
211
211
|
"resources": {
|
212
212
|
"name": "filebrowser",
|
213
213
|
"entity": "tensorflow-jupyter",
|
@@ -227,7 +227,7 @@ class ResponsesData:
|
|
227
227
|
"rent_start_cost": "2023-02-03 16:30:11",
|
228
228
|
"rent_end_cost": "2023-02-03 16:33:25",
|
229
229
|
"rent_time_cost": 194,
|
230
|
-
"type": "
|
230
|
+
"type": "events_resource",
|
231
231
|
"resources": {
|
232
232
|
"name": "test3",
|
233
233
|
"entity": "tensorflow-jupyter",
|
@@ -264,7 +264,7 @@ class ResponsesData:
|
|
264
264
|
"rent_start_cost": "2023-02-02 14:03:20",
|
265
265
|
"rent_end_cost": "2023-02-08 14:00:06",
|
266
266
|
"rent_time_cost": 518206,
|
267
|
-
"type": "
|
267
|
+
"type": "events_resource",
|
268
268
|
"resources": {
|
269
269
|
"name": "test2",
|
270
270
|
"entity": "nvidia-pytorch",
|
@@ -284,7 +284,7 @@ class ResponsesData:
|
|
284
284
|
"rent_start_cost": "2023-02-03 16:30:03",
|
285
285
|
"rent_end_cost": "2023-02-08 15:27:22",
|
286
286
|
"rent_time_cost": 428239,
|
287
|
-
"type": "
|
287
|
+
"type": "events_resource",
|
288
288
|
"resources": {
|
289
289
|
"name": "test2",
|
290
290
|
"entity": "tensorflow-jupyter",
|
@@ -343,7 +343,7 @@ class ResponsesData:
|
|
343
343
|
"rent_start_cost": "2023-02-05 14:50:48",
|
344
344
|
"rent_end_cost": "2023-02-05 14:52:26",
|
345
345
|
"rent_time_cost": 98,
|
346
|
-
"type": "
|
346
|
+
"type": "events_resource",
|
347
347
|
"resources": {
|
348
348
|
"name": "test1",
|
349
349
|
"entity": "nvidia-pytorch",
|
@@ -363,7 +363,7 @@ class ResponsesData:
|
|
363
363
|
"rent_start_cost": "2023-02-05 14:54:49",
|
364
364
|
"rent_end_cost": "2023-02-07 14:13:51",
|
365
365
|
"rent_time_cost": 170342,
|
366
|
-
"type": "
|
366
|
+
"type": "events_resource",
|
367
367
|
"resources": {
|
368
368
|
"name": "test1",
|
369
369
|
"entity": "nvidia-pytorch",
|
@@ -380,7 +380,7 @@ class ResponsesData:
|
|
380
380
|
},
|
381
381
|
],
|
382
382
|
},
|
383
|
-
"message": "{'namespace': 'pytest', 'cost_total': 75665.4, 'details': [{'user_id': 'e57c8668-6bc3-47c7-85de-903bfc3772b7', 'details': [{'rent_start': '2023-02-03 16:25:17', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 496207.06346, 'rent_start_cost': '2023-02-03 16:25:17', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 496207.06346, 'type': '
|
383
|
+
"message": "{'namespace': 'pytest', 'cost_total': 75665.4, 'details': [{'user_id': 'e57c8668-6bc3-47c7-85de-903bfc3772b7', 'details': [{'rent_start': '2023-02-03 16:25:17', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 496207.06346, 'rent_start_cost': '2023-02-03 16:25:17', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 496207.06346, 'type': 'events_resource', 'resources': {'name': 'test', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 1, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dd356cc037717bc2322053', 'tid_end': None, 'cost_total': 1654.0}, {'rent_start': '2023-02-03 16:58:38', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 494206.064514, 'rent_start_cost': '2023-02-03 16:58:38', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 494206.064514, 'type': 'events_volume', 'resources': {'name': 'test2', 'disks_type': 'ssd', 'size': 1.0}, 'tid_start': '63dd3d3dc037717bc2322069', 'tid_end': None, 'cost_total': 823.7}, {'rent_start': '2023-02-07 14:33:57', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 157287.06558, 'rent_start_cost': '2023-02-07 14:33:57', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 157287.06558, 'type': 'events_resource', 'resources': {'name': 'test', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63e26155c037717bc232208b', 'tid_end': None, 'cost_total': 786.3000000000001}, {'rent_start': '2023-02-08 13:57:02', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 73102.066748, 'rent_start_cost': '2023-02-08 13:57:02', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 73102.066748, 'type': 'events_resource', 'resources': {'name': 'test2', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63e3aa2dc037717bc2322097', 'tid_end': None, 'cost_total': 365.40000000000003}, {'rent_start': '2023-02-08 14:00:13', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 72911.068128, 'rent_start_cost': '2023-02-08 14:00:13', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 72911.068128, 'type': 'events_resource', 'resources': {'name': 'test2', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63e3aaecc037717bc232209c', 'tid_end': None, 'cost_total': 364.5}, {'rent_start': '2023-02-08 15:28:08', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 67636.069558, 'rent_start_cost': '2023-02-08 15:28:08', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 67636.069558, 'type': 'events_resource', 'resources': {'name': 'test2', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63e3bf88c037717bc23220a1', 'tid_end': None, 'cost_total': 338.1}, {'rent_start': '2023-02-02 15:24:01', 'rent_end': '2023-02-02 15:26:23', 'rent_time': 142.0, 'rent_start_cost': '2023-02-02 15:24:01', 'rent_end_cost': '2023-02-02 15:26:23', 'rent_time_cost': 142.0, 'type': 'events_volume', 'resources': {'name': 'duzy', 'disks_type': 'ssd', 'size': 1.0}, 'tid_start': '63dbd597c037717bc232200a', 'tid_end': '63dbd61fc037717bc232200d', 'cost_total': 0.2}, {'rent_start': '2023-02-02 15:40:52', 'rent_end': '2023-02-02 15:44:50', 'rent_time': 238.0, 'rent_start_cost': '2023-02-02 15:40:52', 'rent_end_cost': '2023-02-02 15:44:50', 'rent_time_cost': 238.0, 'type': 'events_volume', 'resources': {'name': 'duzy', 'disks_type': 'ssd', 'size': 1.0}, 'tid_start': '63dbd983c037717bc2322015', 'tid_end': '63dbda71c037717bc2322019', 'cost_total': 0.4}, {'rent_start': '2023-02-02 15:32:50', 'rent_end': '2023-02-03 15:38:32', 'rent_time': 86742.0, 'rent_start_cost': '2023-02-02 15:32:50', 'rent_end_cost': '2023-02-03 15:38:32', 'rent_time_cost': 86742.0, 'type': 'events_resource', 'resources': {'name': 'test', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 1, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dbd7a1c037717bc232200f', 'tid_end': '63dd2a77c037717bc2322041', 'cost_total': 289.2}, {'rent_start': '2023-02-03 15:38:53', 'rent_end': '2023-02-03 16:06:05', 'rent_time': 1632.0, 'rent_start_cost': '2023-02-03 15:38:53', 'rent_end_cost': '2023-02-03 16:06:05', 'rent_time_cost': 1632.0, 'type': 'events_resource', 'resources': {'name': 'test', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dd2a8dc037717bc2322043', 'tid_end': '63dd30edc037717bc232204b', 'cost_total': 8.100000000000001}, {'rent_start': '2023-02-03 16:06:13', 'rent_end': '2023-02-03 16:18:49', 'rent_time': 756.0, 'rent_start_cost': '2023-02-03 16:06:13', 'rent_end_cost': '2023-02-03 16:18:49', 'rent_time_cost': 756.0, 'type': 'events_resource', 'resources': {'name': 'filebrowser', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 1, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dd30f4c037717bc232204d', 'tid_end': '63dd33e8c037717bc2322050', 'cost_total': 2.6}, {'rent_start': '2023-02-03 16:30:11', 'rent_end': '2023-02-03 16:33:25', 'rent_time': 194.0, 'rent_start_cost': '2023-02-03 16:30:11', 'rent_end_cost': '2023-02-03 16:33:25', 'rent_time_cost': 194.0, 'type': 'events_resource', 'resources': {'name': 'test3', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 1, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dd3692c037717bc232205b', 'tid_end': '63dd3754c037717bc232205e', 'cost_total': 0.6000000000000001}, {'rent_start': '2023-02-03 16:53:52', 'rent_end': '2023-02-03 16:58:32', 'rent_time': 280.0, 'rent_start_cost': '2023-02-03 16:53:52', 'rent_end_cost': '2023-02-03 16:58:32', 'rent_time_cost': 280.0, 'type': 'events_volume', 'resources': {'name': 'test2', 'disks_type': 'ssd', 'size': 1.0}, 'tid_start': '63dd3c20c037717bc2322063', 'tid_end': '63dd3d38c037717bc2322067', 'cost_total': 0.5}, {'rent_start': '2023-02-02 14:03:20', 'rent_end': '2023-02-08 14:00:06', 'rent_time': 518206.0, 'rent_start_cost': '2023-02-02 14:03:20', 'rent_end_cost': '2023-02-08 14:00:06', 'rent_time_cost': 518206.0, 'type': 'events_resource', 'resources': {'name': 'test2', 'entity': 'nvidia-pytorch', 'cpu': 1, 'memory': 1, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dbc2a8c037717bc2322001', 'tid_end': '63e3aae6c037717bc232209a', 'cost_total': 1727.4}, {'rent_start': '2023-02-03 16:30:03', 'rent_end': '2023-02-08 15:27:22', 'rent_time': 428239.0, 'rent_start_cost': '2023-02-03 16:30:03', 'rent_end_cost': '2023-02-08 15:27:22', 'rent_time_cost': 428239.0, 'type': 'events_resource', 'resources': {'name': 'test2', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 1, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dd368ac037717bc2322058', 'tid_end': '63e3bf59c037717bc232209f', 'cost_total': 1427.4}]}, {'user_id': '9a8b327c-1f27-4d79-a387-071cd0954cf9', 'details': [{'rent_start': '2023-01-03 12:40:08', 'rent_end': '2023-02-09 10:15:24', 'rent_time': 3188116.118518, 'rent_start_cost': '2023-02-01 00:00:00', 'rent_end_cost': '2023-02-09 10:15:24', 'rent_time_cost': 728124.118518, 'type': 'events_volume', 'resources': {'name': 'test', 'disks_type': 'ssd', 'size': 1}, 'tid_start': '63dd00a8c037717bc232201d', 'tid_end': None, 'cost_total': 24270}, {'rent_start': '2023-02-04 09:08:29', 'rent_end': '2023-02-04 17:24:09', 'rent_time': 29740.0, 'rent_start_cost': '2023-02-04 09:08:29', 'rent_end_cost': '2023-02-04 17:24:09', 'rent_time_cost': 29740.0, 'type': 'events_volume', 'resources': {'name': 'test1', 'disks_type': 'ssd', 'size': 1.0}, 'tid_start': '63de208cc037717bc232206c', 'tid_end': '63de94b9c037717bc232206f', 'cost_total': 992.0}, {'rent_start': '2023-02-05 14:50:48', 'rent_end': '2023-02-05 14:52:26', 'rent_time': 98.0, 'rent_start_cost': '2023-02-05 14:50:48', 'rent_end_cost': '2023-02-05 14:52:26', 'rent_time_cost': 98.0, 'type': 'events_resource', 'resources': {'name': 'test1', 'entity': 'nvidia-pytorch', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dfc248c037717bc2322079', 'tid_end': '63dfc2a9c037717bc232207c', 'cost_total': 30}, {'rent_start': '2023-02-05 14:54:49', 'rent_end': '2023-02-07 14:13:51', 'rent_time': 170342.0, 'rent_start_cost': '2023-02-05 14:54:49', 'rent_end_cost': '2023-02-07 14:13:51', 'rent_time_cost': 170342.0, 'type': 'events_resource', 'resources': {'name': 'test1', 'entity': 'nvidia-pytorch', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63dfc338c037717bc232207e', 'tid_end': '63e25c9fc037717bc2322083', 'cost_total': 42585}]}]}",
|
384
384
|
"code": 200,
|
385
385
|
"time_stamp": "2023-02-09 12:28:28 ",
|
386
386
|
}
|
@@ -407,7 +407,7 @@ class ResponsesData:
|
|
407
407
|
"rent_start_cost": "2023-01-01 00:00:00",
|
408
408
|
"rent_end_cost": "2023-01-13 11:50:18",
|
409
409
|
"rent_time_cost": 1079418,
|
410
|
-
"type": "
|
410
|
+
"type": "events_resource",
|
411
411
|
"resources": {
|
412
412
|
"name": "test",
|
413
413
|
"entity": "tensorflow-jupyter",
|
@@ -427,7 +427,7 @@ class ResponsesData:
|
|
427
427
|
"rent_start_cost": "2023-01-16 12:01:17",
|
428
428
|
"rent_end_cost": "2023-01-16 13:09:10",
|
429
429
|
"rent_time_cost": 4073,
|
430
|
-
"type": "
|
430
|
+
"type": "events_resource",
|
431
431
|
"resources": {
|
432
432
|
"name": "test1",
|
433
433
|
"entity": "datascience-jupyter",
|
@@ -447,7 +447,7 @@ class ResponsesData:
|
|
447
447
|
"rent_start_cost": "2023-01-16 11:59:47",
|
448
448
|
"rent_end_cost": "2023-01-16 13:16:21",
|
449
449
|
"rent_time_cost": 4594,
|
450
|
-
"type": "
|
450
|
+
"type": "events_resource",
|
451
451
|
"resources": {
|
452
452
|
"name": "test12",
|
453
453
|
"entity": "datascience-jupyter",
|
@@ -467,7 +467,7 @@ class ResponsesData:
|
|
467
467
|
"rent_start_cost": "2023-01-16 12:49:05",
|
468
468
|
"rent_end_cost": "2023-01-16 13:16:30",
|
469
469
|
"rent_time_cost": 1645,
|
470
|
-
"type": "
|
470
|
+
"type": "events_resource",
|
471
471
|
"resources": {
|
472
472
|
"name": "test12324",
|
473
473
|
"entity": "datascience-jupyter",
|
@@ -487,7 +487,7 @@ class ResponsesData:
|
|
487
487
|
"rent_start_cost": "2023-01-16 13:09:59",
|
488
488
|
"rent_end_cost": "2023-01-16 13:16:41",
|
489
489
|
"rent_time_cost": 402,
|
490
|
-
"type": "
|
490
|
+
"type": "events_resource",
|
491
491
|
"resources": {
|
492
492
|
"name": "test123243222",
|
493
493
|
"entity": "datascience-jupyter",
|
@@ -507,7 +507,7 @@ class ResponsesData:
|
|
507
507
|
"rent_start_cost": "2023-01-16 13:17:57",
|
508
508
|
"rent_end_cost": "2023-01-16 13:40:29",
|
509
509
|
"rent_time_cost": 1352,
|
510
|
-
"type": "
|
510
|
+
"type": "events_resource",
|
511
511
|
"resources": {
|
512
512
|
"name": "test5",
|
513
513
|
"entity": "datascience-jupyter",
|
@@ -527,7 +527,7 @@ class ResponsesData:
|
|
527
527
|
"rent_start_cost": "2023-01-16 13:28:41",
|
528
528
|
"rent_end_cost": "2023-01-16 13:40:32",
|
529
529
|
"rent_time_cost": 711,
|
530
|
-
"type": "
|
530
|
+
"type": "events_resource",
|
531
531
|
"resources": {
|
532
532
|
"name": "test6",
|
533
533
|
"entity": "datascience-jupyter",
|
@@ -547,7 +547,7 @@ class ResponsesData:
|
|
547
547
|
"rent_start_cost": "2023-01-16 13:38:10",
|
548
548
|
"rent_end_cost": "2023-01-16 13:40:35",
|
549
549
|
"rent_time_cost": 145,
|
550
|
-
"type": "
|
550
|
+
"type": "events_resource",
|
551
551
|
"resources": {
|
552
552
|
"name": "test7",
|
553
553
|
"entity": "datascience-jupyter",
|
@@ -567,7 +567,7 @@ class ResponsesData:
|
|
567
567
|
"rent_start_cost": "2023-01-16 11:06:03",
|
568
568
|
"rent_end_cost": "2023-01-16 13:40:46",
|
569
569
|
"rent_time_cost": 9283,
|
570
|
-
"type": "
|
570
|
+
"type": "events_resource",
|
571
571
|
"resources": {
|
572
572
|
"name": "test",
|
573
573
|
"entity": "datascience-jupyter",
|
@@ -610,7 +610,7 @@ class ResponsesData:
|
|
610
610
|
],
|
611
611
|
"date_requested": {"year": 2023, "month": 1},
|
612
612
|
},
|
613
|
-
"message": "{'namespace': 'pytest', 'cost_total': 87508.3, 'invoice': [{'user_id': 'e57c8668-6bc3-47c7-85de-903bfc3772b7', 'month': 1, 'year': 2023, 'cost_total': 5508.300000000001, 'details': [{'rent_start': '2022-12-09 10:23:04', 'rent_end': '2023-01-13 11:50:18', 'rent_time': 3029234.0, 'rent_start_cost': '2023-01-01 00:00:00', 'rent_end_cost': '2023-01-13 11:50:18', 'rent_time_cost': 1079418.0, 'type': '
|
613
|
+
"message": "{'namespace': 'pytest', 'cost_total': 87508.3, 'invoice': [{'user_id': 'e57c8668-6bc3-47c7-85de-903bfc3772b7', 'month': 1, 'year': 2023, 'cost_total': 5508.300000000001, 'details': [{'rent_start': '2022-12-09 10:23:04', 'rent_end': '2023-01-13 11:50:18', 'rent_time': 3029234.0, 'rent_start_cost': '2023-01-01 00:00:00', 'rent_end_cost': '2023-01-13 11:50:18', 'rent_time_cost': 1079418.0, 'type': 'events_resource', 'resources': {'name': 'test', 'entity': 'tensorflow-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63930c8a0fd5a2fe98fe5d51', 'tid_end': '63c14579c037717bc2321fad', 'cost_total': 5397.0}, {'rent_start': '2023-01-16 12:01:17', 'rent_end': '2023-01-16 13:09:10', 'rent_time': 4073.0, 'rent_start_cost': '2023-01-16 12:01:17', 'rent_end_cost': '2023-01-16 13:09:10', 'rent_time_cost': 4073.0, 'type': 'events_resource', 'resources': {'name': 'test1', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c53c8cc037717bc2321fc6', 'tid_end': '63c54c75c037717bc2321fd5', 'cost_total': 20.400000000000002}, {'rent_start': '2023-01-16 11:59:47', 'rent_end': '2023-01-16 13:16:21', 'rent_time': 4594.0, 'rent_start_cost': '2023-01-16 11:59:47', 'rent_end_cost': '2023-01-16 13:16:21', 'rent_time_cost': 4594.0, 'type': 'events_resource', 'resources': {'name': 'test12', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c53c32c037717bc2321fc4', 'tid_end': '63c54e25c037717bc2321fe0', 'cost_total': 23.1}, {'rent_start': '2023-01-16 12:49:05', 'rent_end': '2023-01-16 13:16:30', 'rent_time': 1645.0, 'rent_start_cost': '2023-01-16 12:49:05', 'rent_end_cost': '2023-01-16 13:16:30', 'rent_time_cost': 1645.0, 'type': 'events_resource', 'resources': {'name': 'test12324', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c547c1c037717bc2321fcb', 'tid_end': '63c54e2dc037717bc2321fe4', 'cost_total': 8.100000000000001}, {'rent_start': '2023-01-16 13:09:59', 'rent_end': '2023-01-16 13:16:41', 'rent_time': 402.0, 'rent_start_cost': '2023-01-16 13:09:59', 'rent_end_cost': '2023-01-16 13:16:41', 'rent_time_cost': 402.0, 'type': 'events_resource', 'resources': {'name': 'test123243222', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c54ca6c037717bc2321fd6', 'tid_end': '63c54e38c037717bc2321fe6', 'cost_total': 2.1}, {'rent_start': '2023-01-16 13:17:57', 'rent_end': '2023-01-16 13:40:29', 'rent_time': 1352.0, 'rent_start_cost': '2023-01-16 13:17:57', 'rent_end_cost': '2023-01-16 13:40:29', 'rent_time_cost': 1352.0, 'type': 'events_resource', 'resources': {'name': 'test5', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c54e85c037717bc2321fe8', 'tid_end': '63c553ccc037717bc2321ff5', 'cost_total': 6.9}, {'rent_start': '2023-01-16 13:28:41', 'rent_end': '2023-01-16 13:40:32', 'rent_time': 711.0, 'rent_start_cost': '2023-01-16 13:28:41', 'rent_end_cost': '2023-01-16 13:40:32', 'rent_time_cost': 711.0, 'type': 'events_resource', 'resources': {'name': 'test6', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c55109c037717bc2321feb', 'tid_end': '63c553d0c037717bc2321ff7', 'cost_total': 3.6000000000000005}, {'rent_start': '2023-01-16 13:38:10', 'rent_end': '2023-01-16 13:40:35', 'rent_time': 145.0, 'rent_start_cost': '2023-01-16 13:38:10', 'rent_end_cost': '2023-01-16 13:40:35', 'rent_time_cost': 145.0, 'type': 'events_resource', 'resources': {'name': 'test7', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c55341c037717bc2321ff2', 'tid_end': '63c553d3c037717bc2321ff9', 'cost_total': 0.6000000000000001}, {'rent_start': '2023-01-16 11:06:03', 'rent_end': '2023-01-16 13:40:46', 'rent_time': 9283.0, 'rent_start_cost': '2023-01-16 11:06:03', 'rent_end_cost': '2023-01-16 13:40:46', 'rent_time_cost': 9283.0, 'type': 'events_resource', 'resources': {'name': 'test', 'entity': 'datascience-jupyter', 'cpu': 1, 'memory': 2, 'gpu': 0, 'gpu_type': None}, 'tid_start': '63c52f9bc037717bc2321fb5', 'tid_end': '63c553ddc037717bc2321ffb', 'cost_total': 46.5}]}, {'user_id': '9a8b327c-1f27-4d79-a387-071cd0954cf9', 'month': 1, 'year': 2023, 'cost_total': 82000, 'details': [{'rent_start': '2023-01-03 12:40:08', 'rent_end': '2023-02-09 10:19:06', 'rent_time': 3188338.545678, 'rent_start_cost': '2023-01-03 12:40:08', 'rent_end_cost': '2023-01-31 23:59:59', 'rent_time_cost': 2459991.0, 'type': 'events_volume', 'resources': {'name': 'test', 'disks_type': 'ssd', 'size': 1}, 'tid_start': '63dd00a8c037717bc232201d', 'tid_end': None, 'cost_total': 82000}]}], 'date_requested': {'year': 2023, 'month': 1}}",
|
614
614
|
"code": 200,
|
615
615
|
"time_stamp": "2023-02-10 10:58:38 ",
|
616
616
|
},
|
@@ -640,7 +640,7 @@ class ResponsesData:
|
|
640
640
|
"time_stamp": "2023-02-10 11:01:44 ",
|
641
641
|
},
|
642
642
|
)
|
643
|
-
|
643
|
+
test_billing_stop_events_resource = {
|
644
644
|
"status": "Success",
|
645
645
|
"reason": "LIST_COMPUTE_STOP_EVENTS",
|
646
646
|
"details": {
|
@@ -684,7 +684,7 @@ class ResponsesData:
|
|
684
684
|
"code": 200,
|
685
685
|
"time_stamp": "2023-02-06 13:28:39 ",
|
686
686
|
}
|
687
|
-
|
687
|
+
test_billing_no_stop_events_resource = {
|
688
688
|
"status": "Success",
|
689
689
|
"reason": "LIST_COMPUTE_STOP_EVENTS",
|
690
690
|
"details": {"event_list": []},
|
@@ -843,7 +843,7 @@ class ResponsesData:
|
|
843
843
|
}
|
844
844
|
test_compute_template_list = {
|
845
845
|
"status": "Success",
|
846
|
-
"reason": "
|
846
|
+
"reason": "RESOURCE_LIST_AVAILABLE_TEMPLATES",
|
847
847
|
"details": {
|
848
848
|
"namespace": "pytest",
|
849
849
|
"available_templates_list": [
|
@@ -937,7 +937,7 @@ class ResponsesData:
|
|
937
937
|
}
|
938
938
|
test_compute_list_empty = {
|
939
939
|
"status": "Success",
|
940
|
-
"reason": "
|
940
|
+
"reason": "RESOURCE_LIST",
|
941
941
|
"details": {
|
942
942
|
"namespace": "pytest",
|
943
943
|
"pods_list": [],
|
@@ -948,7 +948,7 @@ class ResponsesData:
|
|
948
948
|
}
|
949
949
|
test_compute_list_no_labels = {
|
950
950
|
"status": "Success",
|
951
|
-
"reason": "
|
951
|
+
"reason": "RESOURCE_LIST",
|
952
952
|
"details": {
|
953
953
|
"namespace": "comtegra",
|
954
954
|
"pods_list": [
|
@@ -1521,7 +1521,7 @@ class ResponsesData:
|
|
1521
1521
|
]
|
1522
1522
|
test_compute_list = {
|
1523
1523
|
"status": "Success",
|
1524
|
-
"reason": "
|
1524
|
+
"reason": "RESOURCE_LIST",
|
1525
1525
|
"details": {
|
1526
1526
|
"namespace": "pytest",
|
1527
1527
|
"pods_list": [
|
@@ -1785,14 +1785,14 @@ class DesiredResponsesData:
|
|
1785
1785
|
test_billing_status = get_desired_response_data("test_billing_status.txt")
|
1786
1786
|
test_billing_invoice = get_desired_response_data("test_billing_invoice.txt")
|
1787
1787
|
test_billing_invoice_empty = "[33mNo invoice found for 11.2022.[0m"
|
1788
|
-
|
1789
|
-
"
|
1788
|
+
test_billing_stop_events_resource = get_desired_response_data(
|
1789
|
+
"test_billing_stop_events_resource.txt"
|
1790
1790
|
)
|
1791
1791
|
test_billing_stop_events_volume = get_desired_response_data(
|
1792
1792
|
"test_billing_stop_events_volume.txt"
|
1793
1793
|
)
|
1794
1794
|
test_billing_no_stop_events_volume = "[33mNo volume stop events to list.[0m"
|
1795
|
-
|
1795
|
+
test_billing_no_stop_events_resource = "[33mNo compute stop events to list.[0m"
|
1796
1796
|
test_volume_list = get_desired_response_data("test_volume_list.txt")
|
1797
1797
|
test_volume_list_empty = "[33mNo volumes to list.[0m"
|
1798
1798
|
test_volume_create = (
|
@@ -1816,7 +1816,7 @@ class DesiredResponsesData:
|
|
1816
1816
|
"nvidia-pytorch app test1 creation started!\n"
|
1817
1817
|
"Will be accessible at: https://test1.pytest.dev.quantdevlabs.com\n"
|
1818
1818
|
"App token: 1ce03c31ab9c40df8594d97b301eaaea\n"
|
1819
|
-
"To monitor the startup status use command: cgc
|
1819
|
+
"To monitor the startup status use command: cgc resource list"
|
1820
1820
|
)
|
1821
1821
|
test_compute_create_no_volume_found = "[33mVolume name not found in namespace.[0m"
|
1822
1822
|
test_compute_delete = "App test1 and its service successfully deleted."
|
cgc/tests/responses_tests.py
CHANGED
@@ -20,7 +20,7 @@ from cgc.commands.compute.compute_responses import (
|
|
20
20
|
from cgc.commands.billing.billing_responses import (
|
21
21
|
billing_status_response,
|
22
22
|
billing_invoice_response,
|
23
|
-
|
23
|
+
stop_events_resource_response,
|
24
24
|
stop_events_volume_response,
|
25
25
|
)
|
26
26
|
from cgc.utils.response_utils import (
|
@@ -130,11 +130,11 @@ class TestBillingResponses(unittest.TestCase):
|
|
130
130
|
result = billing_invoice_response(*ResponsesData.test_billing_invoice_empty)
|
131
131
|
self.assertEqual(result, DesiredResponsesData.test_billing_invoice_empty)
|
132
132
|
|
133
|
-
def
|
134
|
-
result =
|
135
|
-
ResponsesData.
|
133
|
+
def test_billing_stop_events_resource(self):
|
134
|
+
result = stop_events_resource_response(
|
135
|
+
ResponsesData.test_billing_stop_events_resource
|
136
136
|
)
|
137
|
-
self.assertEqual(result, DesiredResponsesData.
|
137
|
+
self.assertEqual(result, DesiredResponsesData.test_billing_stop_events_resource)
|
138
138
|
|
139
139
|
def test_billing_stop_events_volume(self):
|
140
140
|
result = stop_events_volume_response(
|
@@ -150,12 +150,12 @@ class TestBillingResponses(unittest.TestCase):
|
|
150
150
|
result, DesiredResponsesData.test_billing_no_stop_events_volume
|
151
151
|
)
|
152
152
|
|
153
|
-
def
|
154
|
-
result =
|
155
|
-
ResponsesData.
|
153
|
+
def test_billing_no_stop_events_resource(self):
|
154
|
+
result = stop_events_resource_response(
|
155
|
+
ResponsesData.test_billing_no_stop_events_resource
|
156
156
|
)
|
157
157
|
self.assertEqual(
|
158
|
-
result, DesiredResponsesData.
|
158
|
+
result, DesiredResponsesData.test_billing_no_stop_events_resource
|
159
159
|
)
|
160
160
|
|
161
161
|
|
@@ -12,5 +12,6 @@ OUTDATED_MINOR = "There is a new release available, consider updating the applic
|
|
12
12
|
OUTDATED_MAJOR = (
|
13
13
|
"You are using outdated version of cgcsdk, please update to the latest version."
|
14
14
|
)
|
15
|
-
UNAUTHORIZED_ERROR = "Unauthorized. Please check your API key and secret key or contact support at support@comtegra.pl
|
16
|
-
DISABLED_ERROR = "Account has been disabled. If you require assistance, please contact support at support@comtegra.pl
|
15
|
+
UNAUTHORIZED_ERROR = "Unauthorized. Please check your API key and secret key or contact support at support@comtegra.pl"
|
16
|
+
DISABLED_ERROR = "Account has been disabled. If you require assistance, please contact support at support@comtegra.pl"
|
17
|
+
ENDPOINT_DISABLED = "Endpoint is currently disabled, please try again later or contact support for additional information at support@comtegra.pl"
|
cgc/utils/response_utils.py
CHANGED
@@ -10,6 +10,7 @@ from cgc.utils.consts.message_consts import (
|
|
10
10
|
UNKNOWN_ERROR,
|
11
11
|
UNAUTHORIZED_ERROR,
|
12
12
|
DISABLED_ERROR,
|
13
|
+
ENDPOINT_DISABLED,
|
13
14
|
)
|
14
15
|
from cgc.utils.custom_exceptions import CUSTOM_EXCEPTIONS
|
15
16
|
from cgc.telemetry.basic import increment_metric
|
@@ -46,14 +47,16 @@ def retrieve_and_validate_response_send_metric(
|
|
46
47
|
return response.json()
|
47
48
|
else:
|
48
49
|
return response
|
49
|
-
response_json = response.json()
|
50
50
|
click.echo(prepare_error_message(f"Error code: {response.status_code}"))
|
51
51
|
if response.status_code == 401:
|
52
52
|
click.echo(prepare_error_message(UNAUTHORIZED_ERROR))
|
53
|
+
elif response.status_code == 302:
|
54
|
+
click.echo(prepare_error_message(ENDPOINT_DISABLED))
|
53
55
|
elif response.status_code == 403:
|
54
56
|
click.echo(prepare_error_message(DISABLED_ERROR))
|
55
57
|
else:
|
56
58
|
try:
|
59
|
+
response_json = response.json()
|
57
60
|
click.echo(
|
58
61
|
prepare_error_message(
|
59
62
|
CUSTOM_EXCEPTIONS[response.status_code][response_json["reason"]]
|
@@ -66,13 +69,12 @@ def retrieve_and_validate_response_send_metric(
|
|
66
69
|
else:
|
67
70
|
pp = pprint.PrettyPrinter(indent=2, width=60, compact=True)
|
68
71
|
pp.pprint(prepare_error_message(error_message))
|
69
|
-
|
70
|
-
increment_metric(
|
71
|
-
metric=metric, is_error=False
|
72
|
-
) # ALL "VALID" error messages are not Errors
|
72
|
+
increment_metric(metric=metric, is_error=True)
|
73
73
|
sys.exit()
|
74
74
|
|
75
|
-
increment_metric(
|
75
|
+
increment_metric(
|
76
|
+
metric=metric, is_error=False
|
77
|
+
) # ALL "VALID" error messages are not Errors
|
76
78
|
sys.exit()
|
77
79
|
except (AttributeError, json.JSONDecodeError):
|
78
80
|
click.echo(prepare_error_message(f"Response reading error. {error_message}"))
|
File without changes
|