Skip to content

Commit

Permalink
Use dbt ls as the default parser when profile_config is provided (#…
Browse files Browse the repository at this point in the history
…1101)

The `load_via_custom_parser` method is not very effective 
when it comes to filtering. Currently, if the ExecutionMode 
is not Local, we always use load_via_custom_parser to parse 
the dbt project. However, I believe it's beneficial to utilize DBT LS 
whenever it's available. This PR removes the check if the 
execution mode is ExecutionMode.LOCAL before `load_via_dbt_ls`

Related: #943
  • Loading branch information
pankajastro authored Jul 19, 2024
1 parent b25d5ea commit e61f3a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cosmos/dbt/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def load(
if self.project.is_manifest_available():
self.load_from_dbt_manifest()
else:
if execution_mode == ExecutionMode.LOCAL and self.profile_config:
if self.profile_config and self.project_path:
try:
self.load_via_dbt_ls()
except FileNotFoundError:
Expand Down
6 changes: 3 additions & 3 deletions tests/dbt/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ def test_load_manifest_with_manifest(mock_load_from_dbt_manifest):
"exec_mode,method,expected_function",
[
(ExecutionMode.LOCAL, LoadMode.AUTOMATIC, "mock_load_via_dbt_ls"),
(ExecutionMode.VIRTUALENV, LoadMode.AUTOMATIC, "mock_load_via_custom_parser"),
(ExecutionMode.KUBERNETES, LoadMode.AUTOMATIC, "mock_load_via_custom_parser"),
(ExecutionMode.DOCKER, LoadMode.AUTOMATIC, "mock_load_via_custom_parser"),
(ExecutionMode.VIRTUALENV, LoadMode.AUTOMATIC, "mock_load_via_dbt_ls"),
(ExecutionMode.KUBERNETES, LoadMode.AUTOMATIC, "mock_load_via_dbt_ls"),
(ExecutionMode.DOCKER, LoadMode.AUTOMATIC, "mock_load_via_dbt_ls"),
(ExecutionMode.LOCAL, LoadMode.DBT_LS, "mock_load_via_dbt_ls"),
(ExecutionMode.LOCAL, LoadMode.CUSTOM, "mock_load_via_custom_parser"),
],
Expand Down

0 comments on commit e61f3a3

Please sign in to comment.