primitive 0.1.79__tar.gz → 0.1.80__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.79 → primitive-0.1.80}/PKG-INFO +1 -1
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/__about__.py +1 -1
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/actions.py +1 -2
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/process.py +6 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/runner.py +38 -14
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/graphql/fragments.py +2 -0
- {primitive-0.1.79 → primitive-0.1.80}/.git-hooks/pre-commit +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/.gitattributes +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/.github/workflows/lint.yml +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/.github/workflows/publish.yml +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/.gitignore +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/.vscode/settings.json +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/LICENSE.txt +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/Makefile +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/README.md +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/linux setup.md +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/pyproject.toml +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/provision.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/agent/uploader.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/auth/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/auth/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/auth/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/auth/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/auth/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/cli.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/client.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/daemons/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/daemons/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/daemons/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/daemons/launch_agents.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/daemons/launch_service.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/exec/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/exec/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/exec/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/exec/interactive.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/graphql/fragments.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/graphql/mutations.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/files/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/git/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/git/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/git/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/git/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/git/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/graphql/relay.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/graphql/sdk.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/graphql/utility_fragments.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/graphql/fragments.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/graphql/mutations.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/hardware/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/graphql/mutations.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/jobs/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/graphql/fragments.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/graphql/mutations.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/organizations/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/graphql/fragments.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/graphql/mutations.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/projects/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/provisioning/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/provisioning/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/provisioning/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/provisioning/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/commands.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/graphql/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/graphql/fragments.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/graphql/mutations.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/reservations/graphql/queries.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/actions.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/auth.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/cache.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/chunk_size.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/config.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/files.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/git.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/memory_size.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/printer.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/shell.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/src/primitive/utils/verible.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/tests/__init__.py +0 -0
- {primitive-0.1.79 → primitive-0.1.80}/uv.lock +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.80
|
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
|
@@ -138,8 +138,7 @@ class Agent(BaseAction):
|
|
138
138
|
runner = AgentRunner(
|
139
139
|
primitive=self.primitive,
|
140
140
|
source_dir=source_dir,
|
141
|
-
|
142
|
-
job_slug=job_run["job"]["slug"],
|
141
|
+
job_run=job_run,
|
143
142
|
max_log_size=500 * 1024,
|
144
143
|
)
|
145
144
|
except Exception as e:
|
@@ -24,6 +24,7 @@ class Process:
|
|
24
24
|
self.stdout_thread = None
|
25
25
|
self.stderr_thread = None
|
26
26
|
self._errors = 0
|
27
|
+
self._warnings = 0
|
27
28
|
|
28
29
|
def start(self):
|
29
30
|
# Start the process
|
@@ -53,6 +54,7 @@ class Process:
|
|
53
54
|
self._errors += 1
|
54
55
|
elif "warning" in raw_data.lower():
|
55
56
|
logger.warning(raw_data)
|
57
|
+
self._warnings += 1
|
56
58
|
else:
|
57
59
|
logger.info(raw_data)
|
58
60
|
elif key.fileobj is self.process.stderr:
|
@@ -117,3 +119,7 @@ class Process:
|
|
117
119
|
@property
|
118
120
|
def errors(self) -> int:
|
119
121
|
return self._errors
|
122
|
+
|
123
|
+
@property
|
124
|
+
def warnings(self) -> int:
|
125
|
+
return self._warnings
|
@@ -4,6 +4,7 @@ import typing
|
|
4
4
|
from pathlib import Path, PurePath
|
5
5
|
from time import sleep
|
6
6
|
from typing import Dict, Iterable, List, Optional, TypedDict, Callable
|
7
|
+
from enum import IntEnum
|
7
8
|
|
8
9
|
import yaml
|
9
10
|
from loguru import logger
|
@@ -39,22 +40,29 @@ class JobDescription(TypedDict):
|
|
39
40
|
steps: List[JobStep]
|
40
41
|
|
41
42
|
|
43
|
+
# NOTE This must match FailureLevel subclass in JobSettings model
|
44
|
+
class FailureLevel(IntEnum):
|
45
|
+
ERROR = 1
|
46
|
+
WARNING = 2
|
47
|
+
|
48
|
+
|
42
49
|
class AgentRunner:
|
43
50
|
def __init__(
|
44
51
|
self,
|
45
52
|
primitive: "primitive.client.Primitive",
|
46
53
|
source_dir: Path,
|
47
|
-
|
48
|
-
job_slug: str,
|
54
|
+
job_run: Dict,
|
49
55
|
max_log_size: int = 10 * 1024 * 1024,
|
50
56
|
log_to_file: bool = True,
|
51
57
|
) -> None:
|
52
58
|
self.primitive = primitive
|
53
59
|
self.source_dir = source_dir
|
54
60
|
self.workdir = "."
|
55
|
-
self.job_id =
|
56
|
-
self.job_slug =
|
61
|
+
self.job_id = job_run["id"]
|
62
|
+
self.job_slug = job_run["job"]["slug"]
|
57
63
|
self.max_log_size = max_log_size
|
64
|
+
self.parse_logs = job_run["jobSettings"]["parseLogs"]
|
65
|
+
self.failure_level = job_run["jobSettings"]["failureLevel"]
|
58
66
|
self.log_to_file = log_to_file
|
59
67
|
|
60
68
|
# Enable and configure logger
|
@@ -140,7 +148,8 @@ class AgentRunner:
|
|
140
148
|
logger.error(f"{self.job_slug} concluded with error(s)")
|
141
149
|
return
|
142
150
|
|
143
|
-
|
151
|
+
fail_level_detected = False
|
152
|
+
total_parsed_levels = {FailureLevel.ERROR: 0, FailureLevel.WARNING: 0}
|
144
153
|
for step in self.steps():
|
145
154
|
logger.info(f"Beginning step {step['name']}")
|
146
155
|
|
@@ -183,7 +192,16 @@ class AgentRunner:
|
|
183
192
|
status_thread.start()
|
184
193
|
|
185
194
|
returncode = proc.wait()
|
186
|
-
|
195
|
+
|
196
|
+
if proc.errors > 0 and self.failure_level >= FailureLevel.ERROR:
|
197
|
+
fail_level_detected = True
|
198
|
+
|
199
|
+
if proc.warnings > 0 and self.failure_level >= FailureLevel.WARNING:
|
200
|
+
fail_level_detected = True
|
201
|
+
|
202
|
+
total_parsed_levels[FailureLevel.ERROR] += proc.errors
|
203
|
+
total_parsed_levels[FailureLevel.WARNING] += proc.warnings
|
204
|
+
|
187
205
|
status_thread.join()
|
188
206
|
|
189
207
|
self.collect_artifacts(step)
|
@@ -194,14 +212,20 @@ class AgentRunner:
|
|
194
212
|
)
|
195
213
|
logger.error(f"{self.job_slug} concluded with error(s)")
|
196
214
|
return
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
215
|
+
|
216
|
+
if fail_level_detected and self.parse_logs:
|
217
|
+
self.primitive.jobs.job_run_update(
|
218
|
+
self.job_id, status="request_completed", conclusion="failure"
|
219
|
+
)
|
220
|
+
|
221
|
+
logger.error(
|
222
|
+
(
|
223
|
+
f"{self.job_slug} concluded"
|
224
|
+
f" with {total_parsed_levels[FailureLevel.ERROR]} error(s)"
|
225
|
+
f" and {total_parsed_levels[FailureLevel.WARNING]} warning(s)"
|
226
|
+
)
|
227
|
+
)
|
228
|
+
return
|
205
229
|
|
206
230
|
self.primitive.jobs.job_run_update(
|
207
231
|
self.job_id, status="request_completed", conclusion="success"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|