fred-oss 0.23.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.
Files changed (78) hide show
  1. {fred_oss-0.23.0/src/main/fred_oss.egg-info → fred_oss-0.24.0}/PKG-INFO +1 -1
  2. fred_oss-0.24.0/src/main/fred/future/callback/_function.py +19 -0
  3. fred_oss-0.24.0/src/main/fred/future/callback/catalog.py +12 -0
  4. fred_oss-0.24.0/src/main/fred/future/callback/interface.py +33 -0
  5. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/future/impl.py +7 -1
  6. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/future/result.py +31 -5
  7. fred_oss-0.24.0/src/main/fred/version +1 -0
  8. fred_oss-0.24.0/src/main/fred/worker/runner/rest/routers/__init__.py +0 -0
  9. {fred_oss-0.23.0 → fred_oss-0.24.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
  10. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/SOURCES.txt +4 -0
  11. fred_oss-0.23.0/src/main/fred/version +0 -1
  12. {fred_oss-0.23.0 → fred_oss-0.24.0}/MANIFEST.in +0 -0
  13. {fred_oss-0.23.0 → fred_oss-0.24.0}/NOTICE.txt +0 -0
  14. {fred_oss-0.23.0 → fred_oss-0.24.0}/README.md +0 -0
  15. {fred_oss-0.23.0 → fred_oss-0.24.0}/requirements.txt +0 -0
  16. {fred_oss-0.23.0 → fred_oss-0.24.0}/setup.cfg +0 -0
  17. {fred_oss-0.23.0 → fred_oss-0.24.0}/setup.py +0 -0
  18. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/cli/__init__.py +0 -0
  19. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/cli/__main__.py +0 -0
  20. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/cli/interface.py +0 -0
  21. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/cli/main.py +0 -0
  22. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/__init__.py +0 -0
  23. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/__init__.py +0 -0
  24. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/_keyval.py +0 -0
  25. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/_queue.py +0 -0
  26. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/catalog.py +0 -0
  27. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/comp/interface.py +0 -0
  28. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/service/__init__.py +0 -0
  29. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/service/_redis.py +0 -0
  30. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/service/_stdlib.py +0 -0
  31. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/service/catalog.py +0 -0
  32. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/service/interface.py +0 -0
  33. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/dao/service/utils.py +0 -0
  34. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/future/__init__.py +0 -0
  35. {fred_oss-0.23.0/src/main/fred/integrations/databricks/runtimes → fred_oss-0.24.0/src/main/fred/future/callback}/__init__.py +0 -0
  36. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/future/settings.py +0 -0
  37. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
  38. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
  39. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
  40. {fred_oss-0.23.0/src/main/fred/integrations/databricks/wrappers → fred_oss-0.24.0/src/main/fred/integrations/databricks/runtimes}/__init__.py +0 -0
  41. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
  42. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
  43. {fred_oss-0.23.0/src/main/fred/utils → fred_oss-0.24.0/src/main/fred/integrations/databricks/wrappers}/__init__.py +0 -0
  44. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
  45. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
  46. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/runpod/cli_ext.py +0 -0
  47. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/integrations/runpod/helper.py +0 -0
  48. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/maturity.py +0 -0
  49. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/monad/__init__.py +0 -0
  50. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/monad/_either.py +0 -0
  51. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/monad/catalog.py +0 -0
  52. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/monad/interface.py +0 -0
  53. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/settings.py +0 -0
  54. {fred_oss-0.23.0/src/main/fred/worker/runner/plugins → fred_oss-0.24.0/src/main/fred/utils}/__init__.py +0 -0
  55. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/utils/dateops.py +0 -0
  56. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/utils/runtime.py +0 -0
  57. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/version.py +0 -0
  58. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/__init__.py +0 -0
  59. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/interface.py +0 -0
  60. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/__init__.py +0 -0
  61. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/client.py +0 -0
  62. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/handler.py +0 -0
  63. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/info.py +0 -0
  64. {fred_oss-0.23.0/src/main/fred/worker/runner/rest → fred_oss-0.24.0/src/main/fred/worker/runner/plugins}/__init__.py +0 -0
  65. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/plugins/_local.py +0 -0
  66. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/plugins/catalog.py +0 -0
  67. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/plugins/interface.py +0 -0
  68. {fred_oss-0.23.0/src/main/fred/worker/runner/rest/routers → fred_oss-0.24.0/src/main/fred/worker/runner/rest}/__init__.py +0 -0
  69. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/cli_ext.py +0 -0
  70. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/routers/_runner.py +0 -0
  71. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/routers/catalog.py +0 -0
  72. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/routers/interface.py +0 -0
  73. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/rest/server.py +0 -0
  74. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred/worker/runner/utils.py +0 -0
  75. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
  76. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
  77. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
  78. {fred_oss-0.23.0 → fred_oss-0.24.0}/src/main/fred_oss.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fred-oss
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: FREDOSS
5
5
  Home-page: https://fred.fahera.mx
6
6
  Author: Fahera Research, Education, and Development
@@ -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 (
@@ -58,6 +59,7 @@ class Future(MonadInterface[A]):
58
59
  def __init__(
59
60
  self,
60
61
  function: Callable[..., A],
62
+ on_complete: Optional[CallbackInterface] = None,
61
63
  **kwargs
62
64
  ):
63
65
  """Initializes a Future with the provided function to be executed asynchronously.
@@ -78,7 +80,11 @@ class Future(MonadInterface[A]):
78
80
  # Note: The thread is a daemon to ensure it does not block program exit.
79
81
  self.future_id = future.future_id
80
82
  self.thread = Thread(
81
- target=lambda: future.apply(function=function, **kwargs),
83
+ target=lambda: future.apply(
84
+ function=function,
85
+ on_complete=on_complete,
86
+ **kwargs
87
+ ),
82
88
  daemon=True,
83
89
  )
84
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.utils.dateops import datetime_utcnow
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(self, function: Callable[..., A], **kwargs) -> 'FutureDefined[A]':
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(function=function, **kwargs)
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(self, function: Callable[..., A], fail: bool = False, **kwargs) -> 'FutureDefined[A]':
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
- return FutureDefined(
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fred-oss
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: FREDOSS
5
5
  Home-page: https://fred.fahera.mx
6
6
  Author: Fahera Research, Education, and Development
@@ -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.23.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes