Skip to content

Commit

Permalink
fix docs and path for ls file (#773) (#788)
Browse files Browse the repository at this point in the history
Fix docs and support str argument for `dbt_ls_file`

Closes: #773 

Co-authored-by: Alex Seeholzer <[email protected]>
  • Loading branch information
Flinz and Alex Seeholzer authored Jan 9, 2024
1 parent e772f78 commit 955aa1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cosmos/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class RenderConfig:
:param node_converters: a dictionary mapping a ``DbtResourceType`` into a callable. Users can control how to render dbt nodes in Airflow. Only supported when using ``load_method=LoadMode.DBT_MANIFEST`` or ``LoadMode.DBT_LS``.
:param dbt_executable_path: The path to the dbt executable for dag generation. Defaults to dbt if available on the path.
:param env_vars: (Deprecated since Cosmos 1.3 use ProjectConfig.env_vars) A dictionary of environment variables for rendering. Only supported when using ``LoadMode.DBT_LS``.
:param dbt_project_path Configures the DBT project location accessible on the airflow controller for DAG rendering. Mutually Exclusive with ProjectConfig.dbt_project_path. Required when using ``load_method=LoadMode.DBT_LS`` or ``load_method=LoadMode.CUSTOM``.
:param dbt_project_path: Configures the DBT project location accessible on the airflow controller for DAG rendering. Mutually Exclusive with ProjectConfig.dbt_project_path. Required when using ``load_method=LoadMode.DBT_LS`` or ``load_method=LoadMode.CUSTOM``.
:param dbt_ls_path: Configures the location of an output of ``dbt ls``. Required when using ``load_method=LoadMode.DBT_LS_FILE``.
"""

emit_datasets: bool = True
Expand All @@ -70,6 +71,8 @@ def __post_init__(self, dbt_project_path: str | Path | None) -> None:
DeprecationWarning,
)
self.project_path = Path(dbt_project_path) if dbt_project_path else None
# allows us to initiate this attribute from Path objects and str
self.dbt_ls_path = Path(self.dbt_ls_path) if self.dbt_ls_path else None

def validate_dbt_command(self, fallback_cmd: str | Path = "") -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/parsing-methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ To use this:
DbtDag(
render_config=RenderConfig(
load_method=LoadMode.DBT_MANIFEST, dbt_ls_path="/path/to/dbt_ls_file.txt"
load_method=LoadMode.DBT_LS_FILE, dbt_ls_path="/path/to/dbt_ls_file.txt"
)
# ...,
)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ def test_is_dbt_ls_file_available_is_true():
assert render_config.is_dbt_ls_file_available()


def test_is_dbt_ls_file_available_is_true_for_str_path():
render_config = RenderConfig(dbt_ls_path=str(DBT_PROJECTS_ROOT_DIR / "sample_dbt_ls.txt"))
assert render_config.is_dbt_ls_file_available()


def test_is_dbt_ls_file_available_is_false():
render_config = RenderConfig(dbt_ls_path=None)
assert not render_config.is_dbt_ls_file_available()
Expand Down

0 comments on commit 955aa1c

Please sign in to comment.