fred-oss 0.8.0__tar.gz → 0.10.0__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.
- {fred_oss-0.8.0/src/main/fred_oss.egg-info → fred_oss-0.10.0}/PKG-INFO +1 -1
- fred_oss-0.10.0/src/main/fred/version +1 -0
- fred_oss-0.10.0/src/main/fred/worker/runner/client.py +104 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/worker/runner/handler.py +11 -11
- {fred_oss-0.8.0 → fred_oss-0.10.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred_oss.egg-info/SOURCES.txt +1 -0
- fred_oss-0.8.0/src/main/fred/version +0 -1
- {fred_oss-0.8.0 → fred_oss-0.10.0}/MANIFEST.in +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/NOTICE.txt +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/README.md +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/requirements.txt +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/setup.cfg +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/setup.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/cli/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/cli/__main__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/cli/interface.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/cli/main.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/runtimes/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/wrappers/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/runpod/cli_ext.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/runpod/helper.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/maturity.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/settings.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/utils/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/utils/dateops.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/utils/runtime.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/version.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/worker/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/worker/interface.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/worker/runner/__init__.py +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
- {fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred_oss.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.10.0
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
import json
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
from fred.settings import (
|
|
6
|
+
get_environ_variable,
|
|
7
|
+
logger_manager,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from redis import Redis
|
|
11
|
+
|
|
12
|
+
logger = logger_manager.get_logger(name=__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True, slots=True)
|
|
16
|
+
class RunnerClient:
|
|
17
|
+
instance: Redis
|
|
18
|
+
req_queue: str
|
|
19
|
+
res_queue: str
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def auto(cls, **kwargs) -> "RunnerClient":
|
|
23
|
+
redis_configs = {
|
|
24
|
+
"host": kwargs.get("host") or get_environ_variable(name="REDIS_HOST", default="localhost"),
|
|
25
|
+
"port": int(kwargs.get("port") or get_environ_variable(name="REDIS_PORT", default=6379)),
|
|
26
|
+
"password": get_environ_variable(name="REDIS_PASSWORD", default=None),
|
|
27
|
+
"db": int(kwargs.get("db") or get_environ_variable(name="REDIS_DB", default=0)),
|
|
28
|
+
"decode_responses": True,
|
|
29
|
+
**kwargs.pop("redis_configs", {}),
|
|
30
|
+
}
|
|
31
|
+
redis_instance = Redis(**redis_configs)
|
|
32
|
+
req_queue = kwargs.get("request_queue") or get_environ_variable(name="FRD_RUNNER_REQUEST_QUEUE", default=None) or (
|
|
33
|
+
logger.warning("Redis request queue not specified; defaulting to 'req:demo'.") or "req:demo"
|
|
34
|
+
)
|
|
35
|
+
res_queue = kwargs.get("response_queue") or get_environ_variable(name="FRD_RUNNER_RESPONSE_QUEUE", default=None) or (
|
|
36
|
+
logger.warning("Redis response queue not specified; defaulting to inferring pattern.") or f"res:{req_queue.split(':')[-1]}"
|
|
37
|
+
)
|
|
38
|
+
logger.info(f"Connecting to Redis, using request queue '{req_queue}' and response queue '{res_queue}'.")
|
|
39
|
+
return cls(
|
|
40
|
+
instance=redis_instance,
|
|
41
|
+
req_queue=req_queue,
|
|
42
|
+
res_queue=res_queue,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def PING(self):
|
|
47
|
+
return self.signal("PING")
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def STOP(self):
|
|
51
|
+
return self.signal("STOP")
|
|
52
|
+
|
|
53
|
+
def signal(self, signal: str):
|
|
54
|
+
# TODO: Validate signals via enum
|
|
55
|
+
self.instance.lpush(self.req_queue, signal)
|
|
56
|
+
|
|
57
|
+
def send(self, item: dict, uuid_hash: bool = False) -> str:
|
|
58
|
+
item_id = item.get("item_id")
|
|
59
|
+
item_str = json.dumps(item)
|
|
60
|
+
if not item_id:
|
|
61
|
+
logger.warning("Item does not have 'item_id'; assigning a UUID based on the hash.")
|
|
62
|
+
item["item_id"] = item_id = str(uuid.uuid5(uuid.NAMESPACE_DNS, item_str)) \
|
|
63
|
+
if uuid_hash else str(uuid.uuid4())
|
|
64
|
+
item_str = json.dumps(item)
|
|
65
|
+
self.instance.lpush(self.req_queue, item_str)
|
|
66
|
+
self.instance.set(f"item_status:{item_id}", "IN_QUEUE")
|
|
67
|
+
return item_id
|
|
68
|
+
|
|
69
|
+
def fetch_status(self, item_id: str) -> str | None:
|
|
70
|
+
status_raw = self.instance.get(f"item_status:{item_id}")
|
|
71
|
+
if not status_raw:
|
|
72
|
+
logger.info(f"No status found for item_id '{item_id}'.")
|
|
73
|
+
return None
|
|
74
|
+
return status_raw.decode("utf-8")
|
|
75
|
+
|
|
76
|
+
def fetch_result(self, item_id: str, blocking: bool = False) -> dict | None:
|
|
77
|
+
match self.fetch_status(item_id=item_id):
|
|
78
|
+
case None:
|
|
79
|
+
logger.info(f"No status found for item_id '{item_id}'.")
|
|
80
|
+
return None
|
|
81
|
+
case "IN_QUEUE" | "PROCESSING":
|
|
82
|
+
if blocking:
|
|
83
|
+
logger.info(f"Blocking until item '{item_id}' is completed.")
|
|
84
|
+
while (status := self.fetch_status(item_id=item_id)) in ("IN_QUEUE", "PROCESSING"):
|
|
85
|
+
continue
|
|
86
|
+
else:
|
|
87
|
+
logger.info(f"Item '{item_id}' is still in progress (current status: '{self.fetch_status(item_id=item_id)}').")
|
|
88
|
+
return None
|
|
89
|
+
case "FAILED":
|
|
90
|
+
logger.error(f"Item '{item_id}' processing failed.")
|
|
91
|
+
return None
|
|
92
|
+
case "COMPLETED":
|
|
93
|
+
result_raw = self.instance.get(f"item_output:{item_id}")
|
|
94
|
+
if result_raw:
|
|
95
|
+
try:
|
|
96
|
+
return json.loads(result_raw)
|
|
97
|
+
except json.JSONDecodeError as e:
|
|
98
|
+
logger.error(f"Error decoding JSON result for item_id '{item_id}': {e}")
|
|
99
|
+
return None
|
|
100
|
+
else:
|
|
101
|
+
logger.error(f"No result found for item_id '{item_id}'.")
|
|
102
|
+
return None
|
|
103
|
+
case status:
|
|
104
|
+
logger.warning(f"Item '{item_id}' has unrecognized status '{status}'. Proceeding to fetch result.")
|
|
@@ -27,14 +27,14 @@ class RunnerHandler(HandlerInterface):
|
|
|
27
27
|
lifespan = payload.get("lifetime", 3600) # Default to 1 hour if not specified
|
|
28
28
|
timeout = payload.get("timeout", 30) # Default to 30 seconds if not specified
|
|
29
29
|
# Get Redis connection details from payload or environment variables
|
|
30
|
-
redis_configs =
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
30
|
+
redis_configs = {
|
|
31
|
+
"host": get_environ_variable(name="REDIS_HOST", default="localhost"),
|
|
32
|
+
"port": int(get_environ_variable(name="REDIS_PORT", default=6379)),
|
|
33
|
+
"password": get_environ_variable(name="REDIS_PASSWORD", default=None),
|
|
34
|
+
"db": int(get_environ_variable(name="REDIS_DB", default=0)),
|
|
35
|
+
"decode_responses": True,
|
|
36
|
+
**payload.pop("redis_configs", {}),
|
|
37
|
+
}
|
|
38
38
|
# Connect to Redis
|
|
39
39
|
redis = Redis(**redis_configs)
|
|
40
40
|
req_queue = payload.pop("redis_request_queue", None) or get_environ_variable(name="FRD_RUNNER_REQUEST_QUEUE", default=None) or (
|
|
@@ -64,16 +64,16 @@ class RunnerHandler(HandlerInterface):
|
|
|
64
64
|
break
|
|
65
65
|
# Fetch item from Redis queue
|
|
66
66
|
try:
|
|
67
|
-
|
|
67
|
+
item_str = redis.rpop(req_queue)
|
|
68
68
|
except Exception as e:
|
|
69
69
|
logger.error(f"Error fetching item from Redis queue '{req_queue}': {e}")
|
|
70
70
|
continue
|
|
71
71
|
# If no item, iterate again
|
|
72
|
-
if not
|
|
72
|
+
if not item_str:
|
|
73
73
|
continue
|
|
74
74
|
try:
|
|
75
75
|
# Handle special signals
|
|
76
|
-
match
|
|
76
|
+
match item_str:
|
|
77
77
|
case "STOP" | "SHUTDOWN" | "TERMINATE":
|
|
78
78
|
logger.info("Received STOP signal; exiting runner loop.")
|
|
79
79
|
break
|
|
@@ -28,6 +28,7 @@ src/main/fred/utils/runtime.py
|
|
|
28
28
|
src/main/fred/worker/__init__.py
|
|
29
29
|
src/main/fred/worker/interface.py
|
|
30
30
|
src/main/fred/worker/runner/__init__.py
|
|
31
|
+
src/main/fred/worker/runner/client.py
|
|
31
32
|
src/main/fred/worker/runner/handler.py
|
|
32
33
|
src/main/fred_oss.egg-info/PKG-INFO
|
|
33
34
|
src/main/fred_oss.egg-info/SOURCES.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.8.0
|
|
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
|
{fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/runtimes/__init__.py
RENAMED
|
File without changes
|
{fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/runtimes/scanner.py
RENAMED
|
File without changes
|
|
File without changes
|
{fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/wrappers/__init__.py
RENAMED
|
File without changes
|
{fred_oss-0.8.0 → fred_oss-0.10.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py
RENAMED
|
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
|