Skip to content

Commit

Permalink
Refactor on_load into prepare_if_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Jun 26, 2024
1 parent 79723bc commit 7831bab
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions python_modules/libraries/dagster-dbt/dagster_dbt/dbt_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class DbtProjectPreparer:
"""

@public
def on_load(self, project: "DbtProject") -> None:
"""Invoked in the `prepare` method of DbtProject, when DbtProject is instantiated with this preparer."""
def prepare_if_dev(self, project: "DbtProject") -> None:
"""Invoked in the `prepare_if_dev` method of DbtProject,
when DbtProject needs preparation during development."""

@public
def prepare(self, project: "DbtProject") -> None:
Expand Down Expand Up @@ -67,19 +68,19 @@ def __init__(
self._generate_cli_args = generate_cli_args or ["parse", "--quiet"]

@public
def on_load(self, project: "DbtProject"):
def prepare_if_dev(self, project: "DbtProject"):
"""Handle the preparation process during development and at run time.
The preparation process is executed if the condition are met,
i.e. if the self.using_dagster_dev or self.parse_on_load_opt_in is true.
The preparation process is executed if the condition is met,
i.e. if the self.using_dagster_dev is true.
This method returns successfully if a loadable manifest file at the expected path.
Args:
project (DbtProject):
The dbt project to be prepared.
"""
if self.using_dagster_dev() or self.parse_on_load_opt_in():
if self.using_dagster_dev():
self.prepare(project)
if not project.manifest_path.exists():
raise DagsterDbtManifestNotFoundError(
Expand Down Expand Up @@ -299,4 +300,4 @@ def prepare_if_dev(self) -> None:
)
"""
if self.preparer:
self.preparer.on_load(self)
self.preparer.prepare_if_dev(self)

0 comments on commit 7831bab

Please sign in to comment.