fred-oss 0.19.0__tar.gz → 0.21.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.19.0/src/main/fred_oss.egg-info → fred_oss-0.21.0}/PKG-INFO +1 -1
- fred_oss-0.21.0/src/main/fred/monad/__init__.py +11 -0
- fred_oss-0.21.0/src/main/fred/monad/_either.py +99 -0
- fred_oss-0.21.0/src/main/fred/monad/catalog.py +11 -0
- fred_oss-0.21.0/src/main/fred/monad/interface.py +22 -0
- fred_oss-0.21.0/src/main/fred/version +1 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred_oss.egg-info/SOURCES.txt +4 -0
- fred_oss-0.19.0/src/main/fred/version +0 -1
- {fred_oss-0.19.0 → fred_oss-0.21.0}/MANIFEST.in +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/NOTICE.txt +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/README.md +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/requirements.txt +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/setup.cfg +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/setup.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/cli/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/cli/__main__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/cli/interface.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/cli/main.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/comp/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/comp/_keyval.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/comp/_queue.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/comp/catalog.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/comp/interface.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/service/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/service/_redis.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/service/_stdlib.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/service/catalog.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/service/interface.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/dao/service/utils.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/runtimes/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/wrappers/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/runpod/cli_ext.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/runpod/helper.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/maturity.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/settings.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/utils/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/utils/dateops.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/utils/runtime.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/version.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/interface.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/client.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/handler.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/info.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/plugins/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/plugins/_local.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/plugins/catalog.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/plugins/interface.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/cli_ext.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/routers/__init__.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/routers/_runner.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/routers/catalog.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/routers/interface.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/rest/server.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/worker/runner/utils.py +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
- {fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred_oss.egg-info/top_level.txt +0 -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-Monad implementation is in early development "
|
|
9
|
+
"and therefore currently with incomplete and unstable features."
|
|
10
|
+
)
|
|
11
|
+
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from functools import wraps
|
|
3
|
+
from typing import (
|
|
4
|
+
Callable,
|
|
5
|
+
Generic,
|
|
6
|
+
Generator,
|
|
7
|
+
TypeVar,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from fred.settings import logger_manager
|
|
11
|
+
from fred.monad.interface import MonadInterface
|
|
12
|
+
|
|
13
|
+
logger = logger_manager.get_logger(__name__)
|
|
14
|
+
|
|
15
|
+
A = TypeVar("A")
|
|
16
|
+
B = TypeVar("B")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True, slots=True)
|
|
20
|
+
class EitherWrapper(Generic[A]):
|
|
21
|
+
function: Callable[..., A]
|
|
22
|
+
|
|
23
|
+
def __call__(self, *args, **kwargs) -> A:
|
|
24
|
+
return self.function(*args, **kwargs)
|
|
25
|
+
|
|
26
|
+
def either(self, *args, **kwargs)-> 'Either[A]':
|
|
27
|
+
try:
|
|
28
|
+
return Right[A].from_value(val=self.function(*args, **kwargs))
|
|
29
|
+
except Exception as e:
|
|
30
|
+
return Left(exception=e)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Either(MonadInterface[A]):
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def comprehension(cls, generator: Generator):
|
|
37
|
+
try:
|
|
38
|
+
return Either.from_value(val=next(generator))
|
|
39
|
+
except Exception as e:
|
|
40
|
+
return Left(exception=e)
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def decorator(cls, function: Callable):
|
|
44
|
+
return wraps(function, updated=())(EitherWrapper(function=function))
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def from_value(cls, val: A) -> 'Either[A]':
|
|
48
|
+
if isinstance(val, Exception):
|
|
49
|
+
return Left(exception=val)
|
|
50
|
+
return Right(value=val)
|
|
51
|
+
|
|
52
|
+
def resolve(self) -> A:
|
|
53
|
+
match self:
|
|
54
|
+
case Right(value=value):
|
|
55
|
+
return value
|
|
56
|
+
case Left(exception=exception):
|
|
57
|
+
raise exception
|
|
58
|
+
case _:
|
|
59
|
+
raise TypeError("Unknown Either type")
|
|
60
|
+
|
|
61
|
+
def __iter__(self) -> Generator[A, None, None]:
|
|
62
|
+
match self:
|
|
63
|
+
case Right(value=value):
|
|
64
|
+
yield from [value]
|
|
65
|
+
case Left(exception=exception):
|
|
66
|
+
logger.warning(f"Attempted to iterate over Left: {exception}")
|
|
67
|
+
yield from []
|
|
68
|
+
case _:
|
|
69
|
+
raise TypeError("Unknown Either type")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass(frozen=True, slots=True)
|
|
73
|
+
class Right(Either[A]):
|
|
74
|
+
value: A
|
|
75
|
+
|
|
76
|
+
def flat_map(self, function: Callable[[A], Either[B]]) -> Either[B]:
|
|
77
|
+
try:
|
|
78
|
+
return function(self.value)
|
|
79
|
+
except Exception as e:
|
|
80
|
+
logger.exception(f"Error in flat_map: {e}")
|
|
81
|
+
# Consider that a right that fails is a left
|
|
82
|
+
return Left(exception=e)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass(frozen=True, slots=True)
|
|
86
|
+
class Left(Either[A]):
|
|
87
|
+
exception: Exception
|
|
88
|
+
|
|
89
|
+
def flat_map(self, function: Callable[[A], Either[B]]) -> Either[B]:
|
|
90
|
+
return Left(exception=self.exception) # Propagate exception
|
|
91
|
+
|
|
92
|
+
def map(self, function: Callable[[A], B]) -> Either[B]:
|
|
93
|
+
return Left(exception=self.exception) # Propagate exception
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class EitherMonad(Either[A]):
|
|
97
|
+
Either = Either
|
|
98
|
+
Left = Left
|
|
99
|
+
Right = Right
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
from fred.monad._either import EitherMonad
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MonadCatalog(enum.Enum):
|
|
7
|
+
"""Enum representing the different types of Monads."""
|
|
8
|
+
EITHER = EitherMonad
|
|
9
|
+
|
|
10
|
+
def __call__(self, *args, **kwargs):
|
|
11
|
+
return self.value.from_value(*args, **kwargs)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Callable,
|
|
3
|
+
Generic,
|
|
4
|
+
TypeVar,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
A = TypeVar("A")
|
|
8
|
+
B = TypeVar("B")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MonadInterface(Generic[A]):
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def from_value(cls, val: A) -> 'MonadInterface[A]':
|
|
15
|
+
raise NotImplementedError
|
|
16
|
+
|
|
17
|
+
def flat_map(self, function: Callable[[A], 'MonadInterface[B]']) -> 'MonadInterface[B]':
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
|
|
20
|
+
def map(self, function: Callable[[A], B]) -> 'MonadInterface[B]':
|
|
21
|
+
# Map can be implemented using flat_map to avoid code duplication and ensure consistency
|
|
22
|
+
return self.flat_map(function=lambda value: type(self).from_value(function(value)))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.21.0
|
|
@@ -34,6 +34,10 @@ src/main/fred/integrations/databricks/wrappers/dbutils.py
|
|
|
34
34
|
src/main/fred/integrations/runpod/__init__.py
|
|
35
35
|
src/main/fred/integrations/runpod/cli_ext.py
|
|
36
36
|
src/main/fred/integrations/runpod/helper.py
|
|
37
|
+
src/main/fred/monad/__init__.py
|
|
38
|
+
src/main/fred/monad/_either.py
|
|
39
|
+
src/main/fred/monad/catalog.py
|
|
40
|
+
src/main/fred/monad/interface.py
|
|
37
41
|
src/main/fred/utils/__init__.py
|
|
38
42
|
src/main/fred/utils/dateops.py
|
|
39
43
|
src/main/fred/utils/runtime.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.19.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
|
|
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.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/runtimes/__init__.py
RENAMED
|
File without changes
|
{fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/runtimes/scanner.py
RENAMED
|
File without changes
|
|
File without changes
|
{fred_oss-0.19.0 → fred_oss-0.21.0}/src/main/fred/integrations/databricks/wrappers/__init__.py
RENAMED
|
File without changes
|
{fred_oss-0.19.0 → fred_oss-0.21.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
|
|
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
|