primitive 0.2.51__tar.gz → 0.2.53__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.51 → primitive-0.2.53}/PKG-INFO +1 -1
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/__about__.py +1 -1
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/agent/actions.py +65 -52
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/agent/uploader.py +12 -10
- {primitive-0.2.51 → primitive-0.2.53}/.git-hooks/pre-commit +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.gitattributes +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.github/workflows/lint.yml +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.github/workflows/publish.yml +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.github/workflows/pyright.yml +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.gitignore +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.vscode/extensions.json +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/.vscode/settings.json +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/LICENSE.txt +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/Makefile +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/README.md +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/linux setup.md +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/pyproject.toml +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/agent/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/agent/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/agent/runner.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/auth/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/auth/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/auth/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/auth/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/auth/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/cli.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/client.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/daemons/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/daemons/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/daemons/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/daemons/launch_agents.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/daemons/launch_service.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/daemons/ui.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/exec/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/exec/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/exec/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/exec/interactive.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/graphql/fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/graphql/mutations.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/files/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/git/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/git/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/git/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/git/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/git/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/graphql/relay.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/graphql/sdk.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/graphql/utility_fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/android.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/graphql/fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/graphql/mutations.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/hardware/ui.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/graphql/fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/graphql/mutations.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/jobs/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/monitor/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/monitor/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/graphql/fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/graphql/mutations.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/organizations/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/graphql/fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/graphql/mutations.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/projects/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/provisioning/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/provisioning/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/provisioning/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/provisioning/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/commands.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/graphql/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/graphql/fragments.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/graphql/mutations.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/reservations/graphql/queries.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/actions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/auth.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/cache.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/chunk_size.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/config.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/daemons.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/exceptions.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/logging.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/memory_size.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/printer.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/psutil.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/shell.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/src/primitive/utils/text.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/tests/__init__.py +0 -0
- {primitive-0.2.51 → primitive-0.2.53}/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.53
|
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
|
@@ -89,71 +89,84 @@ class Agent(BaseAction):
|
|
89
89
|
logger.debug(f"Job Run ID: {job_run_data.get('id')}")
|
90
90
|
logger.debug(f"Job Name: {job_run_data.get('job').get('name')}")
|
91
91
|
|
92
|
-
|
93
|
-
f"Setting JobRun {job_run_data.get('job').get('name')} to request_in_progress"
|
94
|
-
)
|
92
|
+
job_run_status = job_run_data.get("status", None)
|
95
93
|
|
96
|
-
|
97
|
-
|
98
|
-
while job_run_status != "in_progress":
|
99
|
-
if job_run_status == "request_completed":
|
100
|
-
logger.error(
|
101
|
-
f"JobRun {job_run_data.get('name')} is already completed. Exiting."
|
102
|
-
)
|
103
|
-
if RUNNING_IN_CONTAINER:
|
104
|
-
logger.info("Running in container, exiting after job run")
|
105
|
-
return
|
106
|
-
elif job_run_status == "pending":
|
94
|
+
while True:
|
95
|
+
if job_run_status == "pending":
|
107
96
|
# we are setting to request_in_progress here which puts a started_at time on the JobRun in the API's database
|
108
97
|
# any time spent pulling Git repositories, setting up, etc, counts as compute time
|
109
|
-
|
98
|
+
logger.info(
|
99
|
+
f"Setting JobRun {job_run_data.get('id')} to request_in_progress."
|
100
|
+
)
|
101
|
+
# get the status back from the job run update, this should be 'in progress'
|
102
|
+
job_run_update_result = self.primitive.jobs.job_run_update(
|
110
103
|
id=job_run_id, status="request_in_progress"
|
111
104
|
)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
105
|
+
job_run_update_data = job_run_update_result.data
|
106
|
+
if job_run_update_data is not None:
|
107
|
+
# if the job_run_status is not in "in_progress", short circuit
|
108
|
+
job_run_status = job_run_update_data.get(
|
109
|
+
"jobRunUpdate", {}
|
110
|
+
).get("status", None)
|
111
|
+
if job_run_status == "in_progress":
|
112
|
+
logger.info(f"JobRun {job_run_data.get('id')} in progress.")
|
113
|
+
break
|
114
|
+
if (
|
115
|
+
job_run_status == "request_completed"
|
116
|
+
or job_run_status == "completed"
|
117
|
+
):
|
118
|
+
logger.error(
|
119
|
+
f"JobRun {job_run_data.get('name')} is already completed with conclusion {job_run_data.get('jobRun', {}).get('conclusion', 'unknown')}. Exiting."
|
120
|
+
)
|
121
|
+
break
|
122
|
+
|
116
123
|
job_run_result = self.primitive.jobs.get_job_run(id=job_run_id)
|
117
124
|
if job_run_result.data is not None:
|
118
125
|
job_run_data = job_run_result.data.get("jobRun", {})
|
119
126
|
job_run_status = job_run_data.get("status", None)
|
120
|
-
|
121
|
-
|
122
|
-
runner = Runner(
|
123
|
-
primitive=self.primitive,
|
124
|
-
job_run=job_run_data,
|
125
|
-
)
|
126
|
-
runner.setup()
|
127
|
-
except Exception as exception:
|
128
|
-
logger.exception(
|
129
|
-
f"Exception while initializing runner: {exception}"
|
130
|
-
)
|
131
|
-
self.primitive.jobs.job_run_update(
|
132
|
-
id=job_run_id,
|
133
|
-
status="request_completed",
|
134
|
-
conclusion="failure",
|
127
|
+
logger.info(
|
128
|
+
f"Waiting for JobRun {job_run_data.get('id')} to be in_progress. Current status: {job_run_status}"
|
135
129
|
)
|
136
|
-
|
130
|
+
sleep(1)
|
137
131
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
132
|
+
# the backend has said it's okay for the agent to run this job
|
133
|
+
if job_run_status == "in_progress":
|
134
|
+
try:
|
135
|
+
runner = Runner(
|
136
|
+
primitive=self.primitive,
|
137
|
+
job_run=job_run_data,
|
138
|
+
)
|
139
|
+
runner.setup()
|
140
|
+
except Exception as exception:
|
141
|
+
logger.exception(
|
142
|
+
f"Exception while initializing runner: {exception}"
|
143
|
+
)
|
144
|
+
self.primitive.jobs.job_run_update(
|
145
|
+
id=job_run_id,
|
146
|
+
status="request_completed",
|
147
|
+
conclusion="failure",
|
148
|
+
)
|
149
|
+
continue
|
149
150
|
|
150
|
-
|
151
|
-
|
152
|
-
|
151
|
+
try:
|
152
|
+
runner.execute_job_run()
|
153
|
+
except Exception as exception:
|
154
|
+
logger.exception(f"Exception while executing job: {exception}")
|
155
|
+
self.primitive.jobs.job_run_update(
|
156
|
+
id=job_run_id,
|
157
|
+
status="request_completed",
|
158
|
+
conclusion="failure",
|
159
|
+
)
|
160
|
+
finally:
|
161
|
+
runner.cleanup()
|
153
162
|
|
154
|
-
|
155
|
-
|
156
|
-
|
163
|
+
# NOTE: also run scan here to force upload of artifacts
|
164
|
+
# This should probably eventually be another daemon?
|
165
|
+
uploader.scan()
|
166
|
+
|
167
|
+
if RUNNING_IN_CONTAINER:
|
168
|
+
logger.info("Running in container, exiting after job run")
|
169
|
+
break
|
157
170
|
|
158
171
|
sleep(5)
|
159
172
|
except KeyboardInterrupt:
|
@@ -46,22 +46,24 @@ class Uploader:
|
|
46
46
|
|
47
47
|
for file in files:
|
48
48
|
try:
|
49
|
-
|
49
|
+
upload_file_result = self.primitive.files.upload_file_direct(
|
50
50
|
path=file,
|
51
51
|
key_prefix=str(PurePath(file).relative_to(cache.parent).parent),
|
52
52
|
)
|
53
|
-
except Exception as exception:
|
54
|
-
if "is empty" in str(exception):
|
55
|
-
logger.warning(f"{file} is empty, skipping upload")
|
56
|
-
continue
|
57
53
|
|
58
|
-
|
54
|
+
if upload_file_result and upload_file_result.data is not None:
|
55
|
+
upload_file_data = upload_file_result.data
|
56
|
+
upload_id = upload_file_data.get("fileUpdate", {}).get("id")
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
if upload_id:
|
59
|
+
file_ids.append(upload_id)
|
60
|
+
continue
|
63
61
|
|
64
|
-
|
62
|
+
logger.error(f"Unable to upload file {file}")
|
63
|
+
except Exception as exception:
|
64
|
+
if "is empty" in str(exception):
|
65
|
+
logger.warning(f"{file} is empty, skipping upload")
|
66
|
+
continue
|
65
67
|
|
66
68
|
# Clean up job cache
|
67
69
|
shutil.rmtree(path=cache)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|