dagster-dbt 0.27.13__tar.gz → 0.27.15__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.
- {dagster_dbt-0.27.13/dagster_dbt.egg-info → dagster_dbt-0.27.15}/PKG-INFO +2 -2
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/asset_utils.py +1 -1
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/component.py +108 -48
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/core/dbt_event_iterator.py +15 -6
- dagster_dbt-0.27.15/dagster_dbt/version.py +1 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15/dagster_dbt.egg-info}/PKG-INFO +2 -2
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/requires.txt +1 -1
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/setup.py +1 -1
- dagster_dbt-0.27.13/dagster_dbt/version.py +0 -1
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/LICENSE +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/MANIFEST.in +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/README.md +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/asset_decorator.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/asset_specs.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cli/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cli/app.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/asset_defs.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/cli.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/ops.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/resources.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/types.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud/utils.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/asset_decorator.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/cli_invocation.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/client.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/resources.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/run_handler.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/sensor_builder.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/types.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/compat.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/components/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/scaffolder.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/core/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/core/dbt_cli_event.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/core/dbt_cli_invocation.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/core/resource.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/core/utils.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/dagster_dbt_translator.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/dbt_core_version.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/dbt_manifest.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/dbt_manifest_asset_selection.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/dbt_project.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/dbt_version.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/errors.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/freshness_builder.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/__init__.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/pyproject.toml.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/__init__.py.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/assets.py.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/definitions.py.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/project.py.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/schedules.py.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/setup.py.jinja +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/metadata_set.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/py.typed +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/utils.py +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/SOURCES.txt +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/dependency_links.txt +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/entry_points.txt +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/not-zip-safe +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/top_level.txt +0 -0
- {dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dagster-dbt
|
|
3
|
-
Version: 0.27.
|
|
3
|
+
Version: 0.27.15
|
|
4
4
|
Summary: A Dagster integration for dbt
|
|
5
5
|
Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-dbt
|
|
6
6
|
Author: Dagster Labs
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Requires-Python: >=3.9,<3.14
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: dagster==1.11.
|
|
18
|
+
Requires-Dist: dagster==1.11.15
|
|
19
19
|
Requires-Dist: dbt-core<1.11,>=1.7
|
|
20
20
|
Requires-Dist: Jinja2
|
|
21
21
|
Requires-Dist: networkx
|
|
@@ -813,7 +813,7 @@ def build_dbt_specs(
|
|
|
813
813
|
|
|
814
814
|
# add check specs associated with the asset
|
|
815
815
|
for child_unique_id in child_map.get(unique_id, []):
|
|
816
|
-
if not child_unique_id.startswith("test"):
|
|
816
|
+
if child_unique_id not in selected_unique_ids or not child_unique_id.startswith("test"):
|
|
817
817
|
continue
|
|
818
818
|
check_spec = translator.get_asset_check_spec(
|
|
819
819
|
asset_spec=spec,
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
import json
|
|
3
|
+
import shutil
|
|
3
4
|
from collections.abc import Iterator, Mapping
|
|
5
|
+
from contextlib import contextmanager
|
|
6
|
+
from contextvars import ContextVar
|
|
4
7
|
from dataclasses import dataclass, field
|
|
5
8
|
from functools import cached_property
|
|
6
9
|
from pathlib import Path
|
|
7
10
|
from typing import Annotated, Any, Literal, Optional, Union
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
import dagster as dg
|
|
10
13
|
from dagster._annotations import public
|
|
11
|
-
from dagster._core.definitions.asset_key import AssetKey
|
|
12
|
-
from dagster._core.definitions.definitions_class import Definitions
|
|
13
|
-
from dagster._core.execution.context.asset_execution_context import AssetExecutionContext
|
|
14
14
|
from dagster._utils.cached_method import cached_method
|
|
15
|
-
from dagster.components.component.
|
|
15
|
+
from dagster.components.component.state_backed_component import StateBackedComponent
|
|
16
16
|
from dagster.components.core.component_tree import ComponentTree
|
|
17
|
-
from dagster.components.core.context import ComponentLoadContext
|
|
18
17
|
from dagster.components.resolved.core_models import OpSpec, ResolutionContext
|
|
19
18
|
from dagster.components.resolved.model import Resolver
|
|
20
19
|
from dagster.components.scaffold.scaffold import scaffold_with
|
|
21
|
-
from dagster.components.utils.
|
|
20
|
+
from dagster.components.utils.defs_state import DefsStateConfig
|
|
21
|
+
from dagster.components.utils.translation import (
|
|
22
|
+
ComponentTranslator,
|
|
23
|
+
TranslationFn,
|
|
24
|
+
TranslationFnResolver,
|
|
25
|
+
create_component_translator_cls,
|
|
26
|
+
)
|
|
22
27
|
from dagster_shared import check
|
|
28
|
+
from dagster_shared.serdes.objects.models.defs_state_info import DefsStateManagementType
|
|
23
29
|
from typing_extensions import TypeAlias
|
|
24
30
|
|
|
25
31
|
from dagster_dbt.asset_decorator import dbt_assets
|
|
@@ -38,14 +44,14 @@ from dagster_dbt.utils import ASSET_RESOURCE_TYPES
|
|
|
38
44
|
|
|
39
45
|
|
|
40
46
|
@dataclass(frozen=True)
|
|
41
|
-
class
|
|
47
|
+
class DagsterDbtComponentTranslatorSettings(DagsterDbtTranslatorSettings):
|
|
42
48
|
"""Subclass of DagsterDbtTranslatorSettings that enables code references by default."""
|
|
43
49
|
|
|
44
50
|
enable_code_references: bool = True
|
|
45
51
|
|
|
46
52
|
|
|
47
53
|
@dataclass
|
|
48
|
-
class DbtProjectArgs(Resolvable):
|
|
54
|
+
class DbtProjectArgs(dg.Resolvable):
|
|
49
55
|
"""Aligns with DbtProject.__new__."""
|
|
50
56
|
|
|
51
57
|
project_dir: str
|
|
@@ -84,11 +90,22 @@ def resolve_dbt_project(context: ResolutionContext, model) -> DbtProject:
|
|
|
84
90
|
|
|
85
91
|
DbtMetadataAddons: TypeAlias = Literal["column_metadata", "row_count"]
|
|
86
92
|
|
|
93
|
+
_resolution_context: ContextVar[ResolutionContext] = ContextVar("resolution_context")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@contextmanager
|
|
97
|
+
def _set_resolution_context(context: ResolutionContext):
|
|
98
|
+
token = _resolution_context.set(context)
|
|
99
|
+
try:
|
|
100
|
+
yield
|
|
101
|
+
finally:
|
|
102
|
+
_resolution_context.reset(token)
|
|
103
|
+
|
|
87
104
|
|
|
88
105
|
@public
|
|
89
106
|
@scaffold_with(DbtProjectComponentScaffolder)
|
|
90
107
|
@dataclass
|
|
91
|
-
class DbtProjectComponent(
|
|
108
|
+
class DbtProjectComponent(StateBackedComponent, dg.Resolvable):
|
|
92
109
|
"""Expose a DBT project to Dagster as a set of assets.
|
|
93
110
|
|
|
94
111
|
This component assumes that you have already set up a dbt project, for example, the dbt `Jaffle shop <https://github.com/dbt-labs/jaffle-shop>`_. Run `git clone --depth=1 https://github.com/dbt-labs/jaffle-shop.git jaffle_shop && rm -rf jaffle_shop/.git` to copy that project
|
|
@@ -125,8 +142,8 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
125
142
|
"--full_refresh",
|
|
126
143
|
{
|
|
127
144
|
"--vars": {
|
|
128
|
-
"start_date": "{{
|
|
129
|
-
"end_date": "{{
|
|
145
|
+
"start_date": "{{ partition_range_start }}",
|
|
146
|
+
"end_date": "{{ partition_range_end }}",
|
|
130
147
|
},
|
|
131
148
|
},
|
|
132
149
|
],
|
|
@@ -175,7 +192,7 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
175
192
|
TranslationFnResolver(template_vars_for_translation_fn=lambda data: {"node": data}),
|
|
176
193
|
] = None
|
|
177
194
|
translation_settings: Annotated[
|
|
178
|
-
Optional[
|
|
195
|
+
Optional[DagsterDbtComponentTranslatorSettings],
|
|
179
196
|
Resolver.default(
|
|
180
197
|
description="Allows enabling or disabling various features for translating dbt models in to Dagster assets.",
|
|
181
198
|
examples=[
|
|
@@ -184,7 +201,7 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
184
201
|
},
|
|
185
202
|
],
|
|
186
203
|
),
|
|
187
|
-
] =
|
|
204
|
+
] = field(default_factory=lambda: DagsterDbtComponentTranslatorSettings())
|
|
188
205
|
prepare_if_dev: Annotated[
|
|
189
206
|
bool,
|
|
190
207
|
Resolver.default(
|
|
@@ -192,12 +209,35 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
192
209
|
),
|
|
193
210
|
] = True
|
|
194
211
|
|
|
212
|
+
@property
|
|
213
|
+
def defs_state_config(self) -> DefsStateConfig:
|
|
214
|
+
return DefsStateConfig(
|
|
215
|
+
key=f"{self.__class__.__name__}[{self.project.name}]",
|
|
216
|
+
type=DefsStateManagementType.LOCAL_FILESYSTEM,
|
|
217
|
+
refresh_if_dev=self.prepare_if_dev,
|
|
218
|
+
)
|
|
219
|
+
|
|
195
220
|
@cached_property
|
|
196
|
-
def translator(self):
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
221
|
+
def translator(self) -> "DagsterDbtTranslator":
|
|
222
|
+
return DbtProjectComponentTranslator(self, self.translation_settings)
|
|
223
|
+
|
|
224
|
+
@cached_property
|
|
225
|
+
def _base_translator(self) -> "DagsterDbtTranslator":
|
|
226
|
+
return DagsterDbtTranslator(self.translation_settings)
|
|
227
|
+
|
|
228
|
+
def get_asset_spec(
|
|
229
|
+
self, manifest: Mapping[str, Any], unique_id: str, project: Optional[DbtProject]
|
|
230
|
+
) -> dg.AssetSpec:
|
|
231
|
+
return self._base_translator.get_asset_spec(manifest, unique_id, project)
|
|
232
|
+
|
|
233
|
+
def get_asset_check_spec(
|
|
234
|
+
self,
|
|
235
|
+
asset_spec: dg.AssetSpec,
|
|
236
|
+
manifest: Mapping[str, Any],
|
|
237
|
+
unique_id: str,
|
|
238
|
+
project: Optional["DbtProject"],
|
|
239
|
+
) -> Optional[dg.AssetCheckSpec]:
|
|
240
|
+
return self._base_translator.get_asset_check_spec(asset_spec, manifest, unique_id, project)
|
|
201
241
|
|
|
202
242
|
@cached_property
|
|
203
243
|
def cli_resource(self):
|
|
@@ -213,9 +253,19 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
213
253
|
exclude=exclude,
|
|
214
254
|
)
|
|
215
255
|
|
|
216
|
-
def
|
|
217
|
-
|
|
218
|
-
|
|
256
|
+
def write_state_to_path(self, state_path: Path) -> None:
|
|
257
|
+
# compile the manifest
|
|
258
|
+
self.project.preparer.prepare(self.project)
|
|
259
|
+
# move the manifest to the correct path
|
|
260
|
+
shutil.copyfile(self.project.manifest_path, state_path)
|
|
261
|
+
|
|
262
|
+
def build_defs_from_state(
|
|
263
|
+
self, context: dg.ComponentLoadContext, state_path: Optional[Path]
|
|
264
|
+
) -> dg.Definitions:
|
|
265
|
+
if state_path is not None:
|
|
266
|
+
shutil.copyfile(state_path, self.project.manifest_path)
|
|
267
|
+
|
|
268
|
+
res_ctx = context.resolution_context
|
|
219
269
|
|
|
220
270
|
@dbt_assets(
|
|
221
271
|
manifest=self.project.manifest_path,
|
|
@@ -227,13 +277,13 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
227
277
|
exclude=self.exclude,
|
|
228
278
|
backfill_policy=self.op.backfill_policy if self.op else None,
|
|
229
279
|
)
|
|
230
|
-
def _fn(context: AssetExecutionContext):
|
|
231
|
-
|
|
280
|
+
def _fn(context: dg.AssetExecutionContext):
|
|
281
|
+
with _set_resolution_context(res_ctx):
|
|
282
|
+
yield from self.execute(context=context, dbt=self.cli_resource)
|
|
232
283
|
|
|
233
|
-
|
|
234
|
-
return defs
|
|
284
|
+
return dg.Definitions(assets=[_fn])
|
|
235
285
|
|
|
236
|
-
def get_cli_args(self, context: AssetExecutionContext) -> list[str]:
|
|
286
|
+
def get_cli_args(self, context: dg.AssetExecutionContext) -> list[str]:
|
|
237
287
|
# create a resolution scope that includes the partition key and range, if available
|
|
238
288
|
partition_key = context.partition_key if context.has_partition_key else None
|
|
239
289
|
partition_key_range = (
|
|
@@ -244,15 +294,15 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
244
294
|
except Exception:
|
|
245
295
|
partition_time_window = None
|
|
246
296
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
self.cli_args, as_type=list[str]
|
|
297
|
+
# resolve the cli args with additional partition-related scope
|
|
298
|
+
resolved_args = (
|
|
299
|
+
_resolution_context.get()
|
|
300
|
+
.with_scope(
|
|
301
|
+
partition_key=partition_key,
|
|
302
|
+
partition_key_range=partition_key_range,
|
|
303
|
+
partition_time_window=partition_time_window,
|
|
304
|
+
)
|
|
305
|
+
.resolve_value(self.cli_args, as_type=list[str])
|
|
256
306
|
)
|
|
257
307
|
|
|
258
308
|
def _normalize_arg(arg: Union[str, dict[str, Any]]) -> list[str]:
|
|
@@ -277,7 +327,7 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
277
327
|
return normalized_args
|
|
278
328
|
|
|
279
329
|
def _get_dbt_event_iterator(
|
|
280
|
-
self, context: AssetExecutionContext, dbt: DbtCliResource
|
|
330
|
+
self, context: dg.AssetExecutionContext, dbt: DbtCliResource
|
|
281
331
|
) -> Iterator:
|
|
282
332
|
iterator = dbt.cli(self.get_cli_args(context), context=context).stream()
|
|
283
333
|
if "column_metadata" in self.include_metadata:
|
|
@@ -286,7 +336,7 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
286
336
|
iterator = iterator.fetch_row_counts()
|
|
287
337
|
return iterator
|
|
288
338
|
|
|
289
|
-
def execute(self, context: AssetExecutionContext, dbt: DbtCliResource) -> Iterator:
|
|
339
|
+
def execute(self, context: dg.AssetExecutionContext, dbt: DbtCliResource) -> Iterator:
|
|
290
340
|
yield from self._get_dbt_event_iterator(context, dbt)
|
|
291
341
|
|
|
292
342
|
@cached_property
|
|
@@ -298,7 +348,7 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
298
348
|
return validate_translator(self.translator)
|
|
299
349
|
|
|
300
350
|
@cached_method
|
|
301
|
-
def asset_key_for_model(self, model_name: str) -> AssetKey:
|
|
351
|
+
def asset_key_for_model(self, model_name: str) -> dg.AssetKey:
|
|
302
352
|
dagster_dbt_translator = self._validated_translator
|
|
303
353
|
manifest = self._validated_manifest
|
|
304
354
|
|
|
@@ -318,17 +368,27 @@ class DbtProjectComponent(Component, Resolvable):
|
|
|
318
368
|
).key
|
|
319
369
|
|
|
320
370
|
|
|
321
|
-
class
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
371
|
+
class DbtProjectComponentTranslator(
|
|
372
|
+
create_component_translator_cls(DbtProjectComponent, DagsterDbtTranslator),
|
|
373
|
+
ComponentTranslator[DbtProjectComponent],
|
|
374
|
+
):
|
|
375
|
+
def __init__(
|
|
376
|
+
self,
|
|
377
|
+
component: DbtProjectComponent,
|
|
378
|
+
settings: Optional[DagsterDbtComponentTranslatorSettings],
|
|
379
|
+
):
|
|
380
|
+
self._component = component
|
|
326
381
|
super().__init__(settings)
|
|
327
382
|
|
|
328
|
-
def get_asset_spec(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
383
|
+
def get_asset_spec(
|
|
384
|
+
self, manifest: Mapping[str, Any], unique_id: str, project: Optional[DbtProject]
|
|
385
|
+
) -> dg.AssetSpec:
|
|
386
|
+
base_spec = super().get_asset_spec(manifest, unique_id, project)
|
|
387
|
+
if self.component.translation is None:
|
|
388
|
+
return base_spec
|
|
389
|
+
else:
|
|
390
|
+
dbt_props = get_node(manifest, unique_id)
|
|
391
|
+
return self.component.translation(base_spec, dbt_props)
|
|
332
392
|
|
|
333
393
|
|
|
334
394
|
def get_projects_from_dbt_component(components: Path) -> list[DbtProject]:
|
|
@@ -15,6 +15,7 @@ from dagster._core.definitions.asset_checks.asset_check_evaluation import AssetC
|
|
|
15
15
|
from dagster._core.definitions.metadata import TableMetadataSet, TextMetadataValue
|
|
16
16
|
from dagster._core.errors import DagsterInvalidPropertyError
|
|
17
17
|
from dagster._core.utils import exhaust_iterator_and_yield_results_with_exception, imap
|
|
18
|
+
from dagster._utils import pushd
|
|
18
19
|
from typing_extensions import TypeVar
|
|
19
20
|
|
|
20
21
|
from dagster_dbt.asset_utils import default_metadata_from_dbt_resource_props
|
|
@@ -31,6 +32,7 @@ DbtDagsterEventType = Union[
|
|
|
31
32
|
Output, AssetMaterialization, AssetCheckResult, AssetObservation, AssetCheckEvaluation
|
|
32
33
|
]
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
# We define DbtEventIterator as a generic type for the sake of type hinting.
|
|
35
37
|
# This is so that users who inspect the type of the return value of `DbtCliInvocation.stream()`
|
|
36
38
|
# will be able to see the inner type of the iterator, rather than just `DbtEventIterator`.
|
|
@@ -63,7 +65,10 @@ def _fetch_column_metadata(
|
|
|
63
65
|
|
|
64
66
|
dbt_resource_props = _get_dbt_resource_props_from_event(invocation, event)
|
|
65
67
|
|
|
66
|
-
with
|
|
68
|
+
with (
|
|
69
|
+
pushd(str(invocation.project_dir)),
|
|
70
|
+
adapter.connection_named(f"column_metadata_{dbt_resource_props['unique_id']}"),
|
|
71
|
+
):
|
|
67
72
|
try:
|
|
68
73
|
cols = invocation._get_columns_from_dbt_resource_props( # noqa: SLF001
|
|
69
74
|
adapter=adapter, dbt_resource_props=dbt_resource_props
|
|
@@ -165,7 +170,10 @@ def _fetch_row_count_metadata(
|
|
|
165
170
|
relation_name = dbt_resource_props["relation_name"]
|
|
166
171
|
|
|
167
172
|
try:
|
|
168
|
-
with
|
|
173
|
+
with (
|
|
174
|
+
pushd(str(invocation.project_dir)),
|
|
175
|
+
adapter.connection_named(f"row_count_{unique_id}"),
|
|
176
|
+
):
|
|
169
177
|
query_result = adapter.execute(
|
|
170
178
|
f"""
|
|
171
179
|
SELECT
|
|
@@ -267,11 +275,12 @@ class DbtEventIterator(Iterator[T]):
|
|
|
267
275
|
"""
|
|
268
276
|
|
|
269
277
|
def _map_fn(event: DbtDagsterEventType) -> DbtDagsterEventType:
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
278
|
+
with pushd(str(self._dbt_cli_invocation.project_dir)):
|
|
279
|
+
result = fn(self._dbt_cli_invocation, event)
|
|
280
|
+
if result is None:
|
|
281
|
+
return event
|
|
273
282
|
|
|
274
|
-
|
|
283
|
+
return event.with_metadata({**event.metadata, **result})
|
|
275
284
|
|
|
276
285
|
# If the adapter is DuckDB, we need to wait for the dbt CLI process to complete
|
|
277
286
|
# so that the DuckDB lock is released. This is because DuckDB does not allow for
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.27.15"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dagster-dbt
|
|
3
|
-
Version: 0.27.
|
|
3
|
+
Version: 0.27.15
|
|
4
4
|
Summary: A Dagster integration for dbt
|
|
5
5
|
Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-dbt
|
|
6
6
|
Author: Dagster Labs
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Requires-Python: >=3.9,<3.14
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: dagster==1.11.
|
|
18
|
+
Requires-Dist: dagster==1.11.15
|
|
19
19
|
Requires-Dist: dbt-core<1.11,>=1.7
|
|
20
20
|
Requires-Dist: Jinja2
|
|
21
21
|
Requires-Dist: networkx
|
|
@@ -40,7 +40,7 @@ setup(
|
|
|
40
40
|
include_package_data=True,
|
|
41
41
|
python_requires=">=3.9,<3.14",
|
|
42
42
|
install_requires=[
|
|
43
|
-
"dagster==1.11.
|
|
43
|
+
"dagster==1.11.15",
|
|
44
44
|
# Follow the version support constraints for dbt Core: https://docs.getdbt.com/docs/dbt-versions/core
|
|
45
45
|
f"dbt-core>=1.7,<{DBT_CORE_VERSION_UPPER_BOUND}",
|
|
46
46
|
"Jinja2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.27.13"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/scaffolder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dagster_dbt-0.27.13 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/definitions.py.jinja
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|