primitive 0.2.36__py3-none-any.whl → 0.2.37__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 +1 -1
- primitive/agent/actions.py +12 -3
- primitive/agent/commands.py +3 -2
- primitive/agent/runner.py +1 -2
- primitive/utils/logging.py +4 -3
- {primitive-0.2.36.dist-info → primitive-0.2.37.dist-info}/METADATA +1 -1
- {primitive-0.2.36.dist-info → primitive-0.2.37.dist-info}/RECORD +10 -10
- {primitive-0.2.36.dist-info → primitive-0.2.37.dist-info}/WHEEL +0 -0
- {primitive-0.2.36.dist-info → primitive-0.2.37.dist-info}/entry_points.txt +0 -0
- {primitive-0.2.36.dist-info → primitive-0.2.37.dist-info}/licenses/LICENSE.txt +0 -0
primitive/__about__.py
CHANGED
primitive/agent/actions.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import sys
|
2
2
|
from time import sleep
|
3
|
+
from typing import Optional
|
3
4
|
|
4
5
|
from loguru import logger
|
5
6
|
|
@@ -12,9 +13,7 @@ from primitive.utils.actions import BaseAction
|
|
12
13
|
|
13
14
|
|
14
15
|
class Agent(BaseAction):
|
15
|
-
def execute(
|
16
|
-
self,
|
17
|
-
):
|
16
|
+
def execute(self, job_run_id: Optional[str] = None):
|
18
17
|
logger.remove()
|
19
18
|
logger.add(
|
20
19
|
sink=sys.stderr,
|
@@ -26,6 +25,12 @@ class Agent(BaseAction):
|
|
26
25
|
logger.info("primitive agent")
|
27
26
|
logger.info(f"Version: {__version__}")
|
28
27
|
|
28
|
+
# TODO: tighten logic for determining if we're running in a container
|
29
|
+
RUNNING_IN_CONTAINER = False
|
30
|
+
if job_run_id is not None:
|
31
|
+
logger.info("Running in container...")
|
32
|
+
RUNNING_IN_CONTAINER = True
|
33
|
+
|
29
34
|
# Wait for monitor to make database
|
30
35
|
wait_for_db()
|
31
36
|
|
@@ -100,6 +105,10 @@ class Agent(BaseAction):
|
|
100
105
|
# This should probably eventually be another daemon?
|
101
106
|
uploader.scan()
|
102
107
|
|
108
|
+
if RUNNING_IN_CONTAINER:
|
109
|
+
logger.info("Running in container, exiting after job run")
|
110
|
+
break
|
111
|
+
|
103
112
|
sleep(5)
|
104
113
|
except KeyboardInterrupt:
|
105
114
|
logger.info("Stopping primitive agent...")
|
primitive/agent/commands.py
CHANGED
@@ -7,8 +7,9 @@ if typing.TYPE_CHECKING:
|
|
7
7
|
|
8
8
|
|
9
9
|
@click.command("agent")
|
10
|
+
@click.option("--job-run-id", type=str, help="Explicit Job Run to pull")
|
10
11
|
@click.pass_context
|
11
|
-
def cli(context):
|
12
|
+
def cli(context, job_run_id: typing.Optional[str] = None):
|
12
13
|
"""agent"""
|
13
14
|
primitive: Primitive = context.obj.get("PRIMITIVE")
|
14
|
-
primitive.agent.execute()
|
15
|
+
primitive.agent.execute(job_run_id=job_run_id)
|
primitive/agent/runner.py
CHANGED
@@ -7,13 +7,12 @@ from enum import Enum, IntEnum
|
|
7
7
|
from pathlib import Path, PurePath
|
8
8
|
from typing import Dict, List, TypedDict
|
9
9
|
|
10
|
-
from ..utils.logging import log_context, fmt
|
11
|
-
|
12
10
|
import yaml
|
13
11
|
from loguru import logger
|
14
12
|
|
15
13
|
from ..db.models import JobRun
|
16
14
|
from ..utils.cache import get_artifacts_cache, get_logs_cache, get_sources_cache
|
15
|
+
from ..utils.logging import fmt, log_context
|
17
16
|
from ..utils.shell import env_to_dict
|
18
17
|
|
19
18
|
try:
|
primitive/utils/logging.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
import json
|
2
|
+
from datetime import timezone
|
1
3
|
from functools import wraps
|
4
|
+
|
2
5
|
from loguru import logger
|
3
|
-
from datetime import timezone
|
4
|
-
import json
|
5
6
|
|
6
7
|
|
7
8
|
def log_context(**context):
|
@@ -18,7 +19,7 @@ def log_context(**context):
|
|
18
19
|
|
19
20
|
def fmt(record) -> str:
|
20
21
|
extra = record["extra"]
|
21
|
-
label = extra
|
22
|
+
label = extra.get("label", None)
|
22
23
|
tag = extra.get("tag", None)
|
23
24
|
type = extra.get("type", "system")
|
24
25
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.37
|
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=
|
1
|
+
primitive/__about__.py,sha256=k_4SlrPFVlD5xhSWVsBLRpaxZRnyooKrAmVPOvghuL0,130
|
2
2
|
primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
|
3
3
|
primitive/cli.py,sha256=g7EtHI9MATAB0qQu5w-WzbXtxz_8zu8z5E7sETmMkKU,2509
|
4
4
|
primitive/client.py,sha256=h8WZVnQylVe0vbpuyC8YZHl2JyITSPC-1HbUcmrE5pc,3623
|
5
5
|
primitive/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
primitive/agent/actions.py,sha256=
|
7
|
-
primitive/agent/commands.py,sha256=
|
8
|
-
primitive/agent/runner.py,sha256=
|
6
|
+
primitive/agent/actions.py,sha256=vq4_CZy7Mn37jUg-JPuJlMLtcx4sMXp6tUNvXGZOOyQ,4128
|
7
|
+
primitive/agent/commands.py,sha256=kqa-PGqmzS-APd4BSMAkX4l8SdK5N1PRQwq9S8jBjsw,390
|
8
|
+
primitive/agent/runner.py,sha256=ZlFC7Eq0NXOSCOvMtDu9gWKF2sa4QMkeG-wH-R-9iOc,15463
|
9
9
|
primitive/agent/uploader.py,sha256=ZzrzsajNBogwEC7mT6Ejy0h2Jd9axMYGzt9pbCvVMlk,3171
|
10
10
|
primitive/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
primitive/auth/actions.py,sha256=9NIEXJ1BNJutJs6AMMSjMN_ziONUAUhY_xHwojYJCLA,942
|
@@ -92,13 +92,13 @@ primitive/utils/chunk_size.py,sha256=PAuVuirUTA9oRXyjo1c6MWxo31WVBRkWMuWw-AS58Bw
|
|
92
92
|
primitive/utils/config.py,sha256=DlFM5Nglo22WPtbpZSVtH7NX-PTMaKYlcrUE7GPRG4c,1058
|
93
93
|
primitive/utils/daemons.py,sha256=mSoSHitiGfS4KYAEK9sKsiv_YcACHKgY3qISnDpUUIE,1086
|
94
94
|
primitive/utils/exceptions.py,sha256=DrYHTcCAJGC7cCUwOx_FmdlVLWRdpzvDvpLb82heppE,311
|
95
|
-
primitive/utils/logging.py,sha256=
|
95
|
+
primitive/utils/logging.py,sha256=vpwu-hByZC1BgJfUi6iSfAxzCobP_zg9-99EUf80KtY,1132
|
96
96
|
primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIUk,3058
|
97
97
|
primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,370
|
98
98
|
primitive/utils/shell.py,sha256=Z4zxmOaSyGCrS0D6I436iQci-ewHLt4UxVg1CD9Serc,2171
|
99
99
|
primitive/utils/text.py,sha256=XiESMnlhjQ534xE2hMNf08WehE1SKaYFRNih0MmnK0k,829
|
100
|
-
primitive-0.2.
|
101
|
-
primitive-0.2.
|
102
|
-
primitive-0.2.
|
103
|
-
primitive-0.2.
|
104
|
-
primitive-0.2.
|
100
|
+
primitive-0.2.37.dist-info/METADATA,sha256=r-F7XhBMe84oxARfJ9ZMbwVAcV5jQojsGrhxvWlK9E0,3569
|
101
|
+
primitive-0.2.37.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
102
|
+
primitive-0.2.37.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
|
103
|
+
primitive-0.2.37.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
|
104
|
+
primitive-0.2.37.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|