fred-oss 0.25.0__tar.gz → 0.27.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 (80) hide show
  1. {fred_oss-0.25.0/src/main/fred_oss.egg-info → fred_oss-0.27.0}/PKG-INFO +1 -1
  2. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/callback/_function.py +13 -2
  3. fred_oss-0.27.0/src/main/fred/future/callback/interface.py +51 -0
  4. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/impl.py +44 -0
  5. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/result.py +11 -1
  6. fred_oss-0.27.0/src/main/fred/future/utils.py +39 -0
  7. fred_oss-0.27.0/src/main/fred/version +1 -0
  8. {fred_oss-0.25.0 → fred_oss-0.27.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
  9. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred_oss.egg-info/SOURCES.txt +1 -0
  10. fred_oss-0.25.0/src/main/fred/future/callback/interface.py +0 -33
  11. fred_oss-0.25.0/src/main/fred/version +0 -1
  12. {fred_oss-0.25.0 → fred_oss-0.27.0}/MANIFEST.in +0 -0
  13. {fred_oss-0.25.0 → fred_oss-0.27.0}/NOTICE.txt +0 -0
  14. {fred_oss-0.25.0 → fred_oss-0.27.0}/README.md +0 -0
  15. {fred_oss-0.25.0 → fred_oss-0.27.0}/requirements.txt +0 -0
  16. {fred_oss-0.25.0 → fred_oss-0.27.0}/setup.cfg +0 -0
  17. {fred_oss-0.25.0 → fred_oss-0.27.0}/setup.py +0 -0
  18. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/cli/__init__.py +0 -0
  19. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/cli/__main__.py +0 -0
  20. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/cli/interface.py +0 -0
  21. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/cli/main.py +0 -0
  22. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/__init__.py +0 -0
  23. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/comp/__init__.py +0 -0
  24. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/comp/_keyval.py +0 -0
  25. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/comp/_queue.py +0 -0
  26. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/comp/catalog.py +0 -0
  27. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/comp/interface.py +0 -0
  28. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/service/__init__.py +0 -0
  29. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/service/_redis.py +0 -0
  30. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/service/_stdlib.py +0 -0
  31. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/service/catalog.py +0 -0
  32. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/service/interface.py +0 -0
  33. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/dao/service/utils.py +0 -0
  34. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/__init__.py +0 -0
  35. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/callback/__init__.py +0 -0
  36. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/callback/catalog.py +0 -0
  37. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/future/settings.py +0 -0
  38. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
  39. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
  40. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
  41. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/runtimes/__init__.py +0 -0
  42. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
  43. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
  44. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/wrappers/__init__.py +0 -0
  45. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
  46. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
  47. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/runpod/cli_ext.py +0 -0
  48. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/integrations/runpod/helper.py +0 -0
  49. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/maturity.py +0 -0
  50. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/monad/__init__.py +0 -0
  51. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/monad/_either.py +0 -0
  52. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/monad/catalog.py +0 -0
  53. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/monad/interface.py +0 -0
  54. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/settings.py +0 -0
  55. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/utils/__init__.py +0 -0
  56. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/utils/dateops.py +0 -0
  57. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/utils/runtime.py +0 -0
  58. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/version.py +0 -0
  59. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/__init__.py +0 -0
  60. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/interface.py +0 -0
  61. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/__init__.py +0 -0
  62. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/client.py +0 -0
  63. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/handler.py +0 -0
  64. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/info.py +0 -0
  65. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/plugins/__init__.py +0 -0
  66. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/plugins/_local.py +0 -0
  67. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/plugins/catalog.py +0 -0
  68. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/plugins/interface.py +0 -0
  69. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/__init__.py +0 -0
  70. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/cli_ext.py +0 -0
  71. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/routers/__init__.py +0 -0
  72. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/routers/_runner.py +0 -0
  73. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/routers/catalog.py +0 -0
  74. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/routers/interface.py +0 -0
  75. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/rest/server.py +0 -0
  76. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred/worker/runner/utils.py +0 -0
  77. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
  78. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
  79. {fred_oss-0.25.0 → fred_oss-0.27.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
  80. {fred_oss-0.25.0 → fred_oss-0.27.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.25.0
3
+ Version: 0.27.0
4
4
  Summary: FREDOSS
5
5
  Home-page: https://fred.fahera.mx
6
6
  Author: Fahera Research, Education, and Development
@@ -1,4 +1,5 @@
1
1
  from typing import (
2
+ Any,
2
3
  Callable,
3
4
  TypeVar,
4
5
  )
@@ -15,5 +16,15 @@ class CallbackFunction(CallbackInterface[A]):
15
16
  self.function = function
16
17
  self.kwargs = kwargs
17
18
 
18
- def execute(self, future_id: str, output: EitherMonad.Either[A]):
19
- self.function(output, **self.kwargs)
19
+ def _on_start(self, future_id: str) -> Any:
20
+ return self.function(
21
+ future_id=future_id,
22
+ **self.kwargs
23
+ )
24
+
25
+ def _on_complete(self, future_id: str, output: EitherMonad.Either[A]) -> Any:
26
+ return self.function(
27
+ output=output,
28
+ future_id=future_id,
29
+ **self.kwargs
30
+ )
@@ -0,0 +1,51 @@
1
+ from threading import Thread
2
+ from typing import (
3
+ Generic,
4
+ TypeVar,
5
+ Optional,
6
+ )
7
+
8
+ from fred.settings import logger_manager
9
+ from fred.monad.catalog import EitherMonad
10
+
11
+ logger = logger_manager.get_logger(__name__)
12
+
13
+ A = TypeVar("A")
14
+
15
+
16
+ class CallbackInterface(Generic[A]):
17
+
18
+ def _on_start(self, future_id: str):
19
+ raise NotImplementedError
20
+
21
+ def _on_complete(self, future_id: str, output: EitherMonad.Either[A]):
22
+ raise NotImplementedError
23
+
24
+ def run(self, future_id: str, blocking: bool = False, output: Optional[EitherMonad.Either[A]] = None) -> Optional[Thread]:
25
+ """Executes the callback with the provided output and handles any exceptions.
26
+ Args:
27
+ output (EitherMonad.Either[A]): The output to be passed to the callback.
28
+ Returns:
29
+ bool: True if the callback executed successfully, False otherwise.
30
+ """
31
+ # TODO: Consider using a richer return type to capture more details about the execution
32
+ # and optionally propagate the callback return value.
33
+ try:
34
+ match output:
35
+ case None:
36
+ thread = Thread(
37
+ target=lambda: self._on_start(future_id=future_id),
38
+ daemon=True
39
+ )
40
+ case EitherMonad.Either():
41
+ thread = Thread(
42
+ target=lambda: self._on_complete(future_id=future_id, output=output),
43
+ daemon=True
44
+ )
45
+ thread.start()
46
+ if blocking:
47
+ thread.join()
48
+ return thread
49
+ except Exception as e:
50
+ logger.error(f"Callback execution failed on future '{future_id}': {e}")
51
+ return None
@@ -6,6 +6,7 @@ from typing import (
6
6
  )
7
7
 
8
8
  from fred.settings import logger_manager
9
+ from fred.future.settings import FRD_FUTURE_DEFAULT_EXPIRATION
9
10
  from fred.future.callback.interface import CallbackInterface
10
11
  from fred.monad.interface import MonadInterface
11
12
  from fred.monad.catalog import EitherMonad
@@ -59,6 +60,7 @@ class Future(MonadInterface[A]):
59
60
  def __init__(
60
61
  self,
61
62
  function: Callable[..., A],
63
+ on_start: Optional[CallbackInterface] = None,
62
64
  on_complete: Optional[CallbackInterface] = None,
63
65
  **kwargs
64
66
  ):
@@ -83,6 +85,7 @@ class Future(MonadInterface[A]):
83
85
  target=lambda: future.apply(
84
86
  function=function,
85
87
  on_complete=on_complete,
88
+ on_start=on_start,
86
89
  **kwargs
87
90
  ),
88
91
  daemon=True,
@@ -217,3 +220,44 @@ class Future(MonadInterface[A]):
217
220
  Returns: Future[B]: A new Future containing the transformed result.
218
221
  """
219
222
  return self.flat_map(function=lambda value: type(self).from_value(function(value)))
223
+
224
+ @classmethod
225
+ def pullsync(
226
+ cls,
227
+ future_id: str,
228
+ delay: float = 0.001,
229
+ delay_incr: float = 0.001,
230
+ delay_max: float = 30,
231
+ timeout: float = FRD_FUTURE_DEFAULT_EXPIRATION,
232
+ on_complete: Optional[CallbackInterface] = None,
233
+ **kwargs
234
+ ) -> 'Future[A]':
235
+ """Pulls an existing future from the backend storage by its ID.
236
+ This method allows for retrieving and interacting with a future
237
+ that was previously created and stored in the backend.
238
+
239
+ Args:
240
+ future_id (str): The unique identifier of the future to be pulled.
241
+ delay (float): Initial delay between checks for the future's completion.
242
+ delay_incr (float): Incremental increase in delay after each check.
243
+ delay_max (float): Maximum delay between checks.
244
+ timeout (float): Maximum time to wait for the future to complete.
245
+ on_complete (Optional[CallbackInterface]): An optional callback to be executed
246
+ when the future completes.
247
+ **kwargs: Additional keyword arguments to be passed to the Future constructor.
248
+ Returns:
249
+ Future[A]: A Future instance representing the pulled future.
250
+ """
251
+ from fred.future.utils import pull_future_result
252
+
253
+ return cls(
254
+ function=lambda: pull_future_result(
255
+ future_id=future_id,
256
+ delay=delay,
257
+ delay_incr=delay_incr,
258
+ delay_max=delay_max,
259
+ timeout=timeout,
260
+ ),
261
+ on_complete=on_complete,
262
+ **kwargs
263
+ )
@@ -166,6 +166,7 @@ class FutureUndefinedPending(FutureResult[A]):
166
166
  def apply(
167
167
  self,
168
168
  function: Callable[..., A],
169
+ on_start: Optional[CallbackInterface] = None,
169
170
  on_complete: Optional[CallbackInterface] = None,
170
171
  **kwargs
171
172
  ) -> 'FutureDefined[A]':
@@ -187,6 +188,7 @@ class FutureUndefinedPending(FutureResult[A]):
187
188
  )
188
189
  return fip.exec(
189
190
  function=function,
191
+ on_start=on_start,
190
192
  on_complete=on_complete,
191
193
  **kwargs
192
194
  )
@@ -212,6 +214,7 @@ class FutureUndefinedInProgress(FutureResult[A]):
212
214
  def exec(
213
215
  self,
214
216
  function: Callable[..., A],
217
+ on_start: Optional[CallbackInterface] = None,
215
218
  on_complete: Optional[CallbackInterface] = None,
216
219
  fail: bool = False,
217
220
  **kwargs,
@@ -230,6 +233,11 @@ class FutureUndefinedInProgress(FutureResult[A]):
230
233
  Returns:
231
234
  FutureDefined[A]: A new instance of FutureDefined representing the completed state of the Future.
232
235
  """
236
+ # Execute on_start callback if provided
237
+ on_start_thread = (
238
+ logger.debug(f"Future[{self.future_id}] executing on_start callback")
239
+ or on_start.run(future_id=self.future_id, blocking=False)
240
+ ) if on_start else None
233
241
  try:
234
242
  ok = False
235
243
  match function(**kwargs):
@@ -260,7 +268,9 @@ class FutureUndefinedInProgress(FutureResult[A]):
260
268
  # wrapped on an Either monad so the user can handle success/failure as needed.
261
269
  if on_complete:
262
270
  logger.debug(f"Future[{self.future_id}] executing on_complete callback")
263
- on_complete.run(future_id=self.future_id, output=value)
271
+ on_complete.run(future_id=self.future_id, output=value, blocking=True)
272
+ if on_start_thread:
273
+ on_start_thread.join()
264
274
  return future_defined
265
275
 
266
276
 
@@ -0,0 +1,39 @@
1
+ import time
2
+ from typing import TypeVar, Optional
3
+
4
+ from fred.future.settings import FRD_FUTURE_DEFAULT_EXPIRATION
5
+
6
+ A = TypeVar("A")
7
+
8
+
9
+ def pull_future_result(
10
+ future_id: str,
11
+ delay: float = 0.001,
12
+ delay_incr: float = 0.001,
13
+ delay_max: float = 30,
14
+ timeout: float = FRD_FUTURE_DEFAULT_EXPIRATION,
15
+ ) -> A:
16
+ from fred.future.impl import FutureResult, FutureUndefinedInProgress, FutureUndefinedPending
17
+
18
+ if timeout <= 0:
19
+ raise ValueError(f"Pull operation for future_id '{future_id}' has timed out.")
20
+
21
+ match FutureResult.from_backend(future_id=future_id):
22
+ case None:
23
+ raise ValueError(f"No future found with ID '{future_id}'")
24
+ case FutureResult(value=value):
25
+ return value.resolve()
26
+ case FutureUndefinedPending() | FutureUndefinedInProgress():
27
+ # If the future is not yet defined, wait for it to complete
28
+ time.sleep(delay)
29
+ # Increase the delay for the next check to avoid busy waiting (exponential backoff) capped at delay_max
30
+ return pull_future_result(
31
+ future_id=future_id,
32
+ delay=(delay + delay_incr) if delay < delay_max else delay_max,
33
+ delay_incr=delay,
34
+ delay_max=delay_max,
35
+ # TODO: Consider using a more precise timeout mechanism based on elapsed time
36
+ timeout=timeout - delay,
37
+ )
38
+ case _:
39
+ raise ValueError(f"Unknown future state for ID '{future_id}'")
@@ -0,0 +1 @@
1
+ 0.27.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fred-oss
3
- Version: 0.25.0
3
+ Version: 0.27.0
4
4
  Summary: FREDOSS
5
5
  Home-page: https://fred.fahera.mx
6
6
  Author: Fahera Research, Education, and Development
@@ -27,6 +27,7 @@ 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/utils.py
30
31
  src/main/fred/future/callback/__init__.py
31
32
  src/main/fred/future/callback/_function.py
32
33
  src/main/fred/future/callback/catalog.py
@@ -1,33 +0,0 @@
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, future_id: str, output: EitherMonad.Either[A]):
17
- raise NotImplementedError()
18
-
19
- def run(self, future_id: str, 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(future_id=future_id, output=output)
30
- return True
31
- except Exception as e:
32
- logger.error(f"Callback execution failed on future '{future_id}': {e}")
33
- return False
@@ -1 +0,0 @@
1
- 0.25.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes