primitive 0.2.6__tar.gz → 0.2.8__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.2.6 → primitive-0.2.8}/PKG-INFO +1 -1
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/__about__.py +1 -1
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/agent/runner.py +23 -30
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/graphql/sdk.py +1 -1
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/actions.py +0 -35
- {primitive-0.2.6 → primitive-0.2.8}/.git-hooks/pre-commit +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/.gitattributes +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/.github/workflows/lint.yml +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/.github/workflows/publish.yml +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/.gitignore +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/.vscode/settings.json +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/LICENSE.txt +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/Makefile +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/README.md +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/linux setup.md +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/pyproject.toml +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/agent/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/agent/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/agent/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/agent/uploader.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/auth/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/auth/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/auth/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/auth/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/auth/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/cli.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/client.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/daemons/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/daemons/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/daemons/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/daemons/launch_agents.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/daemons/launch_service.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/exec/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/exec/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/exec/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/exec/interactive.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/graphql/fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/graphql/mutations.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/files/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/git/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/git/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/git/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/git/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/git/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/graphql/relay.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/graphql/utility_fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/android.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/graphql/fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/graphql/mutations.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/hardware/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/graphql/fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/graphql/mutations.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/jobs/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/graphql/fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/graphql/mutations.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/organizations/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/graphql/fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/graphql/mutations.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/projects/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/provisioning/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/provisioning/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/provisioning/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/provisioning/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/commands.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/graphql/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/graphql/fragments.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/graphql/mutations.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/reservations/graphql/queries.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/actions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/auth.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/cache.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/chunk_size.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/config.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/exceptions.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/memory_size.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/printer.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/shell.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/src/primitive/utils/text.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/tests/__init__.py +0 -0
- {primitive-0.2.6 → primitive-0.2.8}/uv.lock +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.8
|
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
|
@@ -9,6 +9,7 @@ from pathlib import Path, PurePath
|
|
9
9
|
from loguru import logger
|
10
10
|
import yaml
|
11
11
|
import asyncio
|
12
|
+
import time
|
12
13
|
from ..utils.cache import get_artifacts_cache, get_sources_cache, get_logs_cache
|
13
14
|
from ..utils.shell import env_to_dict
|
14
15
|
|
@@ -155,18 +156,22 @@ class Runner:
|
|
155
156
|
self.modified_env = {**self.initial_env}
|
156
157
|
|
157
158
|
task_failed = False
|
159
|
+
conclusion = "success"
|
158
160
|
for task in self.config["executes"]:
|
159
161
|
with logger.contextualize(label=task["label"]):
|
160
162
|
with asyncio.Runner() as async_runner:
|
161
163
|
if task_failed := async_runner.run(self.run_task(task)):
|
162
164
|
break
|
163
165
|
|
164
|
-
if
|
165
|
-
|
166
|
-
|
167
|
-
)
|
166
|
+
if task_failed:
|
167
|
+
conclusion = "failure"
|
168
|
+
else:
|
168
169
|
logger.success(f"Completed {self.job['slug']} job")
|
169
170
|
|
171
|
+
self.primitive.jobs.job_run_update(
|
172
|
+
self.job_run["id"], status="request_completed", conclusion=conclusion
|
173
|
+
)
|
174
|
+
|
170
175
|
async def run_task(self, task: Task) -> bool:
|
171
176
|
for cmd in task["cmd"].strip().split("\n"):
|
172
177
|
# Adding an additional echo and utilizing stdbuf to force line buffering
|
@@ -191,6 +196,9 @@ class Runner:
|
|
191
196
|
stderr=asyncio.subprocess.PIPE,
|
192
197
|
)
|
193
198
|
|
199
|
+
loop = asyncio.get_running_loop()
|
200
|
+
monitor_task = loop.run_in_executor(None, self.monitor_cmd, process)
|
201
|
+
|
194
202
|
stdout_failed, stderr_failed, cancelled = await asyncio.gather(
|
195
203
|
self.log_cmd(
|
196
204
|
process=process, stream=process.stdout, tags=task.get("tags", {})
|
@@ -198,31 +206,22 @@ class Runner:
|
|
198
206
|
self.log_cmd(
|
199
207
|
process=process, stream=process.stderr, tags=task.get("tags", {})
|
200
208
|
),
|
201
|
-
|
209
|
+
monitor_task,
|
202
210
|
)
|
203
211
|
|
204
212
|
returncode = await process.wait()
|
205
213
|
|
206
214
|
if cancelled:
|
215
|
+
logger.warning("Job cancelled by user")
|
207
216
|
return True
|
208
217
|
|
209
|
-
if returncode > 0
|
210
|
-
|
211
|
-
|
212
|
-
start_time = time.monotonic()
|
213
|
-
await self.primitive.jobs.ajob_run_update(
|
214
|
-
self.job_run["id"], status="request_completed", conclusion="failure"
|
218
|
+
if returncode > 0:
|
219
|
+
logger.error(
|
220
|
+
f"Task {task['label']} failed on '{cmd}' with return code {returncode}"
|
215
221
|
)
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
if returncode > 0:
|
220
|
-
logger.error(
|
221
|
-
f"Task {task['label']} failed on '{cmd}' with return code {returncode}"
|
222
|
-
)
|
223
|
-
else:
|
224
|
-
logger.error(f"Task {task['label']} failed on '{cmd}'")
|
225
|
-
|
222
|
+
return True
|
223
|
+
elif stdout_failed or stderr_failed:
|
224
|
+
logger.error(f"Task {task['label']} failed on '{cmd}'")
|
226
225
|
return True
|
227
226
|
|
228
227
|
return False
|
@@ -303,20 +302,14 @@ class Runner:
|
|
303
302
|
|
304
303
|
return [line for line in lines if len(line) > 0]
|
305
304
|
|
306
|
-
|
305
|
+
def monitor_cmd(self, process) -> bool:
|
307
306
|
while process.returncode is None:
|
308
|
-
|
309
|
-
|
310
|
-
start_time = time.monotonic()
|
311
|
-
status = await self.primitive.jobs.aget_job_status(self.job_run["id"])
|
312
|
-
end_time = time.monotonic()
|
313
|
-
logger.warning(f"GET JOB STATUS {end_time - start_time:.2f} seconds")
|
307
|
+
status = self.primitive.jobs.get_job_status(self.job_run["id"])
|
314
308
|
|
315
309
|
status_value = status.data["jobRun"]["status"]
|
316
310
|
conclusion_value = status.data["jobRun"]["conclusion"]
|
317
311
|
|
318
312
|
if status_value == "completed" and conclusion_value == "cancelled":
|
319
|
-
logger.warning("Job cancelled by user")
|
320
313
|
try:
|
321
314
|
process.terminate()
|
322
315
|
except ProcessLookupError:
|
@@ -324,7 +317,7 @@ class Runner:
|
|
324
317
|
|
325
318
|
return True
|
326
319
|
|
327
|
-
|
320
|
+
time.sleep(10)
|
328
321
|
|
329
322
|
return False
|
330
323
|
|
@@ -30,7 +30,7 @@ def create_session(
|
|
30
30
|
session = Client(
|
31
31
|
transport=transport,
|
32
32
|
fetch_schema_from_transport=fetch_schema_from_transport,
|
33
|
-
execute_timeout=None, #
|
33
|
+
execute_timeout=None, # Prevents timeout errors on async transports
|
34
34
|
)
|
35
35
|
return session
|
36
36
|
|
@@ -128,30 +128,6 @@ class Jobs(BaseAction):
|
|
128
128
|
)
|
129
129
|
return result
|
130
130
|
|
131
|
-
@guard
|
132
|
-
async def ajob_run_update(
|
133
|
-
self,
|
134
|
-
id: str,
|
135
|
-
status: str = None,
|
136
|
-
conclusion: str = None,
|
137
|
-
file_ids: Optional[List[str]] = [],
|
138
|
-
):
|
139
|
-
mutation = gql(job_run_update_mutation)
|
140
|
-
input = {"id": id}
|
141
|
-
if status:
|
142
|
-
input["status"] = status
|
143
|
-
if conclusion:
|
144
|
-
input["conclusion"] = conclusion
|
145
|
-
if file_ids and len(file_ids) > 0:
|
146
|
-
input["files"] = file_ids
|
147
|
-
variables = {"input": input}
|
148
|
-
|
149
|
-
async with self.primitive.session as session:
|
150
|
-
result = await session.execute(
|
151
|
-
mutation, variable_values=variables, get_execution_result=True
|
152
|
-
)
|
153
|
-
return result
|
154
|
-
|
155
131
|
@guard
|
156
132
|
def github_access_token_for_job_run(self, job_run_id: str):
|
157
133
|
query = gql(github_app_token_for_job_run_query)
|
@@ -184,14 +160,3 @@ class Jobs(BaseAction):
|
|
184
160
|
query, variable_values=variables, get_execution_result=True
|
185
161
|
)
|
186
162
|
return result
|
187
|
-
|
188
|
-
@guard
|
189
|
-
async def aget_job_status(self, id: str):
|
190
|
-
query = gql(job_run_status_query)
|
191
|
-
variables = {"id": id}
|
192
|
-
|
193
|
-
async with self.primitive.session as session:
|
194
|
-
result = await session.execute(
|
195
|
-
query, variable_values=variables, get_execution_result=True
|
196
|
-
)
|
197
|
-
return result
|
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
|