primitive 0.2.8__py3-none-any.whl → 0.2.10__py3-none-any.whl

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/__about__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Dylan Stein <dylan@primitive.tech>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.2.8"
4
+ __version__ = "0.2.10"
primitive/agent/runner.py CHANGED
@@ -1,16 +1,18 @@
1
+ import asyncio
1
2
  import os
2
3
  import re
3
- import typing
4
4
  import shutil
5
- from typing import Dict, TypedDict, List
5
+ import time
6
+ import typing
6
7
  from abc import abstractmethod
7
- from enum import IntEnum, Enum
8
+ from enum import Enum, IntEnum
8
9
  from pathlib import Path, PurePath
9
- from loguru import logger
10
+ from typing import Dict, List, TypedDict
11
+
10
12
  import yaml
11
- import asyncio
12
- import time
13
- from ..utils.cache import get_artifacts_cache, get_sources_cache, get_logs_cache
13
+ from loguru import logger
14
+
15
+ from ..utils.cache import get_artifacts_cache, get_logs_cache, get_sources_cache
14
16
  from ..utils.shell import env_to_dict
15
17
 
16
18
  try:
@@ -168,10 +170,61 @@ class Runner:
168
170
  else:
169
171
  logger.success(f"Completed {self.job['slug']} job")
170
172
 
173
+ number_of_files_produced = self.get_number_of_files_produced()
174
+ logger.info(
175
+ f"Produced {number_of_files_produced} files for {self.job['slug']} job"
176
+ )
171
177
  self.primitive.jobs.job_run_update(
172
- self.job_run["id"], status="request_completed", conclusion=conclusion
178
+ self.job_run["id"],
179
+ status="request_completed",
180
+ conclusion=conclusion,
181
+ number_of_files_produced=number_of_files_produced,
173
182
  )
174
183
 
184
+ def get_number_of_files_produced(self) -> int:
185
+ """Returns the number of files produced by the job."""
186
+ number_of_files_produced = 0
187
+
188
+ # Logs can be produced even if no artifact stores are created for the job run.
189
+ job_run_logs_cache = get_logs_cache(self.job_run["id"])
190
+ has_walk = getattr(job_run_logs_cache, "walk", None)
191
+ if has_walk:
192
+ log_files = [
193
+ file
194
+ for _, _, current_path_files in job_run_logs_cache.walk()
195
+ for file in current_path_files
196
+ ]
197
+ else:
198
+ log_files = [
199
+ file
200
+ for _, _, current_path_files in os.walk(job_run_logs_cache)
201
+ for file in current_path_files
202
+ ]
203
+
204
+ number_of_files_produced += len(log_files)
205
+
206
+ if "stores" not in self.config:
207
+ return number_of_files_produced
208
+
209
+ job_run_artifacts_cache = get_artifacts_cache(self.job_run["id"])
210
+ has_walk = getattr(job_run_artifacts_cache, "walk", None)
211
+ if has_walk:
212
+ artifact_files = [
213
+ file
214
+ for _, _, current_path_files in job_run_artifacts_cache.walk()
215
+ for file in current_path_files
216
+ ]
217
+ else:
218
+ artifact_files = [
219
+ file
220
+ for _, _, current_path_files in os.walk(job_run_artifacts_cache)
221
+ for file in current_path_files
222
+ ]
223
+
224
+ number_of_files_produced += len(artifact_files)
225
+
226
+ return number_of_files_produced
227
+
175
228
  async def run_task(self, task: Task) -> bool:
176
229
  for cmd in task["cmd"].strip().split("\n"):
177
230
  # Adding an additional echo and utilizing stdbuf to force line buffering
primitive/jobs/actions.py CHANGED
@@ -113,6 +113,7 @@ class Jobs(BaseAction):
113
113
  status: str = None,
114
114
  conclusion: str = None,
115
115
  file_ids: Optional[List[str]] = [],
116
+ number_of_files_produced: Optional[int] = None,
116
117
  ):
117
118
  mutation = gql(job_run_update_mutation)
118
119
  input = {"id": id}
@@ -122,6 +123,8 @@ class Jobs(BaseAction):
122
123
  input["conclusion"] = conclusion
123
124
  if file_ids and len(file_ids) > 0:
124
125
  input["files"] = file_ids
126
+ if number_of_files_produced is not None:
127
+ input["numberOfFilesProduced"] = number_of_files_produced
125
128
  variables = {"input": input}
