primitive 0.1.68__tar.gz → 0.1.69__tar.gz
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.
- {primitive-0.1.68 → primitive-0.1.69}/.vscode/settings.json +2 -0
- {primitive-0.1.68 → primitive-0.1.69}/PKG-INFO +2 -1
- {primitive-0.1.68 → primitive-0.1.69}/pyproject.toml +2 -1
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/__about__.py +1 -1
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/agent/process.py +8 -1
- primitive-0.1.69/src/primitive/agent/runner.py +246 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/agent/uploader.py +6 -7
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/cli.py +0 -4
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/client.py +5 -8
- primitive-0.1.69/src/primitive/files/actions.py +354 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/files/commands.py +4 -1
- primitive-0.1.69/src/primitive/files/graphql/fragments.py +18 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/files/graphql/mutations.py +17 -1
- primitive-0.1.69/src/primitive/files/graphql/queries.py +31 -0
- primitive-0.1.69/src/primitive/utils/auth.py +35 -0
- primitive-0.1.69/src/primitive/utils/chunk_size.py +87 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/files.py +10 -7
- {primitive-0.1.68 → primitive-0.1.69}/uv.lock +193 -177
- primitive-0.1.68/src/primitive/agent/runner.py +0 -245
- primitive-0.1.68/src/primitive/files/actions.py +0 -191
- primitive-0.1.68/src/primitive/lint/actions.py +0 -76
- primitive-0.1.68/src/primitive/lint/commands.py +0 -17
- primitive-0.1.68/src/primitive/sim/__init__.py +0 -0
- primitive-0.1.68/src/primitive/sim/actions.py +0 -129
- primitive-0.1.68/src/primitive/sim/commands.py +0 -19
- primitive-0.1.68/src/primitive/utils/__init__.py +0 -0
- primitive-0.1.68/src/primitive/utils/auth.py +0 -27
- {primitive-0.1.68 → primitive-0.1.69}/.git-hooks/pre-commit +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/.gitattributes +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/.github/workflows/lint.yml +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/.github/workflows/publish.yml +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/.gitignore +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/LICENSE.txt +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/Makefile +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/README.md +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/linux setup.md +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/agent/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/agent/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/agent/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/agent/provision.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/auth/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/auth/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/auth/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/auth/graphql/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/auth/graphql/queries.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/daemons/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/daemons/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/daemons/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/daemons/launch_agents.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/daemons/launch_service.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/exec/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/exec/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/exec/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/exec/interactive.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/files/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/files/graphql/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/git/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/git/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/git/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/git/graphql/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/git/graphql/queries.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/graphql/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/graphql/relay.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/graphql/sdk.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/graphql/utility_fragments.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/graphql/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/graphql/fragments.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/graphql/mutations.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/hardware/graphql/queries.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/commands.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/graphql/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/graphql/fragments.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/graphql/mutations.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/jobs/graphql/queries.py +0 -0
- {primitive-0.1.68/src/primitive/lint → primitive-0.1.69/src/primitive/organizations}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/organizations/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/organizations/commands.py +0 -0
- {primitive-0.1.68/src/primitive/organizations → primitive-0.1.69/src/primitive/organizations/graphql}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/organizations/graphql/fragments.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/organizations/graphql/mutations.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/organizations/graphql/queries.py +0 -0
- {primitive-0.1.68/src/primitive/organizations/graphql → primitive-0.1.69/src/primitive/projects}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/projects/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/projects/commands.py +0 -0
- {primitive-0.1.68/src/primitive/projects → primitive-0.1.69/src/primitive/projects/graphql}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/projects/graphql/fragments.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/projects/graphql/mutations.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/projects/graphql/queries.py +0 -0
- {primitive-0.1.68/src/primitive/projects/graphql → primitive-0.1.69/src/primitive/provisioning}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/provisioning/actions.py +0 -0
- {primitive-0.1.68/src/primitive/provisioning → primitive-0.1.69/src/primitive/provisioning/graphql}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/provisioning/graphql/queries.py +0 -0
- {primitive-0.1.68/src/primitive/provisioning/graphql → primitive-0.1.69/src/primitive/reservations}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/reservations/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/reservations/commands.py +0 -0
- {primitive-0.1.68/src/primitive/reservations → primitive-0.1.69/src/primitive/reservations/graphql}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/reservations/graphql/fragments.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/reservations/graphql/mutations.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/reservations/graphql/queries.py +0 -0
- {primitive-0.1.68/src/primitive/reservations/graphql → primitive-0.1.69/src/primitive/utils}/__init__.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/actions.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/cache.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/config.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/git.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/memory_size.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/printer.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/shell.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/src/primitive/utils/verible.py +0 -0
- {primitive-0.1.68 → primitive-0.1.69}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.69
|
4
4
|
Project-URL: Documentation, https://github.com//primitivecorp/primitive-cli#readme
|
5
5
|
Project-URL: Issues, https://github.com//primitivecorp/primitive-cli/issues
|
6
6
|
Project-URL: Source, https://github.com//primitivecorp/primitive-cli
|
@@ -23,6 +23,7 @@ Requires-Dist: loguru
|
|
23
23
|
Requires-Dist: paramiko[invoke]
|
24
24
|
Requires-Dist: primitive-pal==0.1.4
|
25
25
|
Requires-Dist: pyyaml
|
26
|
+
Requires-Dist: speedtest-cli
|
26
27
|
Description-Content-Type: text/markdown
|
27
28
|
|
28
29
|
# primitive
|
@@ -41,7 +41,14 @@ class Process:
|
|
41
41
|
continue
|
42
42
|
|
43
43
|
if key.fileobj is self.process.stdout:
|
44
|
-
|
44
|
+
raw_data = data.rstrip()
|
45
|
+
if "error" in raw_data.lower():
|
46
|
+
logger.error(raw_data)
|
47
|
+
self._errors += 1
|
48
|
+
elif "warning" in raw_data.lower():
|
49
|
+
logger.warning(raw_data)
|
50
|
+
else:
|
51
|
+
logger.info(raw_data)
|
45
52
|
elif key.fileobj is self.process.stderr:
|
46
53
|
logger.error(data.rstrip())
|
47
54
|
self._errors += 1
|
@@ -0,0 +1,246 @@
|
|
1
|
+
import os
|
2
|
+
import threading
|
3
|
+
import typing
|
4
|
+
import json
|
5
|
+
from pathlib import Path, PurePath
|
6
|
+
from time import sleep
|
7
|
+
from typing import Dict, Iterable, List, Optional, TypedDict, Callable
|
8
|
+
|
9
|
+
import yaml
|
10
|
+
from loguru import logger
|
11
|
+
from .process import Process
|
12
|
+
from .provision import ProvisionPython
|
13
|
+
from ..utils.cache import get_artifacts_cache, get_logs_cache
|
14
|
+
from ..utils.files import find_files_for_extension
|
15
|
+
|
16
|
+
try:
|
17
|
+
from yaml import CLoader as Loader
|
18
|
+
except ImportError:
|
19
|
+
from yaml import Loader
|
20
|
+
|
21
|
+
if typing.TYPE_CHECKING:
|
22
|
+
import primitive.client
|
23
|
+
|
24
|
+
|
25
|
+
class Artifact(TypedDict):
|
26
|
+
name: str
|
27
|
+
extension: str
|
28
|
+
|
29
|
+
|
30
|
+
class JobStep(TypedDict):
|
31
|
+
name: str
|
32
|
+
workdir: str
|
33
|
+
artifacts: List[Artifact]
|
34
|
+
cmd: str
|
35
|
+
|
36
|
+
|
37
|
+
class JobDescription(TypedDict):
|
38
|
+
name: str
|
39
|
+
provision: str
|
40
|
+
steps: List[JobStep]
|
41
|
+
|
42
|
+
|
43
|
+
class AgentRunner:
|
44
|
+
def __init__(
|
45
|
+
self,
|
46
|
+
primitive: "primitive.client.Primitive",
|
47
|
+
source_dir: Path,
|
48
|
+
job_id: str,
|
49
|
+
job_slug: str,
|
50
|
+
max_log_size: int = 10 * 1024 * 1024,
|
51
|
+
log_to_file: bool = True,
|
52
|
+
) -> None:
|
53
|
+
self.primitive = primitive
|
54
|
+
self.source_dir = source_dir
|
55
|
+
self.workdir = "."
|
56
|
+
self.job_id = job_id
|
57
|
+
self.job_slug = job_slug
|
58
|
+
self.max_log_size = max_log_size
|
59
|
+
self.log_to_file = log_to_file
|
60
|
+
|
61
|
+
# Enable and configure logger
|
62
|
+
logger.enable("primitive")
|
63
|
+
|
64
|
+
if self.log_to_file:
|
65
|
+
log_name = f"{self.job_slug}_{self.job_id}_{{time}}.primitive.log"
|
66
|
+
logger.add(
|
67
|
+
Path(get_logs_cache(self.job_id) / log_name),
|
68
|
+
rotation=self.max_log_size,
|
69
|
+
format=AgentRunner.log_serializer(),
|
70
|
+
)
|
71
|
+
|
72
|
+
# Attempt to load job from file
|
73
|
+
logger.info(f"Scanning directory for job file {self.job_slug}")
|
74
|
+
yaml_file = Path(self.source_dir / ".primitive" / f"{self.job_slug}.yaml")
|
75
|
+
yml_file = Path(self.source_dir / ".primitive" / f"{self.job_slug}.yml")
|
76
|
+
|
77
|
+
if yaml_file.exists() and yml_file.exists():
|
78
|
+
logger.error(
|
79
|
+
f"Found two job descriptions with the same slug: {self.job_slug}"
|
80
|
+
)
|
81
|
+
self.primitive.jobs.job_run_update(
|
82
|
+
self.job_id, status="request_completed", conclusion="failure"
|
83
|
+
)
|
84
|
+
raise FileExistsError
|
85
|
+
|
86
|
+
if yaml_file.exists():
|
87
|
+
self.job = yaml.load(open(yaml_file, "r"), Loader=Loader)
|
88
|
+
elif yml_file.exists():
|
89
|
+
self.job = yaml.load(open(yml_file, "r"), Loader=Loader)
|
90
|
+
else:
|
91
|
+
logger.error(
|
92
|
+
f"No job description with matching slug '{self.job_slug}' found"
|
93
|
+
)
|
94
|
+
self.primitive.jobs.job_run_update(
|
95
|
+
self.job_id, status="request_completed", conclusion="failure"
|
96
|
+
)
|
97
|
+
raise FileNotFoundError
|
98
|
+
|
99
|
+
logger.info(f"Found job description for {self.job_slug}")
|
100
|
+
|
101
|
+
@staticmethod
|
102
|
+
def log_serializer() -> Callable:
|
103
|
+
def fmt(record):
|
104
|
+
step = ""
|
105
|
+
if "step" in record["extra"]:
|
106
|
+
step = record["extra"]["step"]
|
107
|
+
|
108
|
+
log = {
|
109
|
+
"time": record["time"].strftime("%Y-%m-%d %H:%M:%S.%f"),
|
110
|
+
"utc": record["time"].strftime("%Y-%m-%d %H:%M:%S.%f%z"),
|
111
|
+
"level": record["level"].name,
|
112
|
+
"message": record["message"],
|
113
|
+
"name": record["name"],
|
114
|
+
"step": step,
|
115
|
+
}
|
116
|
+
|
117
|
+
record["extra"]["serialized"] = json.dumps(log)
|
118
|
+
|
119
|
+
return "{extra[serialized]}\n"
|
120
|
+
|
121
|
+
return fmt
|
122
|
+
|
123
|
+
def name(self) -> str:
|
124
|
+
return self.job["name"]
|
125
|
+
|
126
|
+
def steps(self) -> Iterable[JobStep]:
|
127
|
+
for step in self.job["steps"]:
|
128
|
+
yield step
|
129
|
+
|
130
|
+
def execute(self) -> None:
|
131
|
+
logger.info(f"Executing {self.job_slug} job")
|
132
|
+
self.primitive.jobs.job_run_update(self.job_id, status="request_in_progress")
|
133
|
+
|
134
|
+
# Initialize the environment with the system
|
135
|
+
environment = os.environ
|
136
|
+
if "provision" in self.job:
|
137
|
+
logger.info(f"Provisioning for {self.job['provision']} environment")
|
138
|
+
environment = self.provision()
|
139
|
+
|
140
|
+
if not environment:
|
141
|
+
self.primitive.jobs.job_run_update(
|
142
|
+
self.job_id, status="request_completed", conclusion="failure"
|
143
|
+
)
|
144
|
+
logger.error(f"{self.job_slug} concluded with error(s)")
|
145
|
+
return
|
146
|
+
|
147
|
+
total_job_errors = 0
|
148
|
+
for step in self.steps():
|
149
|
+
logger.info(f"Beginning step {step['name']}")
|
150
|
+
|
151
|
+
with logger.contextualize(step=step["name"]):
|
152
|
+
if "workdir" in step:
|
153
|
+
self.workdir = step["workdir"]
|
154
|
+
|
155
|
+
proc = Process(
|
156
|
+
cmd=step["cmd"],
|
157
|
+
workdir=Path(self.source_dir / self.workdir),
|
158
|
+
env=environment,
|
159
|
+
)
|
160
|
+
|
161
|
+
try:
|
162
|
+
proc.start()
|
163
|
+
except Exception as e:
|
164
|
+
logger.error(f"Error while attempting to run process {e}")
|
165
|
+
self.primitive.jobs.job_run_update(
|
166
|
+
self.job_id, status="request_completed", conclusion="failure"
|
167
|
+
)
|
168
|
+
logger.error(f"{self.job_slug} concluded with error(s)")
|
169
|
+
return
|
170
|
+
|
171
|
+
def status_check():
|
172
|
+
while proc.is_running():
|
173
|
+
# Check job status
|
174
|
+
status = self.primitive.jobs.get_job_status(self.job_id)
|
175
|
+
status_value = status.data["jobRun"]["status"]
|
176
|
+
|
177
|
+
# TODO: Should probably use request_cancelled or something
|
178
|
+
# once we change it, we'll have to call conclude w/ cancelled status
|
179
|
+
if status_value == "completed":
|
180
|
+
logger.warning("Job cancelled by user")
|
181
|
+
proc.terminate()
|
182
|
+
return
|
183
|
+
|
184
|
+
sleep(5)
|
185
|
+
|
186
|
+
status_thread = threading.Thread(target=status_check)
|
187
|
+
status_thread.start()
|
188
|
+
|
189
|
+
returncode = proc.wait()
|
190
|
+
total_job_errors += proc.errors
|
191
|
+
status_thread.join()
|
192
|
+
|
193
|
+
self.collect_artifacts(step)
|
194
|
+
|
195
|
+
if returncode > 0:
|
196
|
+
self.primitive.jobs.job_run_update(
|
197
|
+
self.job_id, status="request_completed", conclusion="failure"
|
198
|
+
)
|
199
|
+
logger.error(f"{self.job_slug} concluded with error(s)")
|
200
|
+
return
|
201
|
+
|
202
|
+
if total_job_errors > 0:
|
203
|
+
self.primitive.jobs.job_run_update(
|
204
|
+
self.job_id, status="request_completed", conclusion="failure"
|
205
|
+
)
|
206
|
+
logger.error(f"{self.job_slug} concluded with error(s)")
|
207
|
+
return
|
208
|
+
|
209
|
+
self.primitive.jobs.job_run_update(
|
210
|
+
self.job_id, status="request_completed", conclusion="success"
|
211
|
+
)
|
212
|
+
logger.success(f"Completed {self.job_slug} job")
|
213
|
+
|
214
|
+
def provision(self) -> Optional[Dict]:
|
215
|
+
match self.job["provision"]:
|
216
|
+
case "python":
|
217
|
+
requirements_glob = self.source_dir.rglob("requirements.txt")
|
218
|
+
|
219
|
+
requirements_path = next(requirements_glob, None)
|
220
|
+
|
221
|
+
if not requirements_path:
|
222
|
+
logger.error("Unable to locate requirements.txt")
|
223
|
+
return None
|
224
|
+
|
225
|
+
prov = ProvisionPython(self.source_dir, requirements_path)
|
226
|
+
return prov.create_env()
|
227
|
+
|
228
|
+
def collect_artifacts(self, step: JobStep) -> None:
|
229
|
+
if "artifacts" not in step:
|
230
|
+
return
|
231
|
+
|
232
|
+
for artifact in step["artifacts"]:
|
233
|
+
files = find_files_for_extension(self.source_dir, artifact["extension"])
|
234
|
+
|
235
|
+
for file in files:
|
236
|
+
# Find path relative to source_dir
|
237
|
+
relative_path = PurePath(file).relative_to(self.source_dir)
|
238
|
+
|
239
|
+
# Construct destination to preserve directory structure
|
240
|
+
destination = Path(get_artifacts_cache(self.job_id) / relative_path)
|
241
|
+
|
242
|
+
# Create directories if they don't exist
|
243
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
244
|
+
|
245
|
+
# Move file
|
246
|
+
file.rename(destination)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import typing
|
2
|
-
from typing import Dict
|
3
|
-
import shutil
|
4
1
|
import os
|
2
|
+
import shutil
|
3
|
+
import typing
|
5
4
|
from pathlib import Path, PurePath
|
5
|
+
from typing import Dict
|
6
6
|
|
7
7
|
from loguru import logger
|
8
8
|
|
@@ -45,12 +45,11 @@ class Uploader:
|
|
45
45
|
)
|
46
46
|
|
47
47
|
for file in files:
|
48
|
-
|
48
|
+
result = self.primitive.files.upload_file_direct(
|
49
49
|
path=file,
|
50
|
-
key_prefix=str(PurePath(file).relative_to(cache.parent).parent)
|
51
|
-
job_run_id=job_run_id,
|
50
|
+
key_prefix=str(PurePath(file).relative_to(cache.parent).parent)
|
52
51
|
)
|
53
|
-
upload_id =
|
52
|
+
upload_id = result.data["fileUpdate"]["id"]
|
54
53
|
|
55
54
|
if upload_id:
|
56
55
|
file_ids.append(upload_id)
|
@@ -13,11 +13,9 @@ from .files.commands import cli as file_commands
|
|
13
13
|
from .git.commands import cli as git_commands
|
14
14
|
from .hardware.commands import cli as hardware_commands
|
15
15
|
from .jobs.commands import cli as jobs_commands
|
16
|
-
from .lint.commands import cli as lint_commands
|
17
16
|
from .organizations.commands import cli as organizations_commands
|
18
17
|
from .projects.commands import cli as projects_commands
|
19
18
|
from .reservations.commands import cli as reservations_commands
|
20
|
-
from .sim.commands import cli as sim_commands
|
21
19
|
|
22
20
|
|
23
21
|
@click.group()
|
@@ -65,14 +63,12 @@ cli.add_command(config_command, "config")
|
|
65
63
|
cli.add_command(whoami_command, "whoami")
|
66
64
|
cli.add_command(file_commands, "files")
|
67
65
|
cli.add_command(hardware_commands, "hardware")
|
68
|
-
cli.add_command(lint_commands, "lint")
|
69
66
|
cli.add_command(agent_commands, "agent")
|
70
67
|
cli.add_command(git_commands, "git")
|
71
68
|
cli.add_command(daemons_commands, "daemons")
|
72
69
|
cli.add_command(jobs_commands, "jobs")
|
73
70
|
cli.add_command(organizations_commands, "organizations")
|
74
71
|
cli.add_command(projects_commands, "projects")
|
75
|
-
cli.add_command(sim_commands, "sim")
|
76
72
|
cli.add_command(reservations_commands, "reservations")
|
77
73
|
cli.add_command(exec_commands, "exec")
|
78
74
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import sys
|
2
2
|
|
3
|
+
from gql import Client
|
3
4
|
from loguru import logger
|
4
5
|
|
5
6
|
from .agent.actions import Agent
|
@@ -10,12 +11,10 @@ from .files.actions import Files
|
|
10
11
|
from .git.actions import Git
|
11
12
|
from .hardware.actions import Hardware
|
12
13
|
from .jobs.actions import Jobs
|
13
|
-
from .lint.actions import Lint
|
14
14
|
from .organizations.actions import Organizations
|
15
15
|
from .projects.actions import Projects
|
16
16
|
from .provisioning.actions import Provisioning
|
17
17
|
from .reservations.actions import Reservations
|
18
|
-
from .sim.actions import Sim
|
19
18
|
from .utils.config import read_config_file
|
20
19
|
|
21
20
|
logger.disable("primitive")
|
@@ -30,10 +29,10 @@ class Primitive:
|
|
30
29
|
token: str = None,
|
31
30
|
transport: str = None,
|
32
31
|
) -> None:
|
33
|
-
self.host = host
|
34
|
-
self.session = None
|
35
|
-
self.DEBUG = DEBUG
|
36
|
-
self.JSON = JSON
|
32
|
+
self.host: str = host
|
33
|
+
self.session: Client = None
|
34
|
+
self.DEBUG: bool = DEBUG
|
35
|
+
self.JSON: bool = JSON
|
37
36
|
|
38
37
|
if self.DEBUG:
|
39
38
|
logger.enable("primitive")
|
@@ -61,10 +60,8 @@ class Primitive:
|
|
61
60
|
self.projects: Projects = Projects(self)
|
62
61
|
self.jobs: Jobs = Jobs(self)
|
63
62
|
self.files: Files = Files(self)
|
64
|
-
self.sim: Sim = Sim(self)
|
65
63
|
self.reservations: Reservations = Reservations(self)
|
66
64
|
self.hardware: Hardware = Hardware(self)
|
67
|
-
self.lint: Lint = Lint(self)
|
68
65
|
self.agent: Agent = Agent(self)
|
69
66
|
self.git: Git = Git(self)
|
70
67
|
self.daemons: Daemons = Daemons(self)
|