primitive 0.1.6__py3-none-any.whl → 0.1.9__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@steins.studio>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.1.6"
4
+ __version__ = "0.1.9"
@@ -1,6 +1,8 @@
1
+ import sys
1
2
  from time import sleep
2
3
  from primitive.utils.actions import BaseAction
3
4
  from loguru import logger
5
+ from primitive.__about__ import __version__
4
6
 
5
7
 
6
8
  class Agent(BaseAction):
@@ -8,52 +10,62 @@ class Agent(BaseAction):
8
10
  self,
9
11
  ):
10
12
  logger.enable("primitive")
11
- logger.debug("Starting Primitive Agent")
12
- while True:
13
- hardware = self.primitive.hardware.get_own_hardware_details()
14
-
15
- active_reservation_id = None
16
- if hardware.get("activeReservation"):
17
- active_reservation_id = hardware["activeReservation"]["id"]
18
- if not active_reservation_id:
19
- logger.debug("No active reservation found")
20
- sleep(5)
21
- continue
13
+ logger.info(" [*] primitive")
14
+ logger.info(f" [*] Version: {__version__}")
22
15
 
23
- job_runs_data = self.primitive.projects.get_job_runs(
24
- status="pending", first=1, reservation_id=active_reservation_id
25
- )
16
+ # self.primitive.hardware.update_hardware_system_info()
17
+ self.primitive.hardware.check_in_http(is_available=True, is_online=True)
26
18
 
27
- pending_job_runs = [
28
- edge["node"] for edge in job_runs_data["jobRuns"]["edges"]
29
- ]
19
+ try:
20
+ while True:
21
+ hardware = self.primitive.hardware.get_own_hardware_details()
30
22
 
31
- for job_run in pending_job_runs:
32
- logger.debug("Found pending Job Run")
33
- logger.debug(f"Job Run ID: {job_run['id']}")
34
- logger.debug(f"Job Name: {job_run['job']['name']}")
23
+ active_reservation_id = None
24
+ if hardware.get("activeReservation"):
25
+ active_reservation_id = hardware["activeReservation"]["id"]
26
+ if not active_reservation_id:
27
+ logger.debug("No active reservation found")
28
+ sleep(5)
29
+ continue
35
30
 
36
- if job_run["job"]["slug"] == "lint":
37
- logger.debug("Executing Lint Job")
31
+ job_runs_data = self.primitive.projects.get_job_runs(
32
+ status="pending", first=1, reservation_id=active_reservation_id
33
+ )
38
34
 
39
- self.primitive.projects.job_run_update(
40
- job_run["id"], status="request_completed"
41
- )
35
+ pending_job_runs = [
36
+ edge["node"] for edge in job_runs_data["jobRuns"]["edges"]
37
+ ]
38
+
39
+ for job_run in pending_job_runs:
40
+ logger.debug("Found pending Job Run")
41
+ logger.debug(f"Job Run ID: {job_run['id']}")
42
+ logger.debug(f"Job Name: {job_run['job']['name']}")
43
+
44
+ if job_run["job"]["slug"] == "lint":
45
+ logger.debug("Executing Lint Job")
42
46
 
43
- result, message = self.primitive.lint.execute()
44
- if result:
45
- self.primitive.projects.job_run_update(
46
- job_run["id"],
47
- status="request_completed",
48
- conclusion="success",
49
- stdout=message,
50
- )
51
- else:
52
47
  self.primitive.projects.job_run_update(
53
- job_run["id"],
54
- status="request_completed",
55
- conclusion="failure",
56
- stdout=message,
48
+ job_run["id"], status="request_completed"
57
49
  )
58
50
 
59
- sleep(5)
51
+ result, message = self.primitive.lint.execute()
52
+ if result:
53
+ self.primitive.projects.job_run_update(
54
+ job_run["id"],
55
+ status="request_completed",
56
+ conclusion="success",
57
+ stdout=message,
58
+ )
59
+ else:
60
+ self.primitive.projects.job_run_update(
61
+ job_run["id"],
62
+ status="request_completed",
63
+ conclusion="failure",
64
+ stdout=message,
65
+ )
66
+
67
+ sleep(5)
68
+ except KeyboardInterrupt:
69
+ logger.info(" [*] Stopping primitive...")
70
+ self.primitive.hardware.check_in_http(is_available=False, is_online=False)
71
+ sys.exit()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: primitive
3
- Version: 0.1.6
3
+ Version: 0.1.9
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
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
19
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
- Requires-Python: >=3.12
20
+ Requires-Python: >=3.11
21
21
  Requires-Dist: click
22
22
  Requires-Dist: gql[all]
23
23
  Requires-Dist: ipdb
@@ -1,8 +1,8 @@
1
- primitive/__about__.py,sha256=P5wASxX77-g_YRSjb4MnBDu4CWjITURFbU8iN8R3rlM,128
1
+ primitive/__about__.py,sha256=ZISDHEwYuDZ5fKFtcsW-ewhfzmkOO8yp5qFnYsNgT08,128
2
2
  primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
3
3
  primitive/cli.py,sha256=LXSpPtqQLxkOXsnsbs4UN3n7G_pHCz8AkBFCrk7Is4g,1796
4
4
  primitive/client.py,sha256=3RMRNY4ZiGT2OKnZtquWyrXjRSgDe5HlZvtFNKZErLQ,2083
5
- primitive/agent/actions.py,sha256=Fq6GEJqIwv-hWABFOl3YC8l0gBNME3byycNYqICpZG8,2144
5
+ primitive/agent/actions.py,sha256=9y8_zKg9fUV4VT_rx9geSo7sS0oBR5jWWMdXMJwMmFk,2758
6
6
  primitive/agent/commands.py,sha256=-dVDilELfkGfbZB7qfEPs77Dm1oT62qJj4tsIk4KoxI,254
7
7
  primitive/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  primitive/auth/actions.py,sha256=N2bGcwXNsB89pzs66gF9A5_WzUScY5fhfOyWixqo2y8,1054
@@ -27,8 +27,8 @@ primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIU
27
27
  primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,370
28
28
  primitive/utils/shell.py,sha256=-7UjQaBqSGHzEEyX8pNjeYFFP0P3lVnDV0OkgPz1qHU,1050
29
29
  primitive/utils/verible.py,sha256=QYczN1IvxODfj4jeq0nqjFuF0Oi0Zdx-Q32ySOJgcw8,2205
30
- primitive-0.1.6.dist-info/METADATA,sha256=k2nIZBpBfzNRizaA-5a9BW7qtOGmdQTeNF2lOdvocPU,1817
31
- primitive-0.1.6.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
- primitive-0.1.6.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
33
- primitive-0.1.6.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
34
- primitive-0.1.6.dist-info/RECORD,,
30
+ primitive-0.1.9.dist-info/METADATA,sha256=MZhFwacKp68g2ffhknZfVy84VRSTgCsJu7zMttrE1V8,1817
31
+ primitive-0.1.9.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
+ primitive-0.1.9.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
33
+ primitive-0.1.9.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
34
+ primitive-0.1.9.dist-info/RECORD,,