moose-lib 0.4.162__py3-none-any.whl → 0.4.164__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.
- moose_lib/dmv2.py +33 -11
- moose_lib/internal.py +28 -6
- {moose_lib-0.4.162.dist-info → moose_lib-0.4.164.dist-info}/METADATA +1 -1
- {moose_lib-0.4.162.dist-info → moose_lib-0.4.164.dist-info}/RECORD +6 -6
- {moose_lib-0.4.162.dist-info → moose_lib-0.4.164.dist-info}/WHEEL +0 -0
- {moose_lib-0.4.162.dist-info → moose_lib-0.4.164.dist-info}/top_level.txt +0 -0
moose_lib/dmv2.py
CHANGED
@@ -122,12 +122,14 @@ class OlapConfig(BaseModel):
|
|
122
122
|
setting `engine=ClickHouseEngines.ReplacingMergeTree`.
|
123
123
|
engine: The ClickHouse table engine to use (e.g., MergeTree, ReplacingMergeTree).
|
124
124
|
version: Optional version string for tracking configuration changes.
|
125
|
+
metadata: Optional metadata for the table.
|
125
126
|
"""
|
126
127
|
order_by_fields: list[str] = []
|
127
128
|
# equivalent to setting `engine=ClickHouseEngines.ReplacingMergeTree`
|
128
129
|
deduplicate: bool = False
|
129
130
|
engine: Optional[ClickHouseEngines] = None
|
130
131
|
version: Optional[str] = None
|
132
|
+
metadata: Optional[dict] = None
|
131
133
|
|
132
134
|
|
133
135
|
class OlapTable(TypedMooseResource, Generic[T]):
|
@@ -152,6 +154,7 @@ class OlapTable(TypedMooseResource, Generic[T]):
|
|
152
154
|
super().__init__()
|
153
155
|
self._set_type(name, self._get_type(kwargs))
|
154
156
|
self.config = config
|
157
|
+
self.metadata = config.metadata
|
155
158
|
_tables[name] = self
|
156
159
|
|
157
160
|
|
@@ -163,11 +166,13 @@ class StreamConfig(BaseModel):
|
|
163
166
|
retention_period: Data retention period in seconds (default: 7 days).
|
164
167
|
destination: Optional `OlapTable` where stream messages should be automatically ingested.
|
165
168
|
version: Optional version string for tracking configuration changes.
|
169
|
+
metadata: Optional metadata for the stream.
|
166
170
|
"""
|
167
171
|
parallelism: int = 1
|
168
172
|
retention_period: int = 60 * 60 * 24 * 7 # 7 days
|
169
173
|
destination: Optional[OlapTable[Any]] = None
|
170
174
|
version: Optional[str] = None
|
175
|
+
metadata: Optional[dict] = None
|
171
176
|
|
172
177
|
|
173
178
|
class TransformConfig(BaseModel):
|
@@ -180,6 +185,7 @@ class TransformConfig(BaseModel):
|
|
180
185
|
version: Optional[str] = None
|
181
186
|
dead_letter_queue: "Optional[DeadLetterQueue]" = None
|
182
187
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
188
|
+
metadata: Optional[dict] = None
|
183
189
|
|
184
190
|
|
185
191
|
class ConsumerConfig(BaseModel):
|
@@ -244,6 +250,7 @@ class Stream(TypedMooseResource, Generic[T]):
|
|
244
250
|
super().__init__()
|
245
251
|
self._set_type(name, self._get_type(kwargs))
|
246
252
|
self.config = config
|
253
|
+
self.metadata = config.metadata
|
247
254
|
self.consumers = []
|
248
255
|
self.transformations = {}
|
249
256
|
_streams[name] = self
|
@@ -399,8 +406,10 @@ class IngestConfig(BaseModel):
|
|
399
406
|
|
400
407
|
Attributes:
|
401
408
|
version: Optional version string.
|
409
|
+
metadata: Optional metadata for the ingestion point.
|
402
410
|
"""
|
403
411
|
version: Optional[str] = None
|
412
|
+
metadata: Optional[dict] = None
|
404
413
|
|
405
414
|
|
406
415
|
@dataclasses.dataclass
|
@@ -410,9 +419,11 @@ class IngestConfigWithDestination[T: BaseModel]:
|
|
410
419
|
Attributes:
|
411
420
|
destination: The `Stream` where ingested data will be sent.
|
412
421
|
version: Optional version string.
|
422
|
+
metadata: Optional metadata for the ingestion configuration.
|
413
423
|
"""
|
414
424
|
destination: Stream[T]
|
415
425
|
version: Optional[str] = None
|
426
|
+
metadata: Optional[dict] = None
|
416
427
|
|
417
428
|
|
418
429
|
class IngestPipelineConfig(BaseModel):
|
@@ -427,11 +438,13 @@ class IngestPipelineConfig(BaseModel):
|
|
427
438
|
stream: Configuration for the stream component.
|
428
439
|
ingest: Configuration for the ingest API component.
|
429
440
|
version: Optional version string applied to all created components.
|
441
|
+
metadata: Optional metadata for the ingestion pipeline.
|
430
442
|
"""
|
431
443
|
table: bool | OlapConfig = True
|
432
444
|
stream: bool | StreamConfig = True
|
433
445
|
ingest: bool | IngestConfig = True
|
434
446
|
version: Optional[str] = None
|
447
|
+
metadata: Optional[dict] = None
|
435
448
|
|
436
449
|
|
437
450
|
class IngestApi(TypedMooseResource, Generic[T]):
|
@@ -458,6 +471,7 @@ class IngestApi(TypedMooseResource, Generic[T]):
|
|
458
471
|
super().__init__()
|
459
472
|
self._set_type(name, self._get_type(kwargs))
|
460
473
|
self.config = config
|
474
|
+
self.metadata = getattr(config, 'metadata', None)
|
461
475
|
_ingest_apis[name] = self
|
462
476
|
|
463
477
|
|
@@ -527,10 +541,15 @@ class IngestPipeline(TypedMooseResource, Generic[T]):
|
|
527
541
|
def __init__(self, name: str, config: IngestPipelineConfig, **kwargs):
|
528
542
|
super().__init__()
|
529
543
|
self._set_type(name, self._get_type(kwargs))
|
544
|
+
self.metadata = config.metadata
|
545
|
+
table_metadata = config.metadata
|
546
|
+
stream_metadata = config.metadata
|
547
|
+
ingest_metadata = config.metadata
|
530
548
|
if config.table:
|
531
549
|
table_config = OlapConfig() if config.table is True else config.table
|
532
550
|
if config.version:
|
533
551
|
table_config.version = config.version
|
552
|
+
table_config.metadata = table_metadata
|
534
553
|
self.table = OlapTable(name, table_config, t=self._t)
|
535
554
|
if config.stream:
|
536
555
|
stream_config = StreamConfig() if config.stream is True else config.stream
|
@@ -539,6 +558,7 @@ class IngestPipeline(TypedMooseResource, Generic[T]):
|
|
539
558
|
stream_config.destination = self.table
|
540
559
|
if config.version:
|
541
560
|
stream_config.version = config.version
|
561
|
+
stream_config.metadata = stream_metadata
|
542
562
|
self.stream = Stream(name, stream_config, t=self._t)
|
543
563
|
if config.ingest:
|
544
564
|
if self.stream is None:
|
@@ -549,6 +569,7 @@ class IngestPipeline(TypedMooseResource, Generic[T]):
|
|
549
569
|
ingest_config_dict["destination"] = self.stream
|
550
570
|
if config.version:
|
551
571
|
ingest_config_dict["version"] = config.version
|
572
|
+
ingest_config_dict["metadata"] = ingest_metadata
|
552
573
|
ingest_config = IngestConfigWithDestination(**ingest_config_dict)
|
553
574
|
self.ingest_api = IngestApi(name, ingest_config, t=self._t)
|
554
575
|
|
@@ -558,8 +579,10 @@ class EgressConfig(BaseModel):
|
|
558
579
|
|
559
580
|
Attributes:
|
560
581
|
version: Optional version string.
|
582
|
+
metadata: Optional metadata for the consumption API.
|
561
583
|
"""
|
562
584
|
version: Optional[str] = None
|
585
|
+
metadata: Optional[dict] = None
|
563
586
|
|
564
587
|
|
565
588
|
class ConsumptionApi(BaseTypedResource, Generic[T, U]):
|
@@ -599,17 +622,12 @@ class ConsumptionApi(BaseTypedResource, Generic[T, U]):
|
|
599
622
|
|
600
623
|
return curried_constructor
|
601
624
|
|
602
|
-
def __init__(
|
603
|
-
self,
|
604
|
-
name: str,
|
605
|
-
query_function: Callable[..., U],
|
606
|
-
config: EgressConfig = EgressConfig(),
|
607
|
-
**kwargs
|
608
|
-
):
|
625
|
+
def __init__(self, name: str, query_function: Callable[..., U], config: EgressConfig = EgressConfig(), **kwargs):
|
609
626
|
super().__init__()
|
610
627
|
self._set_type(name, self._get_type(kwargs))
|
611
628
|
self.config = config
|
612
629
|
self.query_function = query_function
|
630
|
+
self.metadata = config.metadata
|
613
631
|
_egress_apis[name] = self
|
614
632
|
|
615
633
|
@classmethod
|
@@ -680,13 +698,15 @@ class SqlResource:
|
|
680
698
|
setup: list[str],
|
681
699
|
teardown: list[str],
|
682
700
|
pulls_data_from: Optional[list[Union[OlapTable, "SqlResource"]]] = None,
|
683
|
-
pushes_data_to: Optional[list[Union[OlapTable, "SqlResource"]]] = None
|
701
|
+
pushes_data_to: Optional[list[Union[OlapTable, "SqlResource"]]] = None,
|
702
|
+
metadata: dict = None
|
684
703
|
):
|
685
704
|
self.name = name
|
686
705
|
self.setup = setup
|
687
706
|
self.teardown = teardown
|
688
707
|
self.pulls_data_from = pulls_data_from or []
|
689
708
|
self.pushes_data_to = pushes_data_to or []
|
709
|
+
self.metadata = metadata
|
690
710
|
_sql_resources[name] = self
|
691
711
|
|
692
712
|
|
@@ -700,12 +720,12 @@ class View(SqlResource):
|
|
700
720
|
that this view depends on.
|
701
721
|
"""
|
702
722
|
|
703
|
-
def __init__(self, name: str, select_statement: str, base_tables: list[Union[OlapTable, SqlResource]]):
|
723
|
+
def __init__(self, name: str, select_statement: str, base_tables: list[Union[OlapTable, SqlResource]], metadata: dict = None):
|
704
724
|
setup = [
|
705
725
|
f"CREATE VIEW IF NOT EXISTS {name} AS {select_statement}".strip()
|
706
726
|
]
|
707
727
|
teardown = [f"DROP VIEW IF EXISTS {name}"]
|
708
|
-
super().__init__(name, setup, teardown, pulls_data_from=base_tables)
|
728
|
+
super().__init__(name, setup, teardown, pulls_data_from=base_tables, metadata=metadata)
|
709
729
|
|
710
730
|
|
711
731
|
class MaterializedViewOptions(BaseModel):
|
@@ -758,6 +778,7 @@ class MaterializedView(SqlResource, BaseTypedResource, Generic[T]):
|
|
758
778
|
def __init__(
|
759
779
|
self,
|
760
780
|
options: MaterializedViewOptions,
|
781
|
+
metadata: dict = None,
|
761
782
|
**kwargs
|
762
783
|
):
|
763
784
|
self._set_type(options.materialized_view_name, self._get_type(kwargs))
|
@@ -782,7 +803,8 @@ class MaterializedView(SqlResource, BaseTypedResource, Generic[T]):
|
|
782
803
|
setup,
|
783
804
|
teardown,
|
784
805
|
pulls_data_from=options.select_tables,
|
785
|
-
pushes_data_to=[target_table]
|
806
|
+
pushes_data_to=[target_table],
|
807
|
+
metadata=metadata
|
786
808
|
)
|
787
809
|
|
788
810
|
self.target_table = target_table
|
moose_lib/internal.py
CHANGED
@@ -28,10 +28,12 @@ class Target(BaseModel):
|
|
28
28
|
kind: The type of the target (currently only "stream").
|
29
29
|
name: The name of the target stream.
|
30
30
|
version: Optional version of the target stream configuration.
|
31
|
+
metadata: Optional metadata for the target stream.
|
31
32
|
"""
|
32
33
|
kind: Literal["stream"]
|
33
34
|
name: str
|
34
35
|
version: Optional[str] = None
|
36
|
+
metadata: Optional[dict] = None
|
35
37
|
|
36
38
|
class Consumer(BaseModel):
|
37
39
|
"""Represents a consumer attached to a stream.
|
@@ -51,6 +53,7 @@ class TableConfig(BaseModel):
|
|
51
53
|
deduplicate: Whether the table uses a deduplicating engine (e.g., ReplacingMergeTree).
|
52
54
|
engine: The name of the ClickHouse engine used.
|
53
55
|
version: Optional version string of the table configuration.
|
56
|
+
metadata: Optional metadata for the table.
|
54
57
|
"""
|
55
58
|
model_config = model_config
|
56
59
|
|
@@ -60,6 +63,7 @@ class TableConfig(BaseModel):
|
|
60
63
|
deduplicate: bool
|
61
64
|
engine: Optional[str]
|
62
65
|
version: Optional[str] = None
|
66
|
+
metadata: Optional[dict] = None
|
63
67
|
|
64
68
|
class TopicConfig(BaseModel):
|
65
69
|
"""Internal representation of a stream/topic configuration for serialization.
|
@@ -75,6 +79,7 @@ class TopicConfig(BaseModel):
|
|
75
79
|
transformation_targets: List of streams this topic transforms data into.
|
76
80
|
has_multi_transform: Flag indicating if a multi-transform function is defined.
|
77
81
|
consumers: List of consumers attached to this topic.
|
82
|
+
metadata: Optional metadata for the topic.
|
78
83
|
"""
|
79
84
|
model_config = model_config
|
80
85
|
|
@@ -88,6 +93,7 @@ class TopicConfig(BaseModel):
|
|
88
93
|
transformation_targets: List[Target]
|
89
94
|
has_multi_transform: bool
|
90
95
|
consumers: List[Consumer]
|
96
|
+
metadata: Optional[dict] = None
|
91
97
|
|
92
98
|
class IngestApiConfig(BaseModel):
|
93
99
|
"""Internal representation of an Ingest API configuration for serialization.
|
@@ -97,6 +103,7 @@ class IngestApiConfig(BaseModel):
|
|
97
103
|
columns: List of columns expected in the input data.
|
98
104
|
write_to: The target stream where the ingested data is written.
|
99
105
|
version: Optional version string of the API configuration.
|
106
|
+
metadata: Optional metadata for the API.
|
100
107
|
"""
|
101
108
|
model_config = model_config
|
102
109
|
|
@@ -104,6 +111,7 @@ class IngestApiConfig(BaseModel):
|
|
104
111
|
columns: List[Column]
|
105
112
|
write_to: Target
|
106
113
|
version: Optional[str] = None
|
114
|
+
metadata: Optional[dict] = None
|
107
115
|
|
108
116
|
class EgressApiConfig(BaseModel):
|
109
117
|
"""Internal representation of a Consumption (Egress) API configuration for serialization.
|
@@ -113,6 +121,7 @@ class EgressApiConfig(BaseModel):
|
|
113
121
|
query_params: List of columns representing the expected query parameters.
|
114
122
|
response_schema: JSON schema definition of the API's response body.
|
115
123
|
version: Optional version string of the API configuration.
|
124
|
+
metadata: Optional metadata for the API.
|
116
125
|
"""
|
117
126
|
model_config = model_config
|
118
127
|
|
@@ -120,6 +129,7 @@ class EgressApiConfig(BaseModel):
|
|
120
129
|
query_params: List[Column]
|
121
130
|
response_schema: JsonSchemaValue
|
122
131
|
version: Optional[str] = None
|
132
|
+
metadata: Optional[dict] = None
|
123
133
|
|
124
134
|
class InfrastructureSignatureJson(BaseModel):
|
125
135
|
"""Represents the unique signature of an infrastructure component (Table, Topic, etc.).
|
@@ -142,6 +152,7 @@ class SqlResourceConfig(BaseModel):
|
|
142
152
|
teardown: List of SQL commands required to drop the resource.
|
143
153
|
pulls_data_from: List of infrastructure components this resource reads from.
|
144
154
|
pushes_data_to: List of infrastructure components this resource writes to.
|
155
|
+
metadata: Optional metadata for the resource.
|
145
156
|
"""
|
146
157
|
model_config = model_config
|
147
158
|
|
@@ -150,6 +161,7 @@ class SqlResourceConfig(BaseModel):
|
|
150
161
|
teardown: list[str]
|
151
162
|
pulls_data_from: list[InfrastructureSignatureJson]
|
152
163
|
pushes_data_to: list[InfrastructureSignatureJson]
|
164
|
+
metadata: Optional[dict] = None
|
153
165
|
|
154
166
|
|
155
167
|
class InfrastructureMap(BaseModel):
|
@@ -230,12 +242,18 @@ def to_infra_map() -> dict:
|
|
230
242
|
order_by=table.config.order_by_fields,
|
231
243
|
deduplicate=table.config.deduplicate,
|
232
244
|
engine=None if engine is None else engine.value,
|
233
|
-
version=table.config.version
|
245
|
+
version=table.config.version,
|
246
|
+
metadata=getattr(table, "metadata", None),
|
234
247
|
)
|
235
248
|
|
236
249
|
for name, stream in _streams.items():
|
237
250
|
transformation_targets = [
|
238
|
-
Target(
|
251
|
+
Target(
|
252
|
+
kind="stream",
|
253
|
+
name=dest_name,
|
254
|
+
version=transform.config.version,
|
255
|
+
metadata=getattr(transform.config, "metadata", None),
|
256
|
+
)
|
239
257
|
for dest_name, transforms in stream.transformations.items()
|
240
258
|
for transform in transforms
|
241
259
|
]
|
@@ -255,7 +273,8 @@ def to_infra_map() -> dict:
|
|
255
273
|
version=stream.config.version,
|
256
274
|
transformation_targets=transformation_targets,
|
257
275
|
has_multi_transform=stream._multipleTransformations is not None,
|
258
|
-
consumers=consumers
|
276
|
+
consumers=consumers,
|
277
|
+
metadata=getattr(stream, "metadata", None),
|
259
278
|
)
|
260
279
|
|
261
280
|
for name, api in _ingest_apis.items():
|
@@ -266,7 +285,8 @@ def to_infra_map() -> dict:
|
|
266
285
|
write_to=Target(
|
267
286
|
kind="stream",
|
268
287
|
name=api.config.destination.name
|
269
|
-
)
|
288
|
+
),
|
289
|
+
metadata=getattr(api, "metadata", None),
|
270
290
|
)
|
271
291
|
|
272
292
|
for name, api in _egress_apis.items():
|
@@ -274,7 +294,8 @@ def to_infra_map() -> dict:
|
|
274
294
|
name=name,
|
275
295
|
query_params=_to_columns(api.model_type),
|
276
296
|
response_schema=api.get_response_schema(),
|
277
|
-
version=api.config.version
|
297
|
+
version=api.config.version,
|
298
|
+
metadata=getattr(api, "metadata", None),
|
278
299
|
)
|
279
300
|
|
280
301
|
for name, resource in _sql_resources.items():
|
@@ -283,7 +304,8 @@ def to_infra_map() -> dict:
|
|
283
304
|
setup=resource.setup,
|
284
305
|
teardown=resource.teardown,
|
285
306
|
pulls_data_from=[_map_sql_resource_ref(dep) for dep in resource.pulls_data_from],
|
286
|
-
pushes_data_to=[_map_sql_resource_ref(dep) for dep in resource.pushes_data_to]
|
307
|
+
pushes_data_to=[_map_sql_resource_ref(dep) for dep in resource.pushes_data_to],
|
308
|
+
metadata=getattr(resource, "metadata", None),
|
287
309
|
)
|
288
310
|
|
289
311
|
infra_map = InfrastructureMap(
|
@@ -3,8 +3,8 @@ moose_lib/blocks.py,sha256=_wdvC2NC_Y3MMEnB71WTgWbeQ--zPNHk19xjToJW0C0,3185
|
|
3
3
|
moose_lib/commons.py,sha256=BV5X78MuOWHiZV9bsWSN69JIvzTNWUi-gnuMiAtaO8A,2489
|
4
4
|
moose_lib/data_models.py,sha256=1U8IFQaO1hR8pNGb1UTtdcGQehGgKIvLNtUFFFXC1Ko,7695
|
5
5
|
moose_lib/dmv2-serializer.py,sha256=CL_Pvvg8tJOT8Qk6hywDNzY8MYGhMVdTOw8arZi3jng,49
|
6
|
-
moose_lib/dmv2.py,sha256=
|
7
|
-
moose_lib/internal.py,sha256=
|
6
|
+
moose_lib/dmv2.py,sha256=f3VsBYcTcWU1rEUjqG9cHcZxRUlXP_yBTbyoc7Tp7oI,31754
|
7
|
+
moose_lib/internal.py,sha256=gREvC3XxBFN4i7JL5uMj0riCu_JUO2YyiMZvCokg1ME,13101
|
8
8
|
moose_lib/main.py,sha256=In-u7yA1FsLDeP_2bhIgBtHY_BkXaZqDwf7BxwyC21c,8471
|
9
9
|
moose_lib/query_param.py,sha256=AB5BKu610Ji-h1iYGMBZKfnEFqt85rS94kzhDwhWJnc,6288
|
10
10
|
moose_lib/tasks.py,sha256=6MXA0j7nhvQILAJVTQHCAsquwrSOi2zAevghAc_7kXs,1554
|
@@ -13,7 +13,7 @@ moose_lib/streaming/streaming_function_runner.py,sha256=K53lyzGLawAgKgrK3jreJrB7
|
|
13
13
|
tests/__init__.py,sha256=0Gh4yzPkkC3TzBGKhenpMIxJcRhyrrCfxLSfpTZnPMQ,53
|
14
14
|
tests/conftest.py,sha256=ZVJNbnr4DwbcqkTmePW6U01zAzE6QD0kNAEZjPG1f4s,169
|
15
15
|
tests/test_moose.py,sha256=mBsx_OYWmL8ppDzL_7Bd7xR6qf_i3-pCIO3wm2iQNaA,2136
|
16
|
-
moose_lib-0.4.
|
17
|
-
moose_lib-0.4.
|
18
|
-
moose_lib-0.4.
|
19
|
-
moose_lib-0.4.
|
16
|
+
moose_lib-0.4.164.dist-info/METADATA,sha256=kc5TOymVYCETNBq1SQ4H4vTVyOkmRLOhhs7KBVjsYA4,575
|
17
|
+
moose_lib-0.4.164.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
18
|
+
moose_lib-0.4.164.dist-info/top_level.txt,sha256=XEns2-4aCmGp2XjJAeEH9TAUcGONLnSLy6ycT9FSJh8,16
|
19
|
+
moose_lib-0.4.164.dist-info/RECORD,,
|
File without changes
|
File without changes
|