moose-lib 0.5.7__py3-none-any.whl → 0.5.9__py3-none-any.whl
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.
Potentially problematic release.
This version of moose-lib might be problematic. Click here for more details.
- moose_lib/dmv2/_registry.py +2 -0
- moose_lib/dmv2/consumption.py +33 -2
- moose_lib/dmv2/registry.py +14 -3
- {moose_lib-0.5.7.dist-info → moose_lib-0.5.9.dist-info}/METADATA +1 -1
- {moose_lib-0.5.7.dist-info → moose_lib-0.5.9.dist-info}/RECORD +7 -7
- {moose_lib-0.5.7.dist-info → moose_lib-0.5.9.dist-info}/WHEEL +0 -0
- {moose_lib-0.5.7.dist-info → moose_lib-0.5.9.dist-info}/top_level.txt +0 -0
moose_lib/dmv2/_registry.py
CHANGED
|
@@ -11,5 +11,7 @@ _tables: Dict[str, Any] = {}
|
|
|
11
11
|
_streams: Dict[str, Any] = {}
|
|
12
12
|
_ingest_apis: Dict[str, Any] = {}
|
|
13
13
|
_egress_apis: Dict[str, Any] = {}
|
|
14
|
+
# Alias map for O(1) fallback of sole versioned APIs: base name -> handler
|
|
15
|
+
_egress_api_name_aliases: Dict[str, Any] = {}
|
|
14
16
|
_sql_resources: Dict[str, Any] = {}
|
|
15
17
|
_workflows: Dict[str, Any] = {}
|
moose_lib/dmv2/consumption.py
CHANGED
|
@@ -12,7 +12,7 @@ from pydantic import BaseModel
|
|
|
12
12
|
from pydantic.json_schema import JsonSchemaValue
|
|
13
13
|
|
|
14
14
|
from .types import BaseTypedResource, T, U
|
|
15
|
-
from ._registry import _egress_apis
|
|
15
|
+
from ._registry import _egress_apis, _egress_api_name_aliases
|
|
16
16
|
|
|
17
17
|
# Global base URL configuration
|
|
18
18
|
_global_base_url: Optional[str] = None
|
|
@@ -116,7 +116,38 @@ class ConsumptionApi(BaseTypedResource, Generic[U]):
|
|
|
116
116
|
|
|
117
117
|
self.query_function = query_function
|
|
118
118
|
self.metadata = getattr(self.config, 'metadata', {}) or {}
|
|
119
|
-
|
|
119
|
+
key = _generate_api_key(name, self.config.version)
|
|
120
|
+
_egress_apis[key] = self
|
|
121
|
+
|
|
122
|
+
# Maintain alias for base name:
|
|
123
|
+
# - If explicit unversioned registered, alias -> that
|
|
124
|
+
# - Else, if exactly one versioned exists, alias -> that
|
|
125
|
+
base = name
|
|
126
|
+
if self.config.version is None:
|
|
127
|
+
_egress_api_name_aliases[base] = self
|
|
128
|
+
return
|
|
129
|
+
|
|
130
|
+
# Versioned registration: only adjust alias if no explicit unversioned exists
|
|
131
|
+
if base in _egress_apis:
|
|
132
|
+
# Explicit unversioned present, ensure alias points to it
|
|
133
|
+
_egress_api_name_aliases[base] = _egress_apis[base]
|
|
134
|
+
return
|
|
135
|
+
|
|
136
|
+
# Determine if there is exactly one versioned API
|
|
137
|
+
prefix = f"{base}:"
|
|
138
|
+
# Early exit on 2 matches to avoid O(n) counting
|
|
139
|
+
match_count = 0
|
|
140
|
+
sole = None
|
|
141
|
+
for k in _egress_apis.keys():
|
|
142
|
+
if k.startswith(prefix):
|
|
143
|
+
match_count += 1
|
|
144
|
+
sole = _egress_apis[k]
|
|
145
|
+
if match_count > 1:
|
|
146
|
+
break
|
|
147
|
+
if match_count == 1 and sole is not None:
|
|
148
|
+
_egress_api_name_aliases[base] = sole
|
|
149
|
+
else:
|
|
150
|
+
_egress_api_name_aliases.pop(base, None)
|
|
120
151
|
|
|
121
152
|
@classmethod
|
|
122
153
|
def _get_type(cls, keyword_args: dict):
|
moose_lib/dmv2/registry.py
CHANGED
|
@@ -11,7 +11,15 @@ from .ingest_api import IngestApi
|
|
|
11
11
|
from .consumption import ConsumptionApi
|
|
12
12
|
from .sql_resource import SqlResource
|
|
13
13
|
from .workflow import Workflow
|
|
14
|
-
from ._registry import
|
|
14
|
+
from ._registry import (
|
|
15
|
+
_tables,
|
|
16
|
+
_streams,
|
|
17
|
+
_ingest_apis,
|
|
18
|
+
_egress_apis,
|
|
19
|
+
_sql_resources,
|
|
20
|
+
_workflows,
|
|
21
|
+
_egress_api_name_aliases,
|
|
22
|
+
)
|
|
15
23
|
|
|
16
24
|
def get_tables() -> Dict[str, OlapTable]:
|
|
17
25
|
"""Get all registered OLAP tables."""
|
|
@@ -42,8 +50,11 @@ def get_consumption_apis() -> Dict[str, ConsumptionApi]:
|
|
|
42
50
|
return _egress_apis
|
|
43
51
|
|
|
44
52
|
def get_consumption_api(name: str) -> Optional[ConsumptionApi]:
|
|
45
|
-
"""Get a registered consumption API by name.
|
|
46
|
-
|
|
53
|
+
"""Get a registered consumption API by name.
|
|
54
|
+
|
|
55
|
+
Supports unversioned lookup by name via alias map when only a single versioned API exists.
|
|
56
|
+
"""
|
|
57
|
+
return _egress_apis.get(name) or _egress_api_name_aliases.get(name)
|
|
47
58
|
|
|
48
59
|
def get_sql_resources() -> Dict[str, SqlResource]:
|
|
49
60
|
"""Get all registered SQL resources."""
|
|
@@ -13,14 +13,14 @@ moose_lib/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
13
13
|
moose_lib/config/config_file.py,sha256=NyjY6YFraBel7vBk18lLkpGaPR1viKMAEv4ZldyfLIA,2585
|
|
14
14
|
moose_lib/config/runtime.py,sha256=gF1wrUCbp0MxRU92k0vyItvWX2x6P1FuBRzM61nJE_U,2776
|
|
15
15
|
moose_lib/dmv2/__init__.py,sha256=N81VWGNWRZJbPjDlsCPVYUcu_VaWw5hhdNkKcbWknVk,2448
|
|
16
|
-
moose_lib/dmv2/_registry.py,sha256=
|
|
17
|
-
moose_lib/dmv2/consumption.py,sha256
|
|
16
|
+
moose_lib/dmv2/_registry.py,sha256=eKeMRjO0e1_anl0G3qjGMnRI0o9OJghdQ3uVtlsggm4,625
|
|
17
|
+
moose_lib/dmv2/consumption.py,sha256=V2AQWsg5jVJXqbFuB94V9YaHHUgdOHJxgTHPThykwKQ,8791
|
|
18
18
|
moose_lib/dmv2/ingest_api.py,sha256=Snek9NGwaJl_BuImSWGtQq91m9D3AJ4qBoGiKZ-9yTQ,2323
|
|
19
19
|
moose_lib/dmv2/ingest_pipeline.py,sha256=q7k8B50Dp_jpJA86Rr9dOGl7-EaGF0LR81TuFXlktxc,7024
|
|
20
20
|
moose_lib/dmv2/life_cycle.py,sha256=wl0k6yzwU1MJ_fO_UkN29buoY5G6ChYZvfwigP9fVfM,1254
|
|
21
21
|
moose_lib/dmv2/materialized_view.py,sha256=kcx-sJFTM-cH3Uc1GoldgFGodjoz0AegAQEMmohdS38,3826
|
|
22
22
|
moose_lib/dmv2/olap_table.py,sha256=gAo5wE7W2P5cN3GMw7er0jXyfvXVbbo_SZPvzHoJQx0,31640
|
|
23
|
-
moose_lib/dmv2/registry.py,sha256=
|
|
23
|
+
moose_lib/dmv2/registry.py,sha256=sB6AlSg7H4gQWUN3qco2HOyN6GKQVvFu6DskedyqN78,2252
|
|
24
24
|
moose_lib/dmv2/sql_resource.py,sha256=kUZoGqxhZMHMthtBZGYJBxTFjXkspXiWLXhJRYXgGUM,1864
|
|
25
25
|
moose_lib/dmv2/stream.py,sha256=jiUWBsjFalLLP63mikOxyHRdieiDAlzf9lXfLye-Wjc,10761
|
|
26
26
|
moose_lib/dmv2/types.py,sha256=5FsB0HLHFkYB-8cjJ0rtRUjqahVA-ToLr2JXT1lFiss,3276
|
|
@@ -32,7 +32,7 @@ tests/__init__.py,sha256=0Gh4yzPkkC3TzBGKhenpMIxJcRhyrrCfxLSfpTZnPMQ,53
|
|
|
32
32
|
tests/conftest.py,sha256=ZVJNbnr4DwbcqkTmePW6U01zAzE6QD0kNAEZjPG1f4s,169
|
|
33
33
|
tests/test_moose.py,sha256=mBsx_OYWmL8ppDzL_7Bd7xR6qf_i3-pCIO3wm2iQNaA,2136
|
|
34
34
|
tests/test_redis_client.py,sha256=d9_MLYsJ4ecVil_jPB2gW3Q5aWnavxmmjZg2uYI3LVo,3256
|
|
35
|
-
moose_lib-0.5.
|
|
36
|
-
moose_lib-0.5.
|
|
37
|
-
moose_lib-0.5.
|
|
38
|
-
moose_lib-0.5.
|
|
35
|
+
moose_lib-0.5.9.dist-info/METADATA,sha256=jYG1sQezj21_PI_vRv43ItWOuy3f8jh0XE_kdHZgMoI,729
|
|
36
|
+
moose_lib-0.5.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
37
|
+
moose_lib-0.5.9.dist-info/top_level.txt,sha256=XEns2-4aCmGp2XjJAeEH9TAUcGONLnSLy6ycT9FSJh8,16
|
|
38
|
+
moose_lib-0.5.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|