Skip to content

Commit

Permalink
chore: raise CosmosLoadDbtException when returncode is not zero
Browse files Browse the repository at this point in the history
  • Loading branch information
cliff-lau-cloverhealth committed Sep 19, 2023
1 parent 27d1945 commit e24b825
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions cosmos/dbt/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ def load_via_dbt_ls(self) -> None:
env=env,
)
stdout, stderr = process.communicate()
returncode = process.returncode
logger.debug("dbt deps output: %s", stdout)

if stderr or "Error" in stdout:
if returncode:
details = stderr or stdout
raise CosmosLoadDbtException(f"Unable to run dbt deps command due to the error:\n{details}")

Expand All @@ -222,6 +223,7 @@ def load_via_dbt_ls(self) -> None:
)

stdout, stderr = process.communicate()
returncode = process.returncode

logger.debug("dbt output: %s", stdout)
log_filepath = log_dir / DBT_LOG_FILENAME
Expand All @@ -231,14 +233,14 @@ def load_via_dbt_ls(self) -> None:
for line in logfile:
logger.debug(line.strip())

if stderr or "Error" in stdout:
if 'Run "dbt deps" to install package dependencies' in stdout:
raise CosmosLoadDbtException(
"Unable to run dbt ls command due to missing dbt_packages. Set render_config.dbt_deps=True."
)
else:
details = stderr or stdout
raise CosmosLoadDbtException(f"Unable to run dbt ls command due to the error:\n{details}")
if 'Run "dbt deps" to install package dependencies' in stdout:
raise CosmosLoadDbtException(
"Unable to run dbt ls command due to missing dbt_packages. Set render_config.dbt_deps=True."
)

if returncode:
details = stderr or stdout
raise CosmosLoadDbtException(f"Unable to run dbt ls command due to the error:\n{details}")

nodes = {}
for line in stdout.split("\n"):
Expand Down

0 comments on commit e24b825

Please sign in to comment.