artefacts-cli 0.7.3__py3-none-any.whl → 0.9.1__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.
- artefacts/cli/__init__.py +66 -18
- artefacts/cli/app.py +209 -166
- artefacts/cli/app_containers.py +116 -24
- artefacts/cli/app_containers.pyi +3 -0
- artefacts/cli/bagparser.py +4 -0
- artefacts/cli/config.py +62 -0
- artefacts/cli/constants.py +7 -0
- artefacts/cli/containers/__init__.py +5 -5
- artefacts/cli/containers/docker_cm.py +175 -0
- artefacts/cli/containers/docker_utils.py +98 -0
- artefacts/cli/containers/utils.py +20 -8
- artefacts/cli/helpers.py +55 -0
- artefacts/cli/i18n.py +30 -0
- artefacts/cli/locales/art.pot +524 -0
- artefacts/cli/locales/base.pot +936 -0
- artefacts/cli/locales/click.pot +438 -0
- artefacts/cli/locales/ja_JP/LC_MESSAGES/artefacts.mo +0 -0
- artefacts/cli/logger.py +21 -5
- artefacts/cli/other.py +4 -0
- artefacts/cli/ros1.py +21 -6
- artefacts/cli/ros2.py +31 -15
- artefacts/cli/utils.py +8 -4
- artefacts/cli/utils_ros.py +8 -4
- artefacts/cli/version.py +2 -2
- artefacts/copava/__init__.py +1 -0
- {artefacts_cli-0.7.3.dist-info → artefacts_cli-0.9.1.dist-info}/METADATA +10 -3
- artefacts_cli-0.9.1.dist-info/RECORD +34 -0
- {artefacts_cli-0.7.3.dist-info → artefacts_cli-0.9.1.dist-info}/WHEEL +1 -1
- artefacts/cli/containers/docker.py +0 -119
- artefacts_cli-0.7.3.dist-info/RECORD +0 -24
- {artefacts_cli-0.7.3.dist-info → artefacts_cli-0.9.1.dist-info}/entry_points.txt +0 -0
- {artefacts_cli-0.7.3.dist-info → artefacts_cli-0.9.1.dist-info}/top_level.txt +0 -0
artefacts/cli/__init__.py
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
from datetime import datetime, timezone
|
1
2
|
from importlib.metadata import version, PackageNotFoundError
|
2
|
-
import
|
3
|
+
from typing import Optional
|
4
|
+
import copy
|
3
5
|
import glob
|
4
|
-
|
5
|
-
import os
|
6
|
+
import json
|
6
7
|
import math
|
8
|
+
import os
|
7
9
|
import requests
|
8
|
-
import copy
|
9
|
-
from typing import Optional
|
10
10
|
|
11
|
+
from .config import APIConf
|
12
|
+
from .i18n import localise
|
11
13
|
from .parameters import iter_grid
|
12
14
|
from .logger import logger
|
13
15
|
|
@@ -21,7 +23,13 @@ except PackageNotFoundError:
|
|
21
23
|
|
22
24
|
__version__ = get_version()
|
23
25
|
except Exception as e:
|
24
|
-
logger.warning(
|
26
|
+
logger.warning(
|
27
|
+
localise(
|
28
|
+
"Could not determine package version: {error_message}. Default to 0.0.0".format(
|
29
|
+
error_message=e
|
30
|
+
)
|
31
|
+
)
|
32
|
+
)
|
25
33
|
__version__ = "0.0.0"
|
26
34
|
|
27
35
|
|
@@ -35,7 +43,7 @@ class WarpJob:
|
|
35
43
|
def __init__(
|
36
44
|
self,
|
37
45
|
project_id,
|
38
|
-
api_conf,
|
46
|
+
api_conf: APIConf,
|
39
47
|
jobname,
|
40
48
|
jobconf,
|
41
49
|
dryrun=False,
|
@@ -86,7 +94,13 @@ class WarpJob:
|
|
86
94
|
msg = response.json()["message"]
|
87
95
|
logger.warning(msg)
|
88
96
|
raise AuthenticationError(msg)
|
89
|
-
logger.warning(
|
97
|
+
logger.warning(
|
98
|
+
localise(
|
99
|
+
"Error on job creation: {status_code}".format(
|
100
|
+
status_code=response.status_code
|
101
|
+
)
|
102
|
+
)
|
103
|
+
)
|
90
104
|
logger.warning(response.text)
|
91
105
|
raise AuthenticationError(str(response.status_code))
|
92
106
|
self.job_id = response.json()["job_id"]
|
@@ -133,6 +147,9 @@ class WarpRun:
|
|
133
147
|
self.output_path = self.params.get(
|
134
148
|
"output_path", f"{self.job.output_path}/{self.run_n}"
|
135
149
|
)
|
150
|
+
self.test_results = None
|
151
|
+
self.success = False
|
152
|
+
self.logger = logger
|
136
153
|
os.makedirs(self.output_path, exist_ok=True)
|
137
154
|
data = {
|
138
155
|
"job_id": job.job_id,
|
@@ -155,10 +172,16 @@ class WarpRun:
|
|
155
172
|
if response.status_code != 200:
|
156
173
|
if response.status_code == 403:
|
157
174
|
msg = response.json()["message"]
|
158
|
-
logger.warning(msg)
|
175
|
+
self.logger.warning(msg)
|
159
176
|
raise AuthenticationError(msg)
|
160
|
-
logger.warning(
|
161
|
-
|
177
|
+
self.logger.warning(
|
178
|
+
localise(
|
179
|
+
"Error on scenario creation: {status_code}".format(
|
180
|
+
status_code=response.status_code
|
181
|
+
)
|
182
|
+
)
|
183
|
+
)
|
184
|
+
self.logger.warning(response.text)
|
162
185
|
raise AuthenticationError(str(response.status_code))
|
163
186
|
return
|
164
187
|
|
@@ -235,8 +258,10 @@ class WarpRun:
|
|
235
258
|
|
236
259
|
def stop(self):
|
237
260
|
end = datetime.now(timezone.utc).timestamp()
|
261
|
+
|
238
262
|
if self.job.dryrun:
|
239
263
|
return
|
264
|
+
|
240
265
|
# Log metadata
|
241
266
|
data = {
|
242
267
|
"job_id": self.job.job_id,
|
@@ -247,18 +272,23 @@ class WarpRun:
|
|
247
272
|
"duration": math.ceil(end - self.start),
|
248
273
|
"tests": self.test_results,
|
249
274
|
"success": self.success,
|
250
|
-
"uploads": self.uploads,
|
251
275
|
"metrics": self.metrics,
|
252
276
|
}
|
277
|
+
if not self.job.noupload:
|
278
|
+
data["uploads"] = self.uploads
|
279
|
+
|
253
280
|
response = requests.put(
|
254
281
|
f"{self.job.api_conf.api_url}/{self.job.project_id}/job/{self.job.job_id}/run/{self.run_n}",
|
255
282
|
json=data,
|
256
283
|
headers=self.job.api_conf.headers,
|
257
284
|
)
|
285
|
+
|
258
286
|
# use s3 presigned urls to upload the artifacts
|
259
287
|
if self.job.noupload:
|
260
288
|
print(
|
261
|
-
|
289
|
+
localise(
|
290
|
+
"Files generated by the job are not uploaded to Artefacts, including the ones specified in output_dirs"
|
291
|
+
)
|
262
292
|
)
|
263
293
|
else:
|
264
294
|
upload_urls = response.json()["upload_urls"]
|
@@ -267,7 +297,13 @@ class WarpRun:
|
|
267
297
|
upload_info = upload_urls[key]
|
268
298
|
file_size_mb = os.path.getsize(file_name) / 1024 / 1024
|
269
299
|
try:
|
270
|
-
print(
|
300
|
+
print(
|
301
|
+
localise(
|
302
|
+
"Uploading {file_name} ({file_size:.2f} MB)".format(
|
303
|
+
file_name=file_name, file_size=file_size_mb
|
304
|
+
)
|
305
|
+
)
|
306
|
+
)
|
271
307
|
# TODO: add a retry policy
|
272
308
|
requests.post(
|
273
309
|
upload_info["url"],
|
@@ -275,14 +311,26 @@ class WarpRun:
|
|
275
311
|
files=files,
|
276
312
|
)
|
277
313
|
except OverflowError:
|
278
|
-
logger.warning(
|
314
|
+
self.logger.warning(
|
315
|
+
localise(
|
316
|
+
"File too large: {file_name} could not be uploaded".format(
|
317
|
+
file_name=file_name
|
318
|
+
)
|
319
|
+
)
|
320
|
+
)
|
279
321
|
except Exception as e:
|
280
|
-
logger.warning(
|
322
|
+
self.logger.warning(
|
323
|
+
localise(
|
324
|
+
"Error uploading {file_name}: {error_message}, skipping".format(
|
325
|
+
file_name=file_name, error_message=e
|
326
|
+
)
|
327
|
+
)
|
328
|
+
)
|
281
329
|
|
282
330
|
|
283
331
|
def init_job(
|
284
332
|
project_id: str,
|
285
|
-
|
333
|
+
api_conf: APIConf,
|
286
334
|
jobname: str,
|
287
335
|
jobconf: dict,
|
288
336
|
dryrun: bool = False,
|
@@ -294,7 +342,7 @@ def init_job(
|
|
294
342
|
):
|
295
343
|
return WarpJob(
|
296
344
|
project_id,
|
297
|
-
|
345
|
+
api_conf,
|
298
346
|
jobname,
|
299
347
|
jobconf,
|
300
348
|
dryrun,
|