Skip to content

Commit

Permalink
Fix rebase conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
LennartKloppenburg committed Nov 17, 2023
1 parent 4532db2 commit 3c89c0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions cosmos/dbt/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import itertools
import json
import os
import shutil
import tempfile
from dataclasses import dataclass, field
from pathlib import Path
Expand Down Expand Up @@ -185,7 +186,7 @@ def load(

def run_dbt_ls(self, project_path: Path, tmp_dir: Path, env_vars: dict[str, str]) -> dict[str, DbtNode]:
"""Runs dbt ls command and returns the parsed nodes."""
ls_command = [dbt_cmd, "ls", "--output", "json"]
ls_command = [self.dbt_cmd, "ls", "--output", "json"]

if self.render_config.exclude:
ls_command.extend(["--exclude", *self.render_config.exclude])
Expand Down Expand Up @@ -229,8 +230,8 @@ def load_via_dbt_ls(self) -> None:
if not self.profile_config:
raise CosmosLoadDbtException("Unable to load project via dbt ls without a profile config.")

if not self.profile_config:
raise CosmosLoadDbtException("Unable to load project via dbt ls without a profile config.")
if not shutil.which(self.dbt_cmd):
raise CosmosLoadDbtException(f"Unable to find the dbt executable: {self.dbt_cmd}")

with tempfile.TemporaryDirectory() as tmpdir:
logger.info(
Expand Down
7 changes: 4 additions & 3 deletions tests/dbt/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from cosmos.config import ExecutionConfig, ProfileConfig, ProjectConfig, RenderConfig
from cosmos.config import ExecutionConfig, ProfileConfig, ProjectConfig, RenderConfig, CosmosConfigException
from cosmos.constants import DbtResourceType, ExecutionMode
from cosmos.dbt.graph import (
CosmosLoadDbtException,
Expand Down Expand Up @@ -349,6 +349,7 @@ def test_load_via_dbt_ls_with_invalid_dbt_path():
render_config = RenderConfig(dbt_project_path=DBT_PROJECTS_ROOT_DIR / DBT_PROJECT_NAME)
with patch("pathlib.Path.exists", return_value=True):
dbt_graph = DbtGraph(
dbt_cmd="/inexistent/dbt",
project=project_config,
execution_config=execution_config,
render_config=render_config,
Expand All @@ -358,10 +359,10 @@ def test_load_via_dbt_ls_with_invalid_dbt_path():
profiles_yml_filepath=Path(__file__).parent.parent / "sample/profiles.yml",
),
)
with pytest.raises(CosmosConfigException) as err_info:
with pytest.raises(CosmosLoadDbtException) as err_info:
dbt_graph.load_via_dbt_ls()

expected = "Unable to find the dbt executable, attempted: </inexistent/dbt> and <dbt>."
expected = "Unable to find the dbt executable: /inexistent/dbt"
assert err_info.value.args[0] == expected


Expand Down

0 comments on commit 3c89c0b

Please sign in to comment.