primitive 0.2.5__tar.gz → 0.2.7__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.5 → primitive-0.2.7}/PKG-INFO +1 -1
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/__about__.py +1 -1
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/agent/runner.py +24 -20
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/graphql/sdk.py +1 -2
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/actions.py +0 -35
- {primitive-0.2.5 → primitive-0.2.7}/.git-hooks/pre-commit +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/.gitattributes +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/.github/workflows/lint.yml +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/.github/workflows/publish.yml +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/.gitignore +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/.vscode/settings.json +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/LICENSE.txt +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/Makefile +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/README.md +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/linux setup.md +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/pyproject.toml +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/agent/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/agent/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/agent/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/agent/uploader.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/auth/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/auth/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/auth/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/auth/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/auth/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/cli.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/client.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/daemons/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/daemons/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/daemons/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/daemons/launch_agents.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/daemons/launch_service.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/exec/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/exec/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/exec/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/exec/interactive.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/graphql/fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/graphql/mutations.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/files/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/git/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/git/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/git/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/git/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/git/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/graphql/relay.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/graphql/utility_fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/android.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/graphql/fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/graphql/mutations.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/hardware/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/graphql/fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/graphql/mutations.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/jobs/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/graphql/fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/graphql/mutations.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/organizations/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/graphql/fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/graphql/mutations.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/projects/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/provisioning/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/provisioning/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/provisioning/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/provisioning/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/commands.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/graphql/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/graphql/fragments.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/graphql/mutations.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/reservations/graphql/queries.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/actions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/auth.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/cache.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/chunk_size.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/config.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/exceptions.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/memory_size.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/printer.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/shell.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/src/primitive/utils/text.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/tests/__init__.py +0 -0
- {primitive-0.2.5 → primitive-0.2.7}/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.7
|
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
|
@@ -2,6 +2,7 @@ import os
|
|
2
2
|
import re
|
3
3
|
import typing
|
4
4
|
import shutil
|
5
|
+
import time
|
5
6
|
from typing import Dict, TypedDict, List
|
6
7
|
from abc import abstractmethod
|
7
8
|
from enum import IntEnum, Enum
|
@@ -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,26 +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
|
-
|
218
|
+
if returncode > 0:
|
219
|
+
logger.error(
|
220
|
+
f"Task {task['label']} failed on '{cmd}' with return code {returncode}"
|
212
221
|
)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
f"Task {task['label']} failed on '{cmd}' with return code {returncode}"
|
217
|
-
)
|
218
|
-
else:
|
219
|
-
logger.error(f"Task {task['label']} failed on '{cmd}'")
|
220
|
-
|
222
|
+
return True
|
223
|
+
elif stdout_failed or stderr_failed:
|
224
|
+
logger.error(f"Task {task['label']} failed on '{cmd}'")
|
221
225
|
return True
|
222
226
|
|
223
227
|
return False
|
@@ -298,14 +302,14 @@ class Runner:
|
|
298
302
|
|
299
303
|
return [line for line in lines if len(line) > 0]
|
300
304
|
|
301
|
-
|
305
|
+
def monitor_cmd(self, process) -> bool:
|
302
306
|
while process.returncode is None:
|
303
|
-
status =
|
307
|
+
status = self.primitive.jobs.get_job_status(self.job_run["id"])
|
308
|
+
|
304
309
|
status_value = status.data["jobRun"]["status"]
|
305
310
|
conclusion_value = status.data["jobRun"]["conclusion"]
|
306
311
|
|
307
312
|
if status_value == "completed" and conclusion_value == "cancelled":
|
308
|
-
logger.warning("Job cancelled by user")
|
309
313
|
try:
|
310
314
|
process.terminate()
|
311
315
|
except ProcessLookupError:
|
@@ -313,7 +317,7 @@ class Runner:
|
|
313
317
|
|
314
318
|
return True
|
315
319
|
|
316
|
-
|
320
|
+
time.sleep(5)
|
317
321
|
|
318
322
|
return False
|
319
323
|
|
@@ -28,8 +28,7 @@ def create_session(
|
|
28
28
|
|
29
29
|
transport = AIOHTTPTransport(url=url, headers=headers)
|
30
30
|
session = Client(
|
31
|
-
transport=transport,
|
32
|
-
fetch_schema_from_transport=fetch_schema_from_transport,
|
31
|
+
transport=transport, fetch_schema_from_transport=fetch_schema_from_transport
|
33
32
|
)
|
34
33
|
return session
|
35
34
|
|
@@ -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
|