dagster-dbt 0.27.14__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.14/dagster_dbt.egg-info → dagster_dbt-0.27.15}/PKG-INFO +2 -2
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/component.py +52 -16
- {dagster_dbt-0.27.14 → 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.14 → dagster_dbt-0.27.15/dagster_dbt.egg-info}/PKG-INFO +2 -2
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/requires.txt +1 -1
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/setup.py +1 -1
- dagster_dbt-0.27.14/dagster_dbt/version.py +0 -1
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/LICENSE +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/MANIFEST.in +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/README.md +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/asset_decorator.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/asset_specs.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/asset_utils.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cli/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cli/app.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/asset_defs.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/cli.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/ops.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/resources.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/types.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud/utils.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/asset_decorator.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/cli_invocation.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/client.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/resources.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/run_handler.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/sensor_builder.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/cloud_v2/types.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/compat.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/components/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/components/dbt_project/scaffolder.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/core/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/core/dbt_cli_event.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/core/dbt_cli_invocation.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/core/resource.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/core/utils.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/dagster_dbt_translator.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/dbt_core_version.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/dbt_manifest.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/dbt_manifest_asset_selection.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/dbt_project.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/dbt_version.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/errors.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/freshness_builder.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/__init__.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/pyproject.toml.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/__init__.py.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/assets.py.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/definitions.py.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/project.py.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/scaffold/schedules.py.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/include/setup.py.jinja +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/metadata_set.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/py.typed +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt/utils.py +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/SOURCES.txt +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/dependency_links.txt +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/entry_points.txt +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/not-zip-safe +0 -0
- {dagster_dbt-0.27.14 → dagster_dbt-0.27.15}/dagster_dbt.egg-info/top_level.txt +0 -0
- {dagster_dbt-0.27.14 → 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
|
|
@@ -1,6 +1,9 @@
|
|
|
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
|
|
@@ -9,10 +12,12 @@ from typing import Annotated, Any, Literal, Optional, Union
|
|
|
9
12
|
import dagster as dg
|
|
10
13
|
from dagster._annotations import public
|
|
11
14
|
from dagster._utils.cached_method import cached_method
|
|
15
|
+
from dagster.components.component.state_backed_component import StateBackedComponent
|
|
12
16
|
from dagster.components.core.component_tree import ComponentTree
|
|
13
17
|
from dagster.components.resolved.core_models import OpSpec, ResolutionContext
|
|
14
18
|
from dagster.components.resolved.model import Resolver
|
|
15
19
|
from dagster.components.scaffold.scaffold import scaffold_with
|
|
20
|
+
from dagster.components.utils.defs_state import DefsStateConfig
|
|
16
21
|
from dagster.components.utils.translation import (
|
|
17
22
|
ComponentTranslator,
|
|
18
23
|
TranslationFn,
|
|
@@ -20,6 +25,7 @@ from dagster.components.utils.translation import (
|
|
|
20
25
|
create_component_translator_cls,
|
|
21
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
|
|
@@ -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(dg.Component, dg.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
|
],
|
|
@@ -192,6 +209,14 @@ class DbtProjectComponent(dg.Component, dg.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
221
|
def translator(self) -> "DagsterDbtTranslator":
|
|
197
222
|
return DbtProjectComponentTranslator(self, self.translation_settings)
|
|
@@ -228,9 +253,19 @@ class DbtProjectComponent(dg.Component, dg.Resolvable):
|
|
|
228
253
|
exclude=exclude,
|
|
229
254
|
)
|
|
230
255
|
|
|
231
|
-
def
|
|
232
|
-
|
|
233
|
-
|
|
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
|
|
234
269
|
|
|
235
270
|
@dbt_assets(
|
|
236
271
|
manifest=self.project.manifest_path,
|
|
@@ -243,7 +278,8 @@ class DbtProjectComponent(dg.Component, dg.Resolvable):
|
|
|
243
278
|
backfill_policy=self.op.backfill_policy if self.op else None,
|
|
244
279
|
)
|
|
245
280
|
def _fn(context: dg.AssetExecutionContext):
|
|
246
|
-
|
|
281
|
+
with _set_resolution_context(res_ctx):
|
|
282
|
+
yield from self.execute(context=context, dbt=self.cli_resource)
|
|
247
283
|
|
|
248
284
|
return dg.Definitions(assets=[_fn])
|
|
249
285
|
|
|
@@ -258,15 +294,15 @@ class DbtProjectComponent(dg.Component, dg.Resolvable):
|
|
|
258
294
|
except Exception:
|
|
259
295
|
partition_time_window = None
|
|
260
296
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
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])
|
|
270
306
|
)
|
|
271
307
|
|
|
272
308
|
def _normalize_arg(arg: Union[str, dict[str, Any]]) -> list[str]:
|
|
@@ -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.14"
|
|
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
|
|
File without changes
|
{dagster_dbt-0.27.14 → 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.14 → 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
|