Skip to content

Commit

Permalink
Fix dbt_project.py
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Jun 17, 2024
1 parent c289e9a commit db2841b
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions python_modules/libraries/dagster-dbt/dagster_dbt/dbt_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _prepare_packages(self, project: "DbtProject") -> None:

(
DbtCliResource(project_dir=project)
.cli(["deps", "--quiet"], target_path=project.target_path)
.cli(["deps", "--quiet"], target_path=project.output_path)
.wait()
)

Expand All @@ -102,7 +102,7 @@ def _prepare_manifest(self, project: "DbtProject") -> None:
DbtCliResource(project_dir=project)
.cli(
self._generate_cli_args,
target_path=project.target_path,
target_path=project.output_path,
)
.wait()
)
Expand All @@ -125,8 +125,9 @@ class DbtProject(IHaveNew):
Args:
project_dir (Union[str, Path]):
The directory of the dbt project.
target_path (Union[str, Path]):
output_path (Union[str, Path]):
The path, relative to the project directory, to output artifacts.
In a dbt project, it corresponds to the target path.
Default: "target"
target (Optional[str]):
The target from your dbt `profiles.yml` to use for execution, if it should be explicitly set.
Expand All @@ -138,8 +139,9 @@ class DbtProject(IHaveNew):
like when deploying using PEX.
state_path (Optional[Union[str, Path]]):
The path, relative to the project directory, to reference artifacts from another run.
manifest_preparer (Optional[DbtManifestPreparer]):
A object for ensuring that manifest.json is in the right state at
preparer (Optional[DbtManifestPreparer]):
A object for ensuring that the dbt project is correctly prepared for Dagster.
By default, that means ensuring that dependencies and manifest.json are in the right state at
the right times.
Default: DagsterDbtManifestPreparer
Expand Down Expand Up @@ -180,23 +182,23 @@ def get_env():
"""

project_dir: Path
target_path: Path
output_path: Path
target: Optional[str]
manifest_path: Path
packaged_project_dir: Optional[Path]
state_path: Optional[Path]
has_uninstalled_deps: bool
manifest_preparer: DbtManifestPreparer
preparer: DbtManifestPreparer

def __new__(
cls,
project_dir: Union[Path, str],
*,
target_path: Union[Path, str] = Path("target"),
output_path: Union[Path, str] = Path("target"),
target: Optional[str] = None,
packaged_project_dir: Optional[Union[Path, str]] = None,
state_path: Optional[Union[Path, str]] = None,
manifest_preparer: DbtManifestPreparer = DagsterDbtManifestPreparer(),
preparer: DbtManifestPreparer = DagsterDbtManifestPreparer(),
):
project_dir = Path(project_dir)
if not project_dir.exists():
Expand All @@ -206,7 +208,7 @@ def __new__(
if not using_dagster_dev() and packaged_project_dir and packaged_project_dir.exists():
project_dir = packaged_project_dir

manifest_path = project_dir.joinpath(target_path, "manifest.json")
manifest_path = project_dir.joinpath(output_path, "manifest.json")

dependencies_path = project_dir.joinpath("dependencies.yml")
packages_path = project_dir.joinpath("packages.yml")
Expand All @@ -230,13 +232,13 @@ def __new__(
return super().__new__(
cls,
project_dir=project_dir,
target_path=target_path,
output_path=output_path,
target=target,
manifest_path=manifest_path,
state_path=project_dir.joinpath(state_path) if state_path else None,
packaged_project_dir=packaged_project_dir,
has_uninstalled_deps=has_uninstalled_deps,
manifest_preparer=manifest_preparer,
preparer=preparer,
)

@public
Expand All @@ -248,7 +250,7 @@ def ensure_prepared(self) -> "DbtProject":
* During development, pull the dependencies and reload the manifest at run time to pick up any changes.
* When deploying, expect a manifest that was created at build time to reduce start-up time.
The preparation process is ensured by `self.manifest_preparer`.
The preparation process is ensured by `self.preparer`.
If this method returns successfully, `self.manifest_path` will point to a loadable manifest file.
Expand Down Expand Up @@ -289,6 +291,6 @@ def ensure_prepared(self) -> "DbtProject":
def my_dbt_asset():
...
"""
if self.manifest_preparer:
self.manifest_preparer.on_load(self)
if self.preparer:
self.preparer.on_load(self)
return self

0 comments on commit db2841b

Please sign in to comment.