fred-oss 0.4.1__tar.gz → 0.5.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.4.1/src/main/fred_oss.egg-info → fred_oss-0.5.0}/PKG-INFO +1 -1
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/runpod/cli_ext.py +3 -3
- fred_oss-0.5.0/src/main/fred/integrations/runpod/helper.py +25 -0
- fred_oss-0.5.0/src/main/fred/version +1 -0
- fred_oss-0.5.0/src/main/fred/worker/__init__.py +11 -0
- fred_oss-0.4.1/src/main/fred/integrations/runpod/helper.py → fred_oss-0.5.0/src/main/fred/worker/interface.py +33 -9
- {fred_oss-0.4.1 → fred_oss-0.5.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred_oss.egg-info/SOURCES.txt +2 -0
- fred_oss-0.4.1/src/main/fred/version +0 -1
- {fred_oss-0.4.1 → fred_oss-0.5.0}/MANIFEST.in +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/NOTICE.txt +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/README.md +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/requirements.txt +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/setup.cfg +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/setup.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/cli/__init__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/cli/__main__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/cli/interface.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/cli/main.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/runtimes/__init__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/wrappers/__init__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/maturity.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/settings.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/utils/__init__.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/utils/dateops.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/utils/runtime.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/version.py +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
- {fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred_oss.egg-info/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from fred.
|
|
1
|
+
from fred.worker.interface import HandlerInterface
|
|
2
2
|
from fred.cli.interface import IntegrationExtCLI
|
|
3
3
|
from fred.settings import logger_manager
|
|
4
4
|
|
|
@@ -8,8 +8,8 @@ logger = logger_manager.get_logger(name=__name__)
|
|
|
8
8
|
|
|
9
9
|
class RunPodExt(IntegrationExtCLI):
|
|
10
10
|
|
|
11
|
-
def get_handler_instance(self, import_pattern: str, handler_classname: str) ->
|
|
12
|
-
return
|
|
11
|
+
def get_handler_instance(self, import_pattern: str, handler_classname: str) -> HandlerInterface:
|
|
12
|
+
return HandlerInterface.find_handler(
|
|
13
13
|
import_pattern=import_pattern,
|
|
14
14
|
handler_classname=handler_classname,
|
|
15
15
|
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
|
|
3
|
+
from fred.maturity import Maturity, MaturityLevel
|
|
4
|
+
from fred.worker.interface import HandlerInterface
|
|
5
|
+
from fred.settings import logger_manager
|
|
6
|
+
|
|
7
|
+
logger = logger_manager.get_logger(name=__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module_maturity = Maturity(
|
|
11
|
+
level=MaturityLevel.TO_BE_DEPRECATED,
|
|
12
|
+
reference=__name__,
|
|
13
|
+
message=(
|
|
14
|
+
"Runpod Helper implementation is soon to be deprecated! "
|
|
15
|
+
"Please use the Fred-Worker interface instead (HandlerInterface)."
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True, slots=False)
|
|
21
|
+
class HandlerHelper(HandlerInterface):
|
|
22
|
+
|
|
23
|
+
def __post_init__(self):
|
|
24
|
+
super().__post_init__()
|
|
25
|
+
logger.warning("Runpod Helper is soon to be deprecated! Please use Fred-Worker interface instead.")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.5.0
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from fred.maturity import Maturity, MaturityLevel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module_maturity = Maturity(
|
|
5
|
+
level=MaturityLevel.ALPHA,
|
|
6
|
+
reference=__name__,
|
|
7
|
+
message=(
|
|
8
|
+
"Fred-Worker implementation is in early development "
|
|
9
|
+
"and therefore currently with incomplete and unstable features."
|
|
10
|
+
)
|
|
11
|
+
)
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import time
|
|
2
|
-
from dataclasses import dataclass, field
|
|
3
2
|
from typing import Optional
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
4
|
|
|
5
5
|
from fred.utils.dateops import datetime_utcnow
|
|
6
|
-
from fred.settings import
|
|
6
|
+
from fred.settings import (
|
|
7
|
+
get_environ_variable,
|
|
8
|
+
logger_manager,
|
|
9
|
+
)
|
|
7
10
|
|
|
8
11
|
logger = logger_manager.get_logger(name=__name__)
|
|
9
12
|
|
|
10
13
|
|
|
11
|
-
@dataclass(frozen=True, slots=
|
|
12
|
-
class
|
|
14
|
+
@dataclass(frozen=True, slots=False)
|
|
15
|
+
class HandlerInterface:
|
|
16
|
+
"""Base interface for handling events in a worker environment.
|
|
17
|
+
|
|
18
|
+
This class provides a structure for processing events with metadata tracking.
|
|
19
|
+
Subclasses should implement the `handler` method to define specific event processing logic.
|
|
20
|
+
|
|
21
|
+
Considerations: This interface is designed to be extended for various worker implementations, starting with Runpod.
|
|
22
|
+
|
|
23
|
+
Attributes:
|
|
24
|
+
context (dict): A dictionary to hold contextual information for the handler; this can be modified as needed.
|
|
25
|
+
metadata (dict): A dictionary to track metadata about the handler's operations.
|
|
26
|
+
"""
|
|
13
27
|
context: dict = field(default_factory=dict)
|
|
14
28
|
metadata: dict = field(default_factory=dict)
|
|
15
29
|
|
|
@@ -22,16 +36,16 @@ class HandlerHelper:
|
|
|
22
36
|
import_pattern: str,
|
|
23
37
|
handler_classname: str,
|
|
24
38
|
**init_kwargs,
|
|
25
|
-
) -> '
|
|
39
|
+
) -> 'HandlerInterface':
|
|
26
40
|
import importlib
|
|
27
41
|
|
|
28
42
|
# Dynamically import the handler class
|
|
29
43
|
handler_module = importlib.import_module(import_pattern)
|
|
30
44
|
handler_cls = getattr(handler_module, handler_classname)
|
|
31
|
-
# Ensure the handler class exists and is a subclass of
|
|
45
|
+
# Ensure the handler class exists and is a subclass of HandlerInterface
|
|
32
46
|
if not handler_cls or not issubclass(handler_cls, cls):
|
|
33
|
-
logger.error(f"Handler class '{handler_classname}' not found or is not a subclass of
|
|
34
|
-
raise ValueError(f"Handler '{handler_classname}' not found in module '{import_pattern}' or is not a subclass of
|
|
47
|
+
logger.error(f"Handler class '{handler_classname}' not found or is not a subclass of HandlerInterface: {handler_cls}")
|
|
48
|
+
raise ValueError(f"Handler '{handler_classname}' not found in module '{import_pattern}' or is not a subclass of HandlerInterface.")
|
|
35
49
|
kwargs = {
|
|
36
50
|
"metadata": {
|
|
37
51
|
"handler_found_at": datetime_utcnow().isoformat()
|
|
@@ -44,6 +58,16 @@ class HandlerHelper:
|
|
|
44
58
|
logger.warning("Handler method not implemented.")
|
|
45
59
|
return payload
|
|
46
60
|
|
|
61
|
+
@property
|
|
62
|
+
def metadata_prepared(self) -> dict:
|
|
63
|
+
if not int(get_environ_variable("FRD_ENFORCE_METADATA_SERIALIZATION", default="0")):
|
|
64
|
+
return self.metadata
|
|
65
|
+
import json
|
|
66
|
+
# Ensure serializability
|
|
67
|
+
# TODO: Allow custom serialization methods
|
|
68
|
+
metadata_serialized = json.dumps(self.metadata, default=str)
|
|
69
|
+
return json.loads(metadata_serialized)
|
|
70
|
+
|
|
47
71
|
def run(self, event: dict) -> dict:
|
|
48
72
|
job_event_identifier = event.get("id")
|
|
49
73
|
self.metadata["run_seq"] = self.metadata.get("run_seq", 0) + 1
|
|
@@ -65,5 +89,5 @@ class HandlerHelper:
|
|
|
65
89
|
"duration": time.perf_counter() - start_time,
|
|
66
90
|
"started_at": started_at,
|
|
67
91
|
"response": response,
|
|
68
|
-
"metadata": self.
|
|
92
|
+
"metadata": self.metadata_prepared,
|
|
69
93
|
}
|
|
@@ -25,6 +25,8 @@ src/main/fred/integrations/runpod/helper.py
|
|
|
25
25
|
src/main/fred/utils/__init__.py
|
|
26
26
|
src/main/fred/utils/dateops.py
|
|
27
27
|
src/main/fred/utils/runtime.py
|
|
28
|
+
src/main/fred/worker/__init__.py
|
|
29
|
+
src/main/fred/worker/interface.py
|
|
28
30
|
src/main/fred_oss.egg-info/PKG-INFO
|
|
29
31
|
src/main/fred_oss.egg-info/SOURCES.txt
|
|
30
32
|
src/main/fred_oss.egg-info/dependency_links.txt
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.4.1
|
|
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.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/runtimes/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fred_oss-0.4.1 → fred_oss-0.5.0}/src/main/fred/integrations/databricks/wrappers/__init__.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
|