126
129
  result = self.primitive.session.execute(
127
130
  mutation, variable_values=variables, get_execution_result=True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: primitive
3
- Version: 0.2.8
3
+ Version: 0.2.10
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
@@ -1,11 +1,11 @@
1
- primitive/__about__.py,sha256=o1318KQLLGunTegpCvMc3dTrIoSjFpV3EIBF2ZwnUSQ,129
1
+ primitive/__about__.py,sha256=GhNBI3l8-Fbx4DkjexXgyhbGe2cWuYgQDdzAhhACDvE,130
2
2
  primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
3
3
  primitive/cli.py,sha256=58fn6ayVSC1f4hLKx3FUNT9CkuPLva8dFQg0_YUwpio,2410
4
4
  primitive/client.py,sha256=PPyIQRvKKSqCF9RRF5mJJ4Vqqolpzy1YXqffNLKIvAA,2390
5
5
  primitive/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  primitive/agent/actions.py,sha256=5Lmqxsf24eH6BDEesbJbn1Xj-8ifVlQ_Y3QR8xpkFtM,6869
7
7
  primitive/agent/commands.py,sha256=-dVDilELfkGfbZB7qfEPs77Dm1oT62qJj4tsIk4KoxI,254
8
- primitive/agent/runner.py,sha256=MVViJjydMIrR7cgkaP9V2pI3PIqIOEy0sVJFtNJul_M,12105
8
+ primitive/agent/runner.py,sha256=0p-zObkTuSF0H7HQUBnz0jCtwKCERzABJobQhFJfrY4,13944
9
9
  primitive/agent/uploader.py,sha256=6pjUyb1LyUCpHBE6p13pRpXxy6iDxu14qJGvE3R6cVo,3155
10
10
  primitive/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  primitive/auth/actions.py,sha256=MPsG9LcKcOPwA7gZ9Ewk0PZJhTQvIrGfODdz4GxSzgA,999
@@ -46,7 +46,7 @@ primitive/hardware/graphql/fragments.py,sha256=kI6qnTNjaEaUr-C6eD55COphtueVYbYOW
46
46
  primitive/hardware/graphql/mutations.py,sha256=_4Hkbfik9Ron4T-meulu6T-9FR_BZjyPNwn745MPksU,1484
47
47
  primitive/hardware/graphql/queries.py,sha256=I86uLuOSjHSph11Y5MVCYko5Js7hoiEZ-cEoPTc4J-k,1392
48
48
  primitive/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
- primitive/jobs/actions.py,sha256=CtyO-Z9614TgIoXJJX1QGsoll0fgpBIjG9PJH5JwCQs,4901
49
+ primitive/jobs/actions.py,sha256=lOfmjzZ7XvqLyP0f-ilyfYwQQZuNgUb4qxFCpf1d93M,5076
50
50
  primitive/jobs/commands.py,sha256=MxPCkBEYW_eLNqgCRYeyj7ZcLOFAWfpVZlqDR2Y_S0o,830
51
51
  primitive/jobs/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  primitive/jobs/graphql/fragments.py,sha256=1_ZttT7dx36KDC3DClJz9M8LMpsPwXySBygHSiUEcGg,619
@@ -88,8 +88,8 @@ primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIU
88
88
  primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,370
89
89
  primitive/utils/shell.py,sha256=jWzb7ky7p987dJas6ZvarK3IJNZ5cwBXcryRWb9Uh6U,2072
90
90
  primitive/utils/text.py,sha256=XiESMnlhjQ534xE2hMNf08WehE1SKaYFRNih0MmnK0k,829
91
- primitive-0.2.8.dist-info/METADATA,sha256=RyG9KfWAyBzjhGfllYVFlf9yzdMKefw-2SRLK_7sgzc,3669
92
- primitive-0.2.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- primitive-0.2.8.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
94
- primitive-0.2.8.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
95
- primitive-0.2.8.dist-info/RECORD,,
91
+ primitive-0.2.10.dist-info/METADATA,sha256=LB4jc6D9OV1PUeLtYV6sXwc_XA7Hiu7jZBfzuxaqdN0,3670
92
+ primitive-0.2.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ primitive-0.2.10.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
94
+ primitive-0.2.10.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
95
+ primitive-0.2.10.dist-info/RECORD,,