artefacts-cli 0.6.18__py3-none-any.whl → 0.6.19__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/app_containers.py +3 -2
- artefacts/cli/containers/__init__.py +11 -11
- artefacts/cli/containers/docker.py +28 -17
- artefacts/cli/version.py +2 -2
- {artefacts_cli-0.6.18.dist-info → artefacts_cli-0.6.19.dist-info}/METADATA +1 -1
- {artefacts_cli-0.6.18.dist-info → artefacts_cli-0.6.19.dist-info}/RECORD +9 -9
- {artefacts_cli-0.6.18.dist-info → artefacts_cli-0.6.19.dist-info}/WHEEL +0 -0
- {artefacts_cli-0.6.18.dist-info → artefacts_cli-0.6.19.dist-info}/entry_points.txt +0 -0
- {artefacts_cli-0.6.18.dist-info → artefacts_cli-0.6.19.dist-info}/top_level.txt +0 -0
artefacts/cli/app_containers.py
CHANGED
@@ -85,9 +85,10 @@ def run(ctx: click.Context, image: str, jobname: str, config: str, with_gui: boo
|
|
85
85
|
image=image,
|
86
86
|
project=project,
|
87
87
|
jobname=jobname,
|
88
|
-
# Hidden setting primarily useful to Artefacts developers
|
89
|
-
api_url=os.environ.get("ARTEFACTS_API_URL", DEFAULT_API_URL),
|
90
88
|
with_gui=with_gui,
|
89
|
+
# Hidden settings primarily useful to Artefacts developers
|
90
|
+
api_url=os.environ.get("ARTEFACTS_API_URL", DEFAULT_API_URL),
|
91
|
+
api_key=os.environ.get("ARTEFACTS_KEY", None),
|
91
92
|
)
|
92
93
|
container, logs = handler.run(**params)
|
93
94
|
if container:
|
@@ -2,7 +2,7 @@ from collections.abc import Generator
|
|
2
2
|
import configparser
|
3
3
|
import os
|
4
4
|
from pathlib import Path
|
5
|
-
from typing import Any, Tuple, Union
|
5
|
+
from typing import Any, Optional, Tuple, Union
|
6
6
|
|
7
7
|
from artefacts.cli.constants import DEFAULT_API_URL
|
8
8
|
|
@@ -36,17 +36,17 @@ class CMgr:
|
|
36
36
|
"""
|
37
37
|
raise NotImplementedError()
|
38
38
|
|
39
|
-
def
|
39
|
+
def _get_artefacts_api_key(
|
40
40
|
self, project: str, path: Union[str, Path] = Path("~/.artefacts").expanduser()
|
41
|
-
) ->
|
41
|
+
) -> Optional[str]:
|
42
42
|
"""
|
43
|
-
|
43
|
+
Get any valid API key to embed in containers.
|
44
44
|
|
45
|
-
1.
|
46
|
-
2. If `path` is not given, check the default
|
47
|
-
3. If `path` is given, check the file directly
|
45
|
+
1. Checks first from the ARTEFACTS_KEY environment variable.
|
46
|
+
2. If `path` is not given, check from the default configuraiton file in the .artefacts folder.
|
47
|
+
3. If `path` is given, check the file directly if a file, or check for a `config` file if a folder.
|
48
48
|
|
49
|
-
When a config file is found, we
|
49
|
+
When a config file is found, we get the API key for the `project`.
|
50
50
|
|
51
51
|
`path` set to None is an error, and aborts execution.
|
52
52
|
"""
|
@@ -55,7 +55,7 @@ class CMgr:
|
|
55
55
|
"`path` must be a string, a Path object, or excluded from the kwargs"
|
56
56
|
)
|
57
57
|
if os.environ.get("ARTEFACTS_KEY", None):
|
58
|
-
return
|
58
|
+
return os.environ["ARTEFACTS_KEY"]
|
59
59
|
path = Path(path) # Ensure we have a Path object
|
60
60
|
config = configparser.ConfigParser()
|
61
61
|
if path.is_dir():
|
@@ -63,6 +63,6 @@ class CMgr:
|
|
63
63
|
else:
|
64
64
|
config.read(path)
|
65
65
|
try:
|
66
|
-
return config[project].get("apikey")
|
66
|
+
return config[project].get("apikey")
|
67
67
|
except KeyError:
|
68
|
-
return
|
68
|
+
return None
|
@@ -53,21 +53,35 @@ class DockerManager(CMgr):
|
|
53
53
|
jobname: str = None,
|
54
54
|
artefacts_dir: str = Path("~/.artefacts").expanduser(),
|
55
55
|
api_url: str = DEFAULT_API_URL,
|
56
|
+
api_key: str = None,
|
56
57
|
with_gui: bool = False,
|
57
58
|
) -> Tuple[Any, Generator]:
|
58
|
-
|
59
|
+
"""
|
60
|
+
Run an application as an Artefacts-enabled container in a Docker engine
|
61
|
+
|
62
|
+
The arguments are considered straightforward, except the different
|
63
|
+
priorities between `artefacts_dir` and `api_key`:
|
64
|
+
* `api_key` has the highest priority. When specified, `artefacts_dir`
|
65
|
+
is ignored. The container will rely on the key as an environment
|
66
|
+
variable (ARTEFACTS_KEY).
|
67
|
+
* Whenever `api_key` is not provided, the container gets `artefacts_dir`
|
68
|
+
mounted as volume. The directory must contain a valid configuration
|
69
|
+
with the project's key.
|
70
|
+
"""
|
71
|
+
env = {
|
72
|
+
"JOB_ID": str(uuid4()),
|
73
|
+
"ARTEFACTS_JOB_NAME": jobname,
|
74
|
+
"ARTEFACTS_API_URL": api_url,
|
75
|
+
}
|
76
|
+
|
77
|
+
env["ARTEFACTS_KEY"] = self._get_artefacts_api_key(project, artefacts_dir)
|
78
|
+
if env["ARTEFACTS_KEY"] is None:
|
59
79
|
return None, iter(
|
60
80
|
[
|
61
|
-
"Missing API key for the project. Does
|
81
|
+
f"Missing API key for the project. Does `{artefacts_dir}/config` exist and contain your key? Alternatively ARTEFACTS_KEY can be set with the key."
|
62
82
|
]
|
63
83
|
)
|
64
84
|
try:
|
65
|
-
env = {
|
66
|
-
"JOB_ID": str(uuid4()),
|
67
|
-
"ARTEFACTS_JOB_NAME": jobname,
|
68
|
-
"ARTEFACTS_API_URL": api_url,
|
69
|
-
}
|
70
|
-
|
71
85
|
if platform.system() in ["Darwin", "Windows"]:
|
72
86
|
# Assume we run in Docker Desktop
|
73
87
|
env["DISPLAY"] = "host.docker.internal:0"
|
@@ -77,24 +91,21 @@ class DockerManager(CMgr):
|
|
77
91
|
if not with_gui:
|
78
92
|
env["QT_QPA_PLATFORM"] = "offscreen"
|
79
93
|
|
80
|
-
|
81
|
-
image,
|
94
|
+
container_conf = dict(
|
95
|
+
image=image,
|
82
96
|
environment=env,
|
83
97
|
detach=False,
|
84
|
-
volumes=["/root/.artefacts"],
|
85
98
|
host_config=self.client.create_host_config(
|
86
|
-
binds={
|
87
|
-
artefacts_dir: {
|
88
|
-
"bind": "/root/.artefacts",
|
89
|
-
"mode": "ro",
|
90
|
-
},
|
91
|
-
},
|
92
99
|
network_mode="host",
|
93
100
|
),
|
94
101
|
)
|
102
|
+
|
103
|
+
container = self.client.create_container(**container_conf)
|
95
104
|
self.client.start(container=container.get("Id"))
|
105
|
+
|
96
106
|
for entry in self.client.logs(container=container.get("Id"), stream=True):
|
97
107
|
print(entry.decode("utf-8").strip())
|
108
|
+
|
98
109
|
return container, iter([])
|
99
110
|
except docker.errors.ImageNotFound:
|
100
111
|
return None, iter(
|
artefacts/cli/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: artefacts_cli
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.19
|
4
4
|
Author-email: FD <fabian@artefacts.com>, AGC <alejandro@artefacts.com>, TN <tomo@artefacts.com>, EP <eric@artefacts.com>
|
5
5
|
Project-URL: Homepage, https://github.com/art-e-fact/artefacts-client
|
6
6
|
Project-URL: Bug Tracker, https://github.com/art-e-fact/artefacts-client/issues
|
@@ -1,6 +1,6 @@
|
|
1
1
|
artefacts/cli/__init__.py,sha256=pt8OK66hMeQUxT9iLcvzYIIjFGrPS63ecWo8hS0T2qQ,11980
|
2
2
|
artefacts/cli/app.py,sha256=fHqq4N_JdSO8jgN4uc0puLSSJk_NU5srbztveipbqLw,22221
|
3
|
-
artefacts/cli/app_containers.py,sha256=
|
3
|
+
artefacts/cli/app_containers.py,sha256=dsyzN8UzGNwxkhV8BsFK7Sz9EOL6Se3YpeiUgzC2qic,3099
|
4
4
|
artefacts/cli/bagparser.py,sha256=FE_QaztC9pg4hQzTjGSdyve6mzZbHJbyqa3wqvZSbxE,3702
|
5
5
|
artefacts/cli/constants.py,sha256=bvsVDwqkAc49IZN7j6k6IL6EG87bECHd_VINtKJqbv8,320
|
6
6
|
artefacts/cli/errors.py,sha256=BiCRo3IwVjtEotaFtmwsGTZiX-TRE69KqLrEQItLsag,34
|
@@ -11,13 +11,13 @@ artefacts/cli/ros1.py,sha256=rKepZckAuy5O_qraF2CW5GiTmTZHar7LRD4pvESy6T0,9622
|
|
11
11
|
artefacts/cli/ros2.py,sha256=9Ax_WQIOV_cohKz3H1eo1LnWiahiaqxO8r99doMmhEc,4466
|
12
12
|
artefacts/cli/utils.py,sha256=bqADil7Aqvg-ci0244e-yf8G9KvIkYeWGNc_jMn6qv0,3151
|
13
13
|
artefacts/cli/utils_ros.py,sha256=3EFoMrzBdlhLc-wAL3mmS5sSw_pACkurYhssKHqYJsI,2089
|
14
|
-
artefacts/cli/version.py,sha256=
|
15
|
-
artefacts/cli/containers/__init__.py,sha256=
|
16
|
-
artefacts/cli/containers/docker.py,sha256=
|
14
|
+
artefacts/cli/version.py,sha256=ixVV8MU63NBV9smkuqL3bT6LQ9c0jfKN5D9k7wenwns,413
|
15
|
+
artefacts/cli/containers/__init__.py,sha256=K0efkJXNCqXH-qYBqhCE_8zVUCHbVmeuKH-y_fE8s4M,2254
|
16
|
+
artefacts/cli/containers/docker.py,sha256=fsGTzpj7Sj7ykCBxzaYlIt_so1yfWJ2j6ktxsWjvdvY,4073
|
17
17
|
artefacts/cli/containers/utils.py,sha256=bILX0uvazUJq7hoqKk4ztRzI_ZerYs04XQdKdx1ltjk,2002
|
18
18
|
artefacts/wrappers/artefacts_ros1_meta.launch,sha256=9tN7_0xLH8jW27KYFerhF3NuWDx2dED3ks_qoGVZAPw,1412
|
19
|
-
artefacts_cli-0.6.
|
20
|
-
artefacts_cli-0.6.
|
21
|
-
artefacts_cli-0.6.
|
22
|
-
artefacts_cli-0.6.
|
23
|
-
artefacts_cli-0.6.
|
19
|
+
artefacts_cli-0.6.19.dist-info/METADATA,sha256=Syxim3fegwldEZqVIFHy_4SmLT9z33XT6hVwQ0GqaNo,3035
|
20
|
+
artefacts_cli-0.6.19.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
21
|
+
artefacts_cli-0.6.19.dist-info/entry_points.txt,sha256=nlTXRzilNjccbi53FgaRWCQPkG-pv61HRkaCkrKjlec,58
|
22
|
+
artefacts_cli-0.6.19.dist-info/top_level.txt,sha256=FdaMV1C9m36MWa-2Stm5xVODv7hss_nRYNwR83j_7ow,10
|
23
|
+
artefacts_cli-0.6.19.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|