fred-oss 0.22.0__tar.gz → 0.24.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.22.0/src/main/fred_oss.egg-info → fred_oss-0.24.0}/PKG-INFO +1 -1
- fred_oss-0.24.0/src/main/fred/future/callback/_function.py +19 -0
- fred_oss-0.24.0/src/main/fred/future/callback/catalog.py +12 -0
- fred_oss-0.24.0/src/main/fred/future/callback/interface.py +33 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/future/impl.py +18 -3
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/future/result.py +31 -5
- fred_oss-0.24.0/src/main/fred/version +1 -0
- fred_oss-0.24.0/src/main/fred/worker/runner/rest/routers/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/SOURCES.txt +4 -0
- fred_oss-0.22.0/src/main/fred/version +0 -1
- {fred_oss-0.22.0 → fred_oss-0.24.0}/MANIFEST.in +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/NOTICE.txt +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/README.md +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/requirements.txt +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/setup.cfg +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/setup.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/cli/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/cli/__main__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/cli/interface.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/cli/main.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/_keyval.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/_queue.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/catalog.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/interface.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/service/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/service/_redis.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/service/_stdlib.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/service/catalog.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/service/interface.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/dao/service/utils.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/future/__init__.py +0 -0
- {fred_oss-0.22.0/src/main/fred/integrations/databricks/runtimes → fred_oss-0.24.0/src/main/fred/future/callback}/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/future/settings.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
- {fred_oss-0.22.0/src/main/fred/integrations/databricks/wrappers → fred_oss-0.24.0/src/main/fred/integrations/databricks/runtimes}/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
- {fred_oss-0.22.0/src/main/fred/utils → fred_oss-0.24.0/src/main/fred/integrations/databricks/wrappers}/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/runpod/cli_ext.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/runpod/helper.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/maturity.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/monad/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/monad/_either.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/monad/catalog.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/monad/interface.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/settings.py +0 -0
- {fred_oss-0.22.0/src/main/fred/worker/runner/plugins → fred_oss-0.24.0/src/main/fred/utils}/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/utils/dateops.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/utils/runtime.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/version.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/interface.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/client.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/handler.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/info.py +0 -0
- {fred_oss-0.22.0/src/main/fred/worker/runner/rest → fred_oss-0.24.0/src/main/fred/worker/runner/plugins}/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/plugins/_local.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/plugins/catalog.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/plugins/interface.py +0 -0
- {fred_oss-0.22.0/src/main/fred/worker/runner/rest/routers → fred_oss-0.24.0/src/main/fred/worker/runner/rest}/__init__.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/cli_ext.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/routers/_runner.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/routers/catalog.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/routers/interface.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/server.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/utils.py +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
- {fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Callable,
|
|
3
|
+
TypeVar,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
from fred.future.callback.interface import CallbackInterface
|
|
7
|
+
from fred.monad.catalog import EitherMonad
|
|
8
|
+
|
|
9
|
+
A = TypeVar("A")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CallbackFunction(CallbackInterface[A]):
|
|
13
|
+
|
|
14
|
+
def __init__(self, function: Callable[[EitherMonad.Either[A]], None], **kwargs):
|
|
15
|
+
self.function = function
|
|
16
|
+
self.kwargs = kwargs
|
|
17
|
+
|
|
18
|
+
def execute(self, output: EitherMonad.Either[A]):
|
|
19
|
+
self.function(output, **self.kwargs)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
from fred.future.callback.interface import CallbackInterface
|
|
4
|
+
from fred.future.callback._function import CallbackFunction
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CallbackCatalog(enum.Enum):
|
|
9
|
+
FUNCTION = CallbackFunction
|
|
10
|
+
|
|
11
|
+
def __call__(self, *args, **kwargs) -> CallbackInterface:
|
|
12
|
+
return self.value(*args, **kwargs)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import (
|
|
2
|
+
Generic,
|
|
3
|
+
TypeVar,
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
from fred.settings import logger_manager
|
|
7
|
+
from fred.monad.catalog import EitherMonad
|
|
8
|
+
|
|
9
|
+
logger = logger_manager.get_logger(__name__)
|
|
10
|
+
|
|
11
|
+
A = TypeVar("A")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CallbackInterface(Generic[A]):
|
|
15
|
+
|
|
16
|
+
def execute(self, output: EitherMonad.Either[A]):
|
|
17
|
+
raise NotImplementedError()
|
|
18
|
+
|
|
19
|
+
def run(self, output: EitherMonad.Either[A]) -> bool:
|
|
20
|
+
"""Executes the callback with the provided output and handles any exceptions.
|
|
21
|
+
Args:
|
|
22
|
+
output (EitherMonad.Either[A]): The output to be passed to the callback.
|
|
23
|
+
Returns:
|
|
24
|
+
bool: True if the callback executed successfully, False otherwise.
|
|
25
|
+
"""
|
|
26
|
+
# TODO: Consider using a richer return type to capture more details about the execution
|
|
27
|
+
# and optionally propagate the callback return value.
|
|
28
|
+
try:
|
|
29
|
+
self.execute(output=output)
|
|
30
|
+
return True
|
|
31
|
+
except Exception as e:
|
|
32
|
+
logger.error(f"Callback execution failed: {e}")
|
|
33
|
+
return False
|
|
@@ -6,6 +6,7 @@ from typing import (
|
|
|
6
6
|
)
|
|
7
7
|
|
|
8
8
|
from fred.settings import logger_manager
|
|
9
|
+
from fred.future.callback.interface import CallbackInterface
|
|
9
10
|
from fred.monad.interface import MonadInterface
|
|
10
11
|
from fred.monad.catalog import EitherMonad
|
|
11
12
|
from fred.future.result import (
|
|
@@ -55,21 +56,35 @@ class Future(MonadInterface[A]):
|
|
|
55
56
|
TODO: Consider using more advanced concurrency primitives for better control and efficiency.
|
|
56
57
|
"""
|
|
57
58
|
|
|
58
|
-
def __init__(
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
function: Callable[..., A],
|
|
62
|
+
on_complete: Optional[CallbackInterface] = None,
|
|
63
|
+
**kwargs
|
|
64
|
+
):
|
|
59
65
|
"""Initializes a Future with the provided function to be executed asynchronously.
|
|
60
66
|
The function is executed in a separate thread, allowing for non-blocking operations.
|
|
67
|
+
|
|
61
68
|
Args:
|
|
62
69
|
function (Callable[..., A]): The function to be executed asynchronously.
|
|
70
|
+
future_id (Optional[str], keyword-only): A reserved keyword-only parameter used to
|
|
71
|
+
uniquely identify this Future instance. This value is consumed by the Future
|
|
72
|
+
infrastructure and is not passed to the target function.
|
|
63
73
|
**kwargs: Additional keyword arguments to be passed to the function when executed.
|
|
74
|
+
All keyword arguments except 'future_id' are forwarded to the target function.
|
|
64
75
|
"""
|
|
65
76
|
# Create a new available future
|
|
66
|
-
future = FutureUndefinedPending.auto()
|
|
77
|
+
future = FutureUndefinedPending.auto(future_id=kwargs.pop("future_id", None))
|
|
67
78
|
# Register the Future-ID and define the available future via the provided function.
|
|
68
79
|
# Note: The 'apply' method is blocking by itself; thus, we run it in a separate thread.
|
|
69
80
|
# Note: The thread is a daemon to ensure it does not block program exit.
|
|
70
81
|
self.future_id = future.future_id
|
|
71
82
|
self.thread = Thread(
|
|
72
|
-
target=lambda: future.apply(
|
|
83
|
+
target=lambda: future.apply(
|
|
84
|
+
function=function,
|
|
85
|
+
on_complete=on_complete,
|
|
86
|
+
**kwargs
|
|
87
|
+
),
|
|
73
88
|
daemon=True,
|
|
74
89
|
)
|
|
75
90
|
# Start the thread to execute the function asynchronously
|
|
@@ -17,8 +17,9 @@ from fred.future.settings import (
|
|
|
17
17
|
FRD_FUTURE_DEFAULT_EXPIRATION,
|
|
18
18
|
FRD_FUTURE_DEFAULT_TIMEOUT,
|
|
19
19
|
)
|
|
20
|
-
from fred.
|
|
20
|
+
from fred.future.callback.interface import CallbackInterface
|
|
21
21
|
from fred.dao.service.catalog import ServiceCatalog
|
|
22
|
+
from fred.utils.dateops import datetime_utcnow
|
|
22
23
|
from fred.dao.comp.catalog import FredKeyVal
|
|
23
24
|
from fred.monad.catalog import EitherMonad
|
|
24
25
|
|
|
@@ -162,7 +163,12 @@ class FutureUndefinedPending(FutureResult[A]):
|
|
|
162
163
|
expire=FRD_FUTURE_DEFAULT_EXPIRATION
|
|
163
164
|
)
|
|
164
165
|
|
|
165
|
-
def apply(
|
|
166
|
+
def apply(
|
|
167
|
+
self,
|
|
168
|
+
function: Callable[..., A],
|
|
169
|
+
on_complete: Optional[CallbackInterface] = None,
|
|
170
|
+
**kwargs
|
|
171
|
+
) -> 'FutureDefined[A]':
|
|
166
172
|
"""Applies a function to the Future, transitioning it from pending to in-progress and finalizing as defined.
|
|
167
173
|
This method executes the provided function with the given keyword arguments,
|
|
168
174
|
transitioning the Future from a pending state to an in-progress state. It captures
|
|
@@ -179,7 +185,11 @@ class FutureUndefinedPending(FutureResult[A]):
|
|
|
179
185
|
started_at=perf_counter(),
|
|
180
186
|
function_name=function.__name__,
|
|
181
187
|
)
|
|
182
|
-
return fip.exec(
|
|
188
|
+
return fip.exec(
|
|
189
|
+
function=function,
|
|
190
|
+
on_complete=on_complete,
|
|
191
|
+
**kwargs
|
|
192
|
+
)
|
|
183
193
|
|
|
184
194
|
|
|
185
195
|
@dataclass(frozen=True, slots=False)
|
|
@@ -199,7 +209,13 @@ class FutureUndefinedInProgress(FutureResult[A]):
|
|
|
199
209
|
expire=FRD_FUTURE_DEFAULT_EXPIRATION
|
|
200
210
|
)
|
|
201
211
|
|
|
202
|
-
def exec(
|
|
212
|
+
def exec(
|
|
213
|
+
self,
|
|
214
|
+
function: Callable[..., A],
|
|
215
|
+
on_complete: Optional[CallbackInterface] = None,
|
|
216
|
+
fail: bool = False,
|
|
217
|
+
**kwargs,
|
|
218
|
+
) -> 'FutureDefined[A]':
|
|
203
219
|
"""Executes the function associated with the Future, capturing its result or exception.
|
|
204
220
|
This method runs the provided function with the given keyword arguments, capturing
|
|
205
221
|
its output. If the function executes successfully, it wraps the result in a Right
|
|
@@ -231,11 +247,21 @@ class FutureUndefinedInProgress(FutureResult[A]):
|
|
|
231
247
|
value = EitherMonad.Left.from_value(val=e)
|
|
232
248
|
if fail:
|
|
233
249
|
raise e
|
|
234
|
-
|
|
250
|
+
future_defined = FutureDefined(
|
|
235
251
|
future_id=self.future_id,
|
|
236
252
|
value=value,
|
|
237
253
|
ok=ok,
|
|
238
254
|
)
|
|
255
|
+
# We could do the following to have an "on_success" behaviour:
|
|
256
|
+
# value.map(lambda v: on_complete.run(v) if on_complete else None)
|
|
257
|
+
# But that would leave out the "on_failure" behaviour and we would probably need to
|
|
258
|
+
# add specific 'on_success' and 'on_failure' callbacks to mitigate that.
|
|
259
|
+
# Instead, we just do a generic 'on_complete' callback that gets executed
|
|
260
|
+
# wrapped on an Either monad so the user can handle success/failure as needed.
|
|
261
|
+
if on_complete:
|
|
262
|
+
logger.debug(f"Future[{self.future_id}] executing on_complete callback")
|
|
263
|
+
on_complete.run(value)
|
|
264
|
+
return future_defined
|
|
239
265
|
|
|
240
266
|
|
|
241
267
|
@dataclass(frozen=True, slots=False)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.24.0
|
|
File without changes
|
|
@@ -27,6 +27,10 @@ src/main/fred/future/__init__.py
|
|
|
27
27
|
src/main/fred/future/impl.py
|
|
28
28
|
src/main/fred/future/result.py
|
|
29
29
|
src/main/fred/future/settings.py
|
|
30
|
+
src/main/fred/future/callback/__init__.py
|
|
31
|
+
src/main/fred/future/callback/_function.py
|
|
32
|
+
src/main/fred/future/callback/catalog.py
|
|
33
|
+
src/main/fred/future/callback/interface.py
|
|
30
34
|
src/main/fred/integrations/databricks/__init__.py
|
|
31
35
|
src/main/fred/integrations/databricks/cli_ext.py
|
|
32
36
|
src/main/fred/integrations/databricks/runtime.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.22.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fred_oss-0.22.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtimes/scanner.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fred_oss-0.22.0 → fred_oss-0.24.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|