diff --git a/cosmos/config.py b/cosmos/config.py index 57d5200b1..f9d47f5e2 100644 --- a/cosmos/config.py +++ b/cosmos/config.py @@ -258,7 +258,7 @@ class ExecutionConfig: execution_mode: ExecutionMode = ExecutionMode.LOCAL test_indirect_selection: TestIndirectSelection = TestIndirectSelection.EAGER - dbt_executable_path: str | Path = get_system_dbt() + dbt_executable_path: str | Path | None = None dbt_project_path: InitVar[str | Path | None] = None @@ -266,3 +266,5 @@ class ExecutionConfig: def __post_init__(self, dbt_project_path: str | Path | None) -> None: self.project_path = Path(dbt_project_path) if dbt_project_path else None + if not self.dbt_executable_path: + self.dbt_executable_path = get_system_dbt() diff --git a/tests/dbt/test_graph.py b/tests/dbt/test_graph.py index 607e56641..0ad7424c8 100644 --- a/tests/dbt/test_graph.py +++ b/tests/dbt/test_graph.py @@ -343,7 +343,8 @@ def test_load_via_dbt_ls_without_profile(mock_validate_dbt_command): assert err_info.value.args[0] == expected -def test_load_via_dbt_ls_with_invalid_dbt_path(): +@patch("cosmos.dbt.executable.shutil.which", return_value=None) +def test_load_via_dbt_ls_with_invalid_dbt_path(mock_which): project_config = ProjectConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME) execution_config = ExecutionConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME) render_config = RenderConfig(