dagster-sling 0.26.21__py3-none-any.whl → 0.27.1__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 dagster-sling might be problematic. Click here for more details.
- dagster_sling/asset_decorator.py +32 -18
- dagster_sling/components/sling_replication_collection/component.py +68 -11
- dagster_sling/dagster_sling_translator.py +5 -5
- dagster_sling/version.py +1 -1
- {dagster_sling-0.26.21.dist-info → dagster_sling-0.27.1.dist-info}/METADATA +2 -2
- {dagster_sling-0.26.21.dist-info → dagster_sling-0.27.1.dist-info}/RECORD +10 -10
- {dagster_sling-0.26.21.dist-info → dagster_sling-0.27.1.dist-info}/WHEEL +0 -0
- {dagster_sling-0.26.21.dist-info → dagster_sling-0.27.1.dist-info}/entry_points.txt +0 -0
- {dagster_sling-0.26.21.dist-info → dagster_sling-0.27.1.dist-info}/licenses/LICENSE +0 -0
- {dagster_sling-0.26.21.dist-info → dagster_sling-0.27.1.dist-info}/top_level.txt +0 -0
dagster_sling/asset_decorator.py
CHANGED
|
@@ -104,6 +104,22 @@ def sling_assets(
|
|
|
104
104
|
def my_assets(context, sling: SlingResource):
|
|
105
105
|
yield from sling.replicate(context=context)
|
|
106
106
|
"""
|
|
107
|
+
return multi_asset(
|
|
108
|
+
name=name,
|
|
109
|
+
partitions_def=partitions_def,
|
|
110
|
+
can_subset=True,
|
|
111
|
+
op_tags=op_tags,
|
|
112
|
+
backfill_policy=backfill_policy,
|
|
113
|
+
specs=get_sling_asset_specs(replication_config, dagster_sling_translator, partitions_def),
|
|
114
|
+
pool=pool,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def get_sling_asset_specs(
|
|
119
|
+
replication_config: SlingReplicationParam,
|
|
120
|
+
dagster_sling_translator: Optional[DagsterSlingTranslator] = None,
|
|
121
|
+
partitions_def: Optional[PartitionsDefinition] = None,
|
|
122
|
+
) -> list[AssetSpec]:
|
|
107
123
|
replication_config = validate_replication(replication_config)
|
|
108
124
|
|
|
109
125
|
raw_streams = get_streams_from_replication(replication_config)
|
|
@@ -124,22 +140,20 @@ def sling_assets(
|
|
|
124
140
|
return asset_spec.replace_attributes(code_version=code_version)
|
|
125
141
|
return asset_spec
|
|
126
142
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
update_code_version_if_unset_by_translator(
|
|
135
|
-
dagster_sling_translator.get_asset_spec(stream).merge_attributes(
|
|
136
|
-
metadata={
|
|
137
|
-
METADATA_KEY_TRANSLATOR: dagster_sling_translator,
|
|
138
|
-
METADATA_KEY_REPLICATION_CONFIG: replication_config,
|
|
139
|
-
}
|
|
140
|
-
)
|
|
143
|
+
base_specs = [
|
|
144
|
+
update_code_version_if_unset_by_translator(
|
|
145
|
+
dagster_sling_translator.get_asset_spec(stream).merge_attributes(
|
|
146
|
+
metadata={
|
|
147
|
+
METADATA_KEY_TRANSLATOR: dagster_sling_translator,
|
|
148
|
+
METADATA_KEY_REPLICATION_CONFIG: replication_config,
|
|
149
|
+
}
|
|
141
150
|
)
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
)
|
|
152
|
+
for stream in streams
|
|
153
|
+
]
|
|
154
|
+
return [
|
|
155
|
+
spec.replace_attributes(
|
|
156
|
+
partitions_def=partitions_def or spec.partitions_def, skippable=True
|
|
157
|
+
)
|
|
158
|
+
for spec in base_specs
|
|
159
|
+
]
|
|
@@ -21,6 +21,8 @@ from dagster.components.resolved.context import ResolutionContext
|
|
|
21
21
|
from dagster.components.resolved.core_models import AssetAttributesModel, AssetPostProcessor, OpSpec
|
|
22
22
|
from dagster.components.scaffold.scaffold import scaffold_with
|
|
23
23
|
from dagster.components.utils import TranslatorResolvingInfo
|
|
24
|
+
from dagster_shared.utils.warnings import deprecation_warning
|
|
25
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
24
26
|
from typing_extensions import TypeAlias
|
|
25
27
|
|
|
26
28
|
from dagster_sling.asset_decorator import sling_assets
|
|
@@ -28,7 +30,7 @@ from dagster_sling.components.sling_replication_collection.scaffolder import (
|
|
|
28
30
|
SlingReplicationComponentScaffolder,
|
|
29
31
|
)
|
|
30
32
|
from dagster_sling.dagster_sling_translator import DagsterSlingTranslator
|
|
31
|
-
from dagster_sling.resources import AssetExecutionContext, SlingResource
|
|
33
|
+
from dagster_sling.resources import AssetExecutionContext, SlingConnectionResource, SlingResource
|
|
32
34
|
|
|
33
35
|
SlingMetadataAddons: TypeAlias = Literal["column_metadata", "row_count"]
|
|
34
36
|
|
|
@@ -87,8 +89,59 @@ class SlingReplicationSpecModel(Resolvable):
|
|
|
87
89
|
def resolve_resource(
|
|
88
90
|
context: ResolutionContext,
|
|
89
91
|
sling,
|
|
90
|
-
) -> SlingResource:
|
|
91
|
-
|
|
92
|
+
) -> Optional[SlingResource]:
|
|
93
|
+
if sling:
|
|
94
|
+
deprecation_warning(
|
|
95
|
+
"The `sling` field is deprecated, use `connections` instead. This field will be removed in a future release.",
|
|
96
|
+
"1.11.1",
|
|
97
|
+
)
|
|
98
|
+
return SlingResource(**context.resolve_value(sling.model_dump())) if sling else None
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def replicate(
|
|
102
|
+
context: AssetExecutionContext,
|
|
103
|
+
connections: list[SlingConnectionResource],
|
|
104
|
+
) -> Iterator[Union[AssetMaterialization, MaterializeResult]]:
|
|
105
|
+
sling = SlingResource(connections=connections)
|
|
106
|
+
yield from sling.replicate(context=context)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class SlingConnectionResourcePropertiesModel(Resolvable, BaseModel):
|
|
110
|
+
"""Properties of a Sling connection resource."""
|
|
111
|
+
|
|
112
|
+
# each connection type supports a variety of different properties
|
|
113
|
+
model_config = ConfigDict(extra="allow")
|
|
114
|
+
|
|
115
|
+
type: str = Field(
|
|
116
|
+
description="Type of the source connection, must match the Sling connection types. Use 'file' for local storage."
|
|
117
|
+
)
|
|
118
|
+
connection_string: Optional[str] = Field(
|
|
119
|
+
description="The optional connection string for the source database, if not using keyword arguments.",
|
|
120
|
+
default=None,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def resolve_connections(
|
|
125
|
+
context: ResolutionContext,
|
|
126
|
+
connections: Mapping[str, SlingConnectionResourcePropertiesModel],
|
|
127
|
+
) -> list[SlingConnectionResource]:
|
|
128
|
+
return [
|
|
129
|
+
SlingConnectionResource(
|
|
130
|
+
name=name,
|
|
131
|
+
**context.resolve_value(
|
|
132
|
+
connection if isinstance(connection, dict) else connection.model_dump()
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
for name, connection in connections.items()
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
ResolvedSlingConnections: TypeAlias = Annotated[
|
|
140
|
+
list[SlingConnectionResource],
|
|
141
|
+
Resolver(
|
|
142
|
+
resolve_connections, model_field_type=Mapping[str, SlingConnectionResourcePropertiesModel]
|
|
143
|
+
),
|
|
144
|
+
]
|
|
92
145
|
|
|
93
146
|
|
|
94
147
|
@scaffold_with(SlingReplicationComponentScaffolder)
|
|
@@ -105,16 +158,18 @@ class SlingReplicationCollectionComponent(Component, Resolvable):
|
|
|
105
158
|
file. See Sling's [documentation](https://docs.slingdata.io/concepts/replication#overview) on `replication.yaml`.
|
|
106
159
|
"""
|
|
107
160
|
|
|
108
|
-
|
|
109
|
-
SlingResource,
|
|
110
|
-
Resolver(
|
|
111
|
-
resolve_resource,
|
|
112
|
-
model_field_name="sling",
|
|
113
|
-
),
|
|
114
|
-
] = field(default_factory=SlingResource)
|
|
161
|
+
connections: ResolvedSlingConnections = field(default_factory=list)
|
|
115
162
|
replications: Sequence[SlingReplicationSpecModel] = field(default_factory=list)
|
|
116
163
|
# TODO: deprecate and then delete -- schrockn 2025-06-10
|
|
117
164
|
asset_post_processors: Optional[Sequence[AssetPostProcessor]] = None
|
|
165
|
+
resource: Annotated[
|
|
166
|
+
Optional[SlingResource],
|
|
167
|
+
Resolver(resolve_resource, model_field_name="sling"),
|
|
168
|
+
] = None
|
|
169
|
+
|
|
170
|
+
@cached_property
|
|
171
|
+
def sling_resource(self) -> SlingResource:
|
|
172
|
+
return self.resource or SlingResource(connections=self.connections)
|
|
118
173
|
|
|
119
174
|
def build_asset(
|
|
120
175
|
self, context: ComponentLoadContext, replication_spec_model: SlingReplicationSpecModel
|
|
@@ -142,7 +197,9 @@ class SlingReplicationCollectionComponent(Component, Resolvable):
|
|
|
142
197
|
)
|
|
143
198
|
def _asset(context: AssetExecutionContext):
|
|
144
199
|
yield from self.execute(
|
|
145
|
-
context=context,
|
|
200
|
+
context=context,
|
|
201
|
+
sling=self.sling_resource,
|
|
202
|
+
replication_spec_model=replication_spec_model,
|
|
146
203
|
)
|
|
147
204
|
|
|
148
205
|
return _asset
|
|
@@ -2,7 +2,7 @@ from collections.abc import Iterable, Mapping
|
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
from typing import Any, Callable, Optional
|
|
4
4
|
|
|
5
|
-
from dagster import AssetKey, AssetSpec, AutoMaterializePolicy,
|
|
5
|
+
from dagster import AssetKey, AssetSpec, AutoMaterializePolicy, LegacyFreshnessPolicy, MetadataValue
|
|
6
6
|
from dagster._annotations import public, superseded
|
|
7
7
|
from dagster._utils.names import clean_name_lower_with_dots
|
|
8
8
|
from dagster._utils.warnings import supersession_warning
|
|
@@ -42,7 +42,7 @@ class DagsterSlingTranslator:
|
|
|
42
42
|
group_name=self._resolve_back_compat_method(
|
|
43
43
|
"get_group_name", self._default_group_name_fn, stream_definition
|
|
44
44
|
),
|
|
45
|
-
|
|
45
|
+
legacy_freshness_policy=self._resolve_back_compat_method(
|
|
46
46
|
"get_freshness_policy", self._default_freshness_policy_fn, stream_definition
|
|
47
47
|
),
|
|
48
48
|
auto_materialize_policy=self._resolve_back_compat_method(
|
|
@@ -471,7 +471,7 @@ class DagsterSlingTranslator:
|
|
|
471
471
|
@public
|
|
472
472
|
def get_freshness_policy(
|
|
473
473
|
self, stream_definition: Mapping[str, Any]
|
|
474
|
-
) -> Optional[
|
|
474
|
+
) -> Optional[LegacyFreshnessPolicy]:
|
|
475
475
|
"""Retrieves the freshness policy for a given stream definition.
|
|
476
476
|
|
|
477
477
|
This method checks the provided stream definition for a specific configuration
|
|
@@ -491,7 +491,7 @@ class DagsterSlingTranslator:
|
|
|
491
491
|
|
|
492
492
|
def _default_freshness_policy_fn(
|
|
493
493
|
self, stream_definition: Mapping[str, Any]
|
|
494
|
-
) -> Optional[
|
|
494
|
+
) -> Optional[LegacyFreshnessPolicy]:
|
|
495
495
|
"""Retrieves the freshness policy for a given stream definition.
|
|
496
496
|
|
|
497
497
|
This method checks the provided stream definition for a specific configuration
|
|
@@ -511,7 +511,7 @@ class DagsterSlingTranslator:
|
|
|
511
511
|
meta = config.get("meta", {})
|
|
512
512
|
freshness_policy_config = meta.get("dagster", {}).get("freshness_policy")
|
|
513
513
|
if freshness_policy_config:
|
|
514
|
-
return
|
|
514
|
+
return LegacyFreshnessPolicy(
|
|
515
515
|
maximum_lag_minutes=float(freshness_policy_config["maximum_lag_minutes"]),
|
|
516
516
|
cron_schedule=freshness_policy_config.get("cron_schedule"),
|
|
517
517
|
cron_schedule_timezone=freshness_policy_config.get("cron_schedule_timezone"),
|
dagster_sling/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.27.1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dagster-sling
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.1
|
|
4
4
|
Summary: Package for performing ETL/ELT tasks with Sling in Dagster.
|
|
5
5
|
Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-sling
|
|
6
6
|
Author: Dagster Labs
|
|
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
14
14
|
Classifier: Operating System :: OS Independent
|
|
15
15
|
Requires-Python: >=3.9,<3.13
|
|
16
16
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: dagster==1.
|
|
17
|
+
Requires-Dist: dagster==1.11.1
|
|
18
18
|
Requires-Dist: sling>=1.1.5
|
|
19
19
|
Requires-Dist: sling-mac-arm64; platform_system == "Darwin" and platform_machine == "arm64"
|
|
20
20
|
Provides-Extra: test
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
dagster_sling/__init__.py,sha256=bMx84ssIRAWK3TrxK1CMrDiOAgq5ynJvcJX-EKXKjvM,842
|
|
2
|
-
dagster_sling/asset_decorator.py,sha256=
|
|
2
|
+
dagster_sling/asset_decorator.py,sha256=W86dh-20oHJ4JC9X4nEdrEDH0LAaeTBublUb1qh_zDU,6385
|
|
3
3
|
dagster_sling/asset_defs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
dagster_sling/dagster_sling_translator.py,sha256=
|
|
4
|
+
dagster_sling/dagster_sling_translator.py,sha256=4HRgqTp5PMxO-73jEvB1oMbguYGfhSlNYVogCtHMWGA,23995
|
|
5
5
|
dagster_sling/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
|
6
6
|
dagster_sling/resources.py,sha256=JKfrNgvmWmrxKsecR5SK_oxe6z7EqpdfS-6FpDiwyzk,25975
|
|
7
7
|
dagster_sling/sling_event_iterator.py,sha256=zLlcYAO-ZbTw-K0lbaIMDuzQPmhNSRrIMcNRvvWkkNY,8460
|
|
8
8
|
dagster_sling/sling_replication.py,sha256=24Fwuokmc2l_8HBStoTMvZSj77Qpt8ZcKUSAJNq34_M,1113
|
|
9
|
-
dagster_sling/version.py,sha256=
|
|
9
|
+
dagster_sling/version.py,sha256=lnka9HWRxSmlQAffgSpaSitns-Djhy2OArtj9IVwxrY,23
|
|
10
10
|
dagster_sling/components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
dagster_sling/components/sling_replication_collection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
dagster_sling/components/sling_replication_collection/component.py,sha256=
|
|
12
|
+
dagster_sling/components/sling_replication_collection/component.py,sha256=loPqICKK1-WEi_YmRgRarFxqE53-bLPqCFoKUakMjlI,9208
|
|
13
13
|
dagster_sling/components/sling_replication_collection/scaffolder.py,sha256=b0L4DtJifCg4FGEQ9E3O9N93WyiGSBlJikSbJOLsq1c,608
|
|
14
|
-
dagster_sling-0.
|
|
15
|
-
dagster_sling-0.
|
|
16
|
-
dagster_sling-0.
|
|
17
|
-
dagster_sling-0.
|
|
18
|
-
dagster_sling-0.
|
|
19
|
-
dagster_sling-0.
|
|
14
|
+
dagster_sling-0.27.1.dist-info/licenses/LICENSE,sha256=4lsMW-RCvfVD4_F57wrmpe3vX1xwUk_OAKKmV_XT7Z0,11348
|
|
15
|
+
dagster_sling-0.27.1.dist-info/METADATA,sha256=Yc1Z49XVL-Tlgnc8KNrKApgtwGHrbhy561zldPZ0Ysc,1131
|
|
16
|
+
dagster_sling-0.27.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
dagster_sling-0.27.1.dist-info/entry_points.txt,sha256=X75y2oDwNMmfILdNMk3CNOsskBN-RQnDoFV9D3PgVvc,64
|
|
18
|
+
dagster_sling-0.27.1.dist-info/top_level.txt,sha256=eoJKEGsD6fqIEmF6xaF8tj5Kq9a7riWyRHbZn6oHTk8,14
|
|
19
|
+
dagster_sling-0.27.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|