moose-lib 0.6.54__py3-none-any.whl → 0.6.56__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/olap_table.py +2 -0
- moose_lib/internal.py +36 -15
- {moose_lib-0.6.54.dist-info → moose_lib-0.6.56.dist-info}/METADATA +1 -1
- {moose_lib-0.6.54.dist-info → moose_lib-0.6.56.dist-info}/RECORD +6 -6
- {moose_lib-0.6.54.dist-info → moose_lib-0.6.56.dist-info}/WHEEL +0 -0
- {moose_lib-0.6.54.dist-info → moose_lib-0.6.56.dist-info}/top_level.txt +0 -0
moose_lib/dmv2/olap_table.py
CHANGED
|
@@ -103,6 +103,7 @@ class OlapConfig(BaseModel):
|
|
|
103
103
|
Attributes:
|
|
104
104
|
order_by_fields: List of column names to use for the ORDER BY clause.
|
|
105
105
|
Crucial for `ReplacingMergeTree` and performance.
|
|
106
|
+
partition_by: Optional PARTITION BY expression (single ClickHouse SQL expression).
|
|
106
107
|
engine: The ClickHouse table engine to use. Can be either a ClickHouseEngines enum value
|
|
107
108
|
(for backward compatibility) or an EngineConfig instance (recommended).
|
|
108
109
|
version: Optional version string for tracking configuration changes.
|
|
@@ -112,6 +113,7 @@ class OlapConfig(BaseModel):
|
|
|
112
113
|
These are alterable settings that can be changed without recreating the table.
|
|
113
114
|
"""
|
|
114
115
|
order_by_fields: list[str] = []
|
|
116
|
+
partition_by: Optional[str] = None
|
|
115
117
|
engine: Optional[Union[ClickHouseEngines, EngineConfig]] = None
|
|
116
118
|
version: Optional[str] = None
|
|
117
119
|
metadata: Optional[dict] = None
|
moose_lib/internal.py
CHANGED
|
@@ -46,6 +46,7 @@ class Target(BaseModel):
|
|
|
46
46
|
version: Optional[str] = None
|
|
47
47
|
metadata: Optional[dict] = None
|
|
48
48
|
|
|
49
|
+
|
|
49
50
|
class Consumer(BaseModel):
|
|
50
51
|
"""Represents a consumer attached to a stream.
|
|
51
52
|
|
|
@@ -54,29 +55,35 @@ class Consumer(BaseModel):
|
|
|
54
55
|
"""
|
|
55
56
|
version: Optional[str] = None
|
|
56
57
|
|
|
58
|
+
|
|
57
59
|
class BaseEngineConfigDict(BaseModel):
|
|
58
60
|
"""Base engine configuration for all ClickHouse table engines."""
|
|
59
61
|
model_config = model_config
|
|
60
62
|
engine: str
|
|
61
63
|
|
|
64
|
+
|
|
62
65
|
class MergeTreeConfigDict(BaseEngineConfigDict):
|
|
63
66
|
"""Configuration for MergeTree engine."""
|
|
64
67
|
engine: Literal["MergeTree"] = "MergeTree"
|
|
65
68
|
|
|
69
|
+
|
|
66
70
|
class ReplacingMergeTreeConfigDict(BaseEngineConfigDict):
|
|
67
71
|
"""Configuration for ReplacingMergeTree engine."""
|
|
68
72
|
engine: Literal["ReplacingMergeTree"] = "ReplacingMergeTree"
|
|
69
73
|
ver: Optional[str] = None
|
|
70
74
|
is_deleted: Optional[str] = None
|
|
71
75
|
|
|
76
|
+
|
|
72
77
|
class AggregatingMergeTreeConfigDict(BaseEngineConfigDict):
|
|
73
78
|
"""Configuration for AggregatingMergeTree engine."""
|
|
74
79
|
engine: Literal["AggregatingMergeTree"] = "AggregatingMergeTree"
|
|
75
80
|
|
|
81
|
+
|
|
76
82
|
class SummingMergeTreeConfigDict(BaseEngineConfigDict):
|
|
77
83
|
"""Configuration for SummingMergeTree engine."""
|
|
78
84
|
engine: Literal["SummingMergeTree"] = "SummingMergeTree"
|
|
79
85
|
|
|
86
|
+
|
|
80
87
|
class S3QueueConfigDict(BaseEngineConfigDict):
|
|
81
88
|
"""Configuration for S3Queue engine with all specific fields."""
|
|
82
89
|
engine: Literal["S3Queue"] = "S3Queue"
|
|
@@ -87,6 +94,7 @@ class S3QueueConfigDict(BaseEngineConfigDict):
|
|
|
87
94
|
compression: Optional[str] = None
|
|
88
95
|
headers: Optional[Dict[str, str]] = None
|
|
89
96
|
|
|
97
|
+
|
|
90
98
|
# Discriminated union of all engine configurations
|
|
91
99
|
EngineConfigDict = Union[
|
|
92
100
|
MergeTreeConfigDict,
|
|
@@ -96,6 +104,7 @@ EngineConfigDict = Union[
|
|
|
96
104
|
S3QueueConfigDict
|
|
97
105
|
]
|
|
98
106
|
|
|
107
|
+
|
|
99
108
|
class TableConfig(BaseModel):
|
|
100
109
|
"""Internal representation of an OLAP table configuration for serialization.
|
|
101
110
|
|
|
@@ -103,6 +112,7 @@ class TableConfig(BaseModel):
|
|
|
103
112
|
name: Name of the table.
|
|
104
113
|
columns: List of columns with their types and attributes.
|
|
105
114
|
order_by: List of columns used for the ORDER BY clause.
|
|
115
|
+
partition_by: The column name used for the PARTITION BY clause.
|
|
106
116
|
engine_config: Engine configuration with type-safe, engine-specific parameters.
|
|
107
117
|
version: Optional version string of the table configuration.
|
|
108
118
|
metadata: Optional metadata for the table.
|
|
@@ -114,12 +124,14 @@ class TableConfig(BaseModel):
|
|
|
114
124
|
name: str
|
|
115
125
|
columns: List[Column]
|
|
116
126
|
order_by: List[str]
|
|
127
|
+
partition_by: Optional[str]
|
|
117
128
|
engine_config: Optional[EngineConfigDict] = Field(None, discriminator='engine')
|
|
118
129
|
version: Optional[str] = None
|
|
119
130
|
metadata: Optional[dict] = None
|
|
120
131
|
life_cycle: Optional[str] = None
|
|
121
132
|
table_settings: Optional[Dict[str, str]] = None
|
|
122
133
|
|
|
134
|
+
|
|
123
135
|
class TopicConfig(BaseModel):
|
|
124
136
|
"""Internal representation of a stream/topic configuration for serialization.
|
|
125
137
|
|
|
@@ -152,6 +164,7 @@ class TopicConfig(BaseModel):
|
|
|
152
164
|
metadata: Optional[dict] = None
|
|
153
165
|
life_cycle: Optional[str] = None
|
|
154
166
|
|
|
167
|
+
|
|
155
168
|
class IngestApiConfig(BaseModel):
|
|
156
169
|
"""Internal representation of an Ingest API configuration for serialization.
|
|
157
170
|
|
|
@@ -172,6 +185,7 @@ class IngestApiConfig(BaseModel):
|
|
|
172
185
|
metadata: Optional[dict] = None
|
|
173
186
|
json_schema: dict[str, Any] = Field(serialization_alias="schema")
|
|
174
187
|
|
|
188
|
+
|
|
175
189
|
class InternalApiConfig(BaseModel):
|
|
176
190
|
"""Internal representation of a API configuration for serialization.
|
|
177
191
|
|
|
@@ -190,6 +204,7 @@ class InternalApiConfig(BaseModel):
|
|
|
190
204
|
version: Optional[str] = None
|
|
191
205
|
metadata: Optional[dict] = None
|
|
192
206
|
|
|
207
|
+
|
|
193
208
|
class WorkflowJson(BaseModel):
|
|
194
209
|
"""Internal representation of a workflow configuration for serialization.
|
|
195
210
|
|
|
@@ -206,6 +221,7 @@ class WorkflowJson(BaseModel):
|
|
|
206
221
|
timeout: Optional[str] = None
|
|
207
222
|
schedule: Optional[str] = None
|
|
208
223
|
|
|
224
|
+
|
|
209
225
|
class InfrastructureSignatureJson(BaseModel):
|
|
210
226
|
"""Represents the unique signature of an infrastructure component (Table, Topic, etc.).
|
|
211
227
|
|
|
@@ -218,6 +234,7 @@ class InfrastructureSignatureJson(BaseModel):
|
|
|
218
234
|
id: str
|
|
219
235
|
kind: Literal["Table", "Topic", "ApiEndpoint", "TopicToTableSyncProcess", "View", "SqlResource"]
|
|
220
236
|
|
|
237
|
+
|
|
221
238
|
class SqlResourceConfig(BaseModel):
|
|
222
239
|
"""Internal representation of a generic SQL resource (like View, MaterializedView) for serialization.
|
|
223
240
|
|
|
@@ -280,12 +297,12 @@ def _map_sql_resource_ref(r: Any) -> InfrastructureSignatureJson:
|
|
|
280
297
|
if hasattr(r, 'kind'):
|
|
281
298
|
if r.kind == "OlapTable":
|
|
282
299
|
# Explicitly cast for type hint checking if needed, though Python is dynamic
|
|
283
|
-
table = r
|
|
300
|
+
table = r # type: OlapTable
|
|
284
301
|
res_id = f"{table.name}_{table.config.version}" if table.config.version else table.name
|
|
285
302
|
return InfrastructureSignatureJson(id=res_id, kind="Table")
|
|
286
303
|
elif r.kind == "SqlResource":
|
|
287
304
|
# Explicitly cast for type hint checking if needed
|
|
288
|
-
resource = r
|
|
305
|
+
resource = r # type: SqlResource
|
|
289
306
|
return InfrastructureSignatureJson(id=resource.name, kind="SqlResource")
|
|
290
307
|
else:
|
|
291
308
|
raise TypeError(f"Unknown SQL resource kind: {r.kind} for object: {r}")
|
|
@@ -294,7 +311,8 @@ def _map_sql_resource_ref(r: Any) -> InfrastructureSignatureJson:
|
|
|
294
311
|
raise TypeError(f"Object {r} lacks a 'kind' attribute for dependency mapping.")
|
|
295
312
|
|
|
296
313
|
|
|
297
|
-
def _convert_engine_to_config_dict(engine: Union[ClickHouseEngines, EngineConfig],
|
|
314
|
+
def _convert_engine_to_config_dict(engine: Union[ClickHouseEngines, EngineConfig],
|
|
315
|
+
table: OlapTable) -> EngineConfigDict:
|
|
298
316
|
"""Convert engine enum or EngineConfig instance to new engine config format.
|
|
299
317
|
|
|
300
318
|
Args:
|
|
@@ -306,12 +324,12 @@ def _convert_engine_to_config_dict(engine: Union[ClickHouseEngines, EngineConfig
|
|
|
306
324
|
"""
|
|
307
325
|
from moose_lib import ClickHouseEngines
|
|
308
326
|
from moose_lib.blocks import (
|
|
309
|
-
EngineConfig, S3QueueEngine, MergeTreeEngine,
|
|
310
|
-
ReplacingMergeTreeEngine, AggregatingMergeTreeEngine,
|
|
327
|
+
EngineConfig, S3QueueEngine, MergeTreeEngine,
|
|
328
|
+
ReplacingMergeTreeEngine, AggregatingMergeTreeEngine,
|
|
311
329
|
SummingMergeTreeEngine
|
|
312
330
|
)
|
|
313
331
|
from moose_lib.commons import Logger
|
|
314
|
-
|
|
332
|
+
|
|
315
333
|
# Check if engine is an EngineConfig instance (new API)
|
|
316
334
|
if isinstance(engine, EngineConfig):
|
|
317
335
|
if isinstance(engine, S3QueueEngine):
|
|
@@ -337,13 +355,13 @@ def _convert_engine_to_config_dict(engine: Union[ClickHouseEngines, EngineConfig
|
|
|
337
355
|
else:
|
|
338
356
|
# Fallback for any other EngineConfig subclass - use base class
|
|
339
357
|
return BaseEngineConfigDict(engine=engine.__class__.__name__.replace("Engine", ""))
|
|
340
|
-
|
|
358
|
+
|
|
341
359
|
# Handle legacy enum-based engine configuration
|
|
342
360
|
if isinstance(engine, ClickHouseEngines):
|
|
343
361
|
engine_name = engine.value
|
|
344
362
|
else:
|
|
345
363
|
engine_name = str(engine)
|
|
346
|
-
|
|
364
|
+
|
|
347
365
|
# For S3Queue with legacy configuration, check for s3_queue_engine_config
|
|
348
366
|
if engine_name == "S3Queue" and hasattr(table.config, 's3_queue_engine_config'):
|
|
349
367
|
s3_config = table.config.s3_queue_engine_config
|
|
@@ -361,7 +379,7 @@ def _convert_engine_to_config_dict(engine: Union[ClickHouseEngines, EngineConfig
|
|
|
361
379
|
compression=s3_config.compression,
|
|
362
380
|
headers=s3_config.headers
|
|
363
381
|
)
|
|
364
|
-
|
|
382
|
+
|
|
365
383
|
# Map engine names to specific config classes
|
|
366
384
|
engine_map = {
|
|
367
385
|
"MergeTree": MergeTreeConfigDict,
|
|
@@ -369,14 +387,15 @@ def _convert_engine_to_config_dict(engine: Union[ClickHouseEngines, EngineConfig
|
|
|
369
387
|
"AggregatingMergeTree": AggregatingMergeTreeConfigDict,
|
|
370
388
|
"SummingMergeTree": SummingMergeTreeConfigDict,
|
|
371
389
|
}
|
|
372
|
-
|
|
390
|
+
|
|
373
391
|
config_class = engine_map.get(engine_name)
|
|
374
392
|
if config_class:
|
|
375
393
|
return config_class()
|
|
376
|
-
|
|
394
|
+
|
|
377
395
|
# Fallback for unknown engines
|
|
378
396
|
return BaseEngineConfigDict(engine=engine_name)
|
|
379
397
|
|
|
398
|
+
|
|
380
399
|
def to_infra_map() -> dict:
|
|
381
400
|
"""Converts the registered `dmv2` resources into the serializable `InfrastructureMap` format.
|
|
382
401
|
|
|
@@ -400,25 +419,27 @@ def to_infra_map() -> dict:
|
|
|
400
419
|
engine_config = None
|
|
401
420
|
if table.config.engine:
|
|
402
421
|
engine_config = _convert_engine_to_config_dict(table.config.engine, table)
|
|
403
|
-
|
|
422
|
+
|
|
404
423
|
# Get table settings, applying defaults for S3Queue
|
|
405
424
|
table_settings = table.config.settings.copy() if table.config.settings else {}
|
|
406
|
-
|
|
425
|
+
|
|
407
426
|
# Apply default settings for S3Queue if not already specified
|
|
408
427
|
if engine_config and engine_config.engine == "S3Queue":
|
|
409
428
|
# Set default mode to 'unordered' if not specified
|
|
410
429
|
if "mode" not in table_settings:
|
|
411
430
|
table_settings["mode"] = "unordered"
|
|
412
|
-
|
|
431
|
+
|
|
413
432
|
tables[name] = TableConfig(
|
|
414
433
|
name=name,
|
|
415
434
|
columns=_to_columns(table._t),
|
|
416
435
|
order_by=table.config.order_by_fields,
|
|
436
|
+
partition_by=table.config.partition_by,
|
|
417
437
|
engine_config=engine_config,
|
|
418
438
|
version=table.config.version,
|
|
419
439
|
metadata=getattr(table, "metadata", None),
|
|
420
440
|
life_cycle=table.config.life_cycle.value if table.config.life_cycle else None,
|
|
421
|
-
|
|
441
|
+
# Map 'settings' to 'table_settings' for internal use
|
|
442
|
+
table_settings=table_settings if table_settings else None,
|
|
422
443
|
)
|
|
423
444
|
|
|
424
445
|
for name, stream in get_streams().items():
|
|
@@ -3,7 +3,7 @@ moose_lib/blocks.py,sha256=gC8dlV3HI4R8lO2wAxgLzn8WjKEMBjLiKyNAy4bssGE,11379
|
|
|
3
3
|
moose_lib/commons.py,sha256=FUpRv8D3-LeGcjhcqtDyiimz5izwpCq53h50ydxC_uA,3711
|
|
4
4
|
moose_lib/data_models.py,sha256=HT8ROf7HLS_BBlWvF-zGR7P-4gYURdMgfMlXa0O4i4s,10744
|
|
5
5
|
moose_lib/dmv2-serializer.py,sha256=CL_Pvvg8tJOT8Qk6hywDNzY8MYGhMVdTOw8arZi3jng,49
|
|
6
|
-
moose_lib/internal.py,sha256=
|
|
6
|
+
moose_lib/internal.py,sha256=MPSdZkJBi0tNyKTAkcT5pexraUo6roeNbg1L6gCsX68,20832
|
|
7
7
|
moose_lib/main.py,sha256=dLcRE4jshP6ViDVLj--Y83QRsEp0dpwh7WilSEZ4ICk,18541
|
|
8
8
|
moose_lib/query_param.py,sha256=kxcR09BMIsEg4o2qetjKrVu1YFRaLfMEzwzyGsKUpvA,6474
|
|
9
9
|
moose_lib/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -18,7 +18,7 @@ moose_lib/dmv2/ingest_api.py,sha256=Snek9NGwaJl_BuImSWGtQq91m9D3AJ4qBoGiKZ-9yTQ,
|
|
|
18
18
|
moose_lib/dmv2/ingest_pipeline.py,sha256=2tDM4gCjQMdDRDjvymI5Z1DlkXULx9nY4nG9M3YXpjk,7033
|
|
19
19
|
moose_lib/dmv2/life_cycle.py,sha256=wl0k6yzwU1MJ_fO_UkN29buoY5G6ChYZvfwigP9fVfM,1254
|
|
20
20
|
moose_lib/dmv2/materialized_view.py,sha256=3JbNLC26p7xOQK0DpgkreWKx7k5V3x3bz9a7kjDqKuU,4876
|
|
21
|
-
moose_lib/dmv2/olap_table.py,sha256=
|
|
21
|
+
moose_lib/dmv2/olap_table.py,sha256=fqGEphHubfR3oxVb6cXwmHVgx7gvb5QO7GCgDNnwAJI,33938
|
|
22
22
|
moose_lib/dmv2/registry.py,sha256=janjYszIXDnMfuwkNhoiBmMLar3umQ3Npw9Ms-u6p-8,2373
|
|
23
23
|
moose_lib/dmv2/sql_resource.py,sha256=kUZoGqxhZMHMthtBZGYJBxTFjXkspXiWLXhJRYXgGUM,1864
|
|
24
24
|
moose_lib/dmv2/stream.py,sha256=jiUWBsjFalLLP63mikOxyHRdieiDAlzf9lXfLye-Wjc,10761
|
|
@@ -34,7 +34,7 @@ tests/conftest.py,sha256=ZVJNbnr4DwbcqkTmePW6U01zAzE6QD0kNAEZjPG1f4s,169
|
|
|
34
34
|
tests/test_moose.py,sha256=mBsx_OYWmL8ppDzL_7Bd7xR6qf_i3-pCIO3wm2iQNaA,2136
|
|
35
35
|
tests/test_redis_client.py,sha256=d9_MLYsJ4ecVil_jPB2gW3Q5aWnavxmmjZg2uYI3LVo,3256
|
|
36
36
|
tests/test_s3queue_config.py,sha256=F05cnD61S2wBKPabcpEJxf55-DJGF4nLqwBb6aFbprc,9741
|
|
37
|
-
moose_lib-0.6.
|
|
38
|
-
moose_lib-0.6.
|
|
39
|
-
moose_lib-0.6.
|
|
40
|
-
moose_lib-0.6.
|
|
37
|
+
moose_lib-0.6.56.dist-info/METADATA,sha256=0lCIoV4D5Cg3df4jzZ9ssA_0xOIa-MVG5HHKOqObxR8,730
|
|
38
|
+
moose_lib-0.6.56.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
39
|
+
moose_lib-0.6.56.dist-info/top_level.txt,sha256=XEns2-4aCmGp2XjJAeEH9TAUcGONLnSLy6ycT9FSJh8,16
|
|
40
|
+
moose_lib-0.6.56.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|