fred-oss 0.14.0__tar.gz → 0.15.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 (60) hide show
  1. {fred_oss-0.14.0/src/main/fred_oss.egg-info → fred_oss-0.15.0}/PKG-INFO +1 -1
  2. fred_oss-0.15.0/src/main/fred/dao/__init__.py +11 -0
  3. fred_oss-0.15.0/src/main/fred/dao/service/_redis.py +25 -0
  4. fred_oss-0.15.0/src/main/fred/dao/service/catalog.py +22 -0
  5. fred_oss-0.15.0/src/main/fred/dao/service/interface.py +54 -0
  6. fred_oss-0.15.0/src/main/fred/dao/service/utils.py +37 -0
  7. fred_oss-0.15.0/src/main/fred/version +1 -0
  8. fred_oss-0.15.0/src/main/fred/worker/runner/rest/routers/__init__.py +0 -0
  9. {fred_oss-0.14.0 → fred_oss-0.15.0/src/main/fred_oss.egg-info}/PKG-INFO +1 -1
  10. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred_oss.egg-info/SOURCES.txt +6 -0
  11. fred_oss-0.14.0/src/main/fred/version +0 -1
  12. {fred_oss-0.14.0 → fred_oss-0.15.0}/MANIFEST.in +0 -0
  13. {fred_oss-0.14.0 → fred_oss-0.15.0}/NOTICE.txt +0 -0
  14. {fred_oss-0.14.0 → fred_oss-0.15.0}/README.md +0 -0
  15. {fred_oss-0.14.0 → fred_oss-0.15.0}/requirements.txt +0 -0
  16. {fred_oss-0.14.0 → fred_oss-0.15.0}/setup.cfg +0 -0
  17. {fred_oss-0.14.0 → fred_oss-0.15.0}/setup.py +0 -0
  18. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/cli/__init__.py +0 -0
  19. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/cli/__main__.py +0 -0
  20. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/cli/interface.py +0 -0
  21. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/cli/main.py +0 -0
  22. {fred_oss-0.14.0/src/main/fred/integrations/databricks/runtimes → fred_oss-0.15.0/src/main/fred/dao/service}/__init__.py +0 -0
  23. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/databricks/__init__.py +0 -0
  24. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/databricks/cli_ext.py +0 -0
  25. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/databricks/runtime.py +0 -0
  26. {fred_oss-0.14.0/src/main/fred/integrations/databricks/wrappers → fred_oss-0.15.0/src/main/fred/integrations/databricks/runtimes}/__init__.py +0 -0
  27. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/databricks/runtimes/scanner.py +0 -0
  28. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/databricks/runtimes/sync.py +0 -0
  29. {fred_oss-0.14.0/src/main/fred/utils → fred_oss-0.15.0/src/main/fred/integrations/databricks/wrappers}/__init__.py +0 -0
  30. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/databricks/wrappers/dbutils.py +0 -0
  31. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/runpod/__init__.py +0 -0
  32. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/runpod/cli_ext.py +0 -0
  33. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/integrations/runpod/helper.py +0 -0
  34. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/maturity.py +0 -0
  35. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/settings.py +0 -0
  36. {fred_oss-0.14.0/src/main/fred/worker/runner/plugins → fred_oss-0.15.0/src/main/fred/utils}/__init__.py +0 -0
  37. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/utils/dateops.py +0 -0
  38. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/utils/runtime.py +0 -0
  39. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/version.py +0 -0
  40. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/__init__.py +0 -0
  41. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/interface.py +0 -0
  42. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/__init__.py +0 -0
  43. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/client.py +0 -0
  44. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/handler.py +0 -0
  45. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/info.py +0 -0
  46. {fred_oss-0.14.0/src/main/fred/worker/runner/rest → fred_oss-0.15.0/src/main/fred/worker/runner/plugins}/__init__.py +0 -0
  47. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/plugins/_local.py +0 -0
  48. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/plugins/catalog.py +0 -0
  49. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/plugins/interface.py +0 -0
  50. {fred_oss-0.14.0/src/main/fred/worker/runner/rest/routers → fred_oss-0.15.0/src/main/fred/worker/runner/rest}/__init__.py +0 -0
  51. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/rest/cli_ext.py +0 -0
  52. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/rest/routers/_runner.py +0 -0
  53. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/rest/routers/catalog.py +0 -0
  54. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/rest/routers/interface.py +0 -0
  55. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/rest/server.py +0 -0
  56. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred/worker/runner/utils.py +0 -0
  57. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred_oss.egg-info/dependency_links.txt +0 -0
  58. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred_oss.egg-info/entry_points.txt +0 -0
  59. {fred_oss-0.14.0 → fred_oss-0.15.0}/src/main/fred_oss.egg-info/requires.txt +0 -0
  60. {fred_oss-0.14.0 → fred_oss-0.15.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.14.0
3
+ Version: 0.15.0
4
4
  Summary: FREDOSS
5
5
  Home-page: https://fred.fahera.mx
6
6
  Author: Fahera Research, Education, and Development
@@ -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-DAO implementation is in early development "
9
+ "and therefore currently with incomplete and unstable features."
10
+ )
11
+ )
@@ -0,0 +1,25 @@
1
+ from redis import Redis, ConnectionPool
2
+
3
+ from fred.dao.service.utils import get_redis_configs_from_payload
4
+ from fred.dao.service.interface import ServiceConnectionPoolInterface, ServiceInterface
5
+
6
+
7
+ class RedisConnectionPool(ServiceConnectionPoolInterface[ConnectionPool]):
8
+
9
+ @classmethod
10
+ def _create_pool(cls, **kwargs) -> ConnectionPool:
11
+ configs = get_redis_configs_from_payload(payload=kwargs, keep=False)
12
+ return ConnectionPool(**configs)
13
+
14
+
15
+ class RedisService(ServiceInterface[Redis]):
16
+ instance: Redis
17
+
18
+ @classmethod
19
+ def _create_instance(cls, **kwargs) -> Redis:
20
+ return Redis(connection_pool=RedisConnectionPool.get_or_create_pool(**kwargs))
21
+
22
+ @classmethod
23
+ def auto(cls, **kwargs) -> "RedisService":
24
+ cls.instance = Redis(connection_pool=RedisConnectionPool.get_or_create_pool(**kwargs))
25
+ return cls(**kwargs)
@@ -0,0 +1,22 @@
1
+ import enum
2
+ from functools import lru_cache
3
+
4
+ from fred.dao.service.interface import ServiceInterface
5
+ from fred.dao.service._redis import RedisService
6
+
7
+
8
+ class ServiceCatalog(enum.Enum):
9
+ REDIS = RedisService
10
+
11
+ @classmethod
12
+ def from_classname(cls, classname: str) -> "ServiceCatalog":
13
+ for item in cls:
14
+ if item.value.__name__ == classname:
15
+ return item
16
+ raise ValueError(f"No service found for classname: {classname}")
17
+
18
+ def service_cls(self) -> type[ServiceInterface]:
19
+ return self.value
20
+
21
+ def auto(self, **kwargs) -> ServiceInterface:
22
+ return self.value.auto(**kwargs)
@@ -0,0 +1,54 @@
1
+ import uuid
2
+ import json
3
+ from functools import lru_cache
4
+ from typing import Generic, TypeVar
5
+
6
+ T = TypeVar("T")
7
+
8
+
9
+ class ServiceConnectionPoolInterface(Generic[T]):
10
+ pool_registry: dict[str, T] = {}
11
+
12
+ @classmethod
13
+ def get_pool_id(cls, **kwargs) -> str:
14
+ return str(uuid.uuid5(uuid.NAMESPACE_OID, json.dumps(kwargs, sort_keys=True)))
15
+
16
+ @classmethod
17
+ def _create_pool(cls, **kwargs) -> T:
18
+ raise NotImplementedError("This method should be implemented by subclasses.")
19
+
20
+ @classmethod
21
+ @lru_cache
22
+ def get_or_create_pool(cls, **kwargs) -> T:
23
+ pool_id = cls.get_pool_id(**kwargs)
24
+ pool = cls.pool_registry.get(pool_id)
25
+ if not pool:
26
+ pool = cls.pool_registry[pool_id] = cls._create_pool(**kwargs)
27
+ return pool
28
+
29
+
30
+ class ServiceInterface(Generic[T]):
31
+ instance: T
32
+
33
+ def __init__(self, **kwargs):
34
+ self.config = kwargs
35
+
36
+ @classmethod
37
+ def _create_instance(cls, **kwargs) -> T:
38
+ raise NotImplementedError("This method should be implemented by subclasses.")
39
+
40
+ @classmethod
41
+ def auto(cls, **kwargs) -> "ServiceInterface":
42
+ raise NotImplementedError("This method should be implemented by subclasses.")
43
+
44
+ @property
45
+ def client(self) -> T:
46
+ if not getattr(self, "instance", None):
47
+ self.instance = self._create_instance(**getattr(self, "config", {}))
48
+ return self.instance
49
+
50
+ def close(self):
51
+ # Close the instance if it has a close method.
52
+ # This method can be overridden by subclasses if needed.
53
+ if self.instance and hasattr(self.instance, "close") and callable(self.instance.close):
54
+ self.instance.close()
@@ -0,0 +1,37 @@
1
+ from fred.settings import get_environ_variable
2
+
3
+
4
+ def get_redis_configs_from_payload(
5
+ payload: dict,
6
+ keep: bool = False,
7
+ ) -> dict:
8
+ """Extract Redis configuration from the given payload dictionary.
9
+ This function looks for common Redis configuration keys in the payload
10
+ dictionary. If a key is not found, it falls back to environment variables.
11
+ Args:
12
+ payload (dict): The dictionary from which to extract Redis configuration.
13
+ keep (bool): If True, the original keys are retained in the payload. If False, they are removed.
14
+ Returns:
15
+ dict: A dictionary containing Redis configuration parameters.
16
+ """
17
+ host = port = password = db = None
18
+ for host_key in ["host", "redis_host"]:
19
+ if (host := payload.get(host_key) if keep else payload.pop(host_key, None)):
20
+ break
21
+ for port_key in ["port", "redis_port"]:
22
+ if (port := payload.get(port_key) if keep else payload.pop(port_key, None)):
23
+ break
24
+ for password_key in ["password", "redis_password"]:
25
+ if (password := payload.get(password_key) if keep else payload.pop(password_key, None)):
26
+ break
27
+ for db_key in ["db", "redis_db"]:
28
+ if (db := payload.get(db_key) if keep else payload.pop(db_key, None)):
29
+ break
30
+ return {
31
+ "host": host or get_environ_variable(name="REDIS_HOST", default="localhost"),
32
+ "port": int(port or get_environ_variable(name="REDIS_PORT", default=6379)),
33
+ "password": password or get_environ_variable(name="REDIS_PASSWORD", default=None),
34
+ "db": int(db or get_environ_variable(name="REDIS_DB", default=0)),
35
+ "decode_responses": True,
36
+ **(payload.get("redis_configs", {}) if keep else payload.pop("redis_configs", {})),
37
+ }
@@ -0,0 +1 @@
1
+ 0.15.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fred-oss
3
- Version: 0.14.0
3
+ Version: 0.15.0
4
4
  Summary: FREDOSS
5
5
  Home-page: https://fred.fahera.mx
6
6
  Author: Fahera Research, Education, and Development
@@ -11,6 +11,12 @@ src/main/fred/cli/__init__.py
11
11
  src/main/fred/cli/__main__.py
12
12
  src/main/fred/cli/interface.py
13
13
  src/main/fred/cli/main.py
14
+ src/main/fred/dao/__init__.py
15
+ src/main/fred/dao/service/__init__.py
16
+ src/main/fred/dao/service/_redis.py
17
+ src/main/fred/dao/service/catalog.py
18
+ src/main/fred/dao/service/interface.py
19
+ src/main/fred/dao/service/utils.py
14
20
  src/main/fred/integrations/databricks/__init__.py
15
21
  src/main/fred/integrations/databricks/cli_ext.py
16
22
  src/main/fred/integrations/databricks/runtime.py
@@ -1 +0,0 @@
1
- 0.14.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes