Skip to content

Commit

Permalink
Make dbt build output real-time, implement Snowflake login_timeout in…
Browse files Browse the repository at this point in the history
… key-pair cases
  • Loading branch information
BAntonellini committed Sep 11, 2024
1 parent 1beafd0 commit cba8d10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion dbt_coves/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ def main(parser: argparse.ArgumentParser = parser, test_cli_args: List[str] = li
console.print(
"[red]The process was killed by the OS due to running out of memory.[/red]"
)
console.print(f"[red]:cross_mark:[/red] {cpe.stderr}")
if cpe.stderr:
console.print(f"[red]:cross_mark:[/red] {cpe.stderr}")

return cpe.returncode
except Exception as ex:
Expand Down
14 changes: 7 additions & 7 deletions dbt_coves/tasks/blue_green/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import snowflake.connector
from rich.console import Console
from rich.text import Text

from dbt_coves.core.exceptions import DbtCovesException
from dbt_coves.tasks.base import BaseConfiguredTask
Expand Down Expand Up @@ -139,14 +138,14 @@ def _run_command(self, command: list, env=os.environ.copy()):
command_string = " ".join(command)
console.print(f"Running [b][i]{command_string}[/i][/b]")
try:
output = subprocess.check_output(command, env=env, stderr=subprocess.PIPE)
console.print(
f"{Text.from_ansi(output.decode())}\n"
f"[green]{command_string} :heavy_check_mark:[/green]"
subprocess.run(
command,
env=env,
check=True,
)
console.print(f"[green]{command_string} :heavy_check_mark:[/green]")
except subprocess.CalledProcessError as e:
formatted = f"{Text.from_ansi(e.stderr.decode()) if e.stderr else Text.from_ansi(e.stdout.decode())}"
e.stderr = f"An error has occurred running [red]{command_string}[/red]:\n{formatted}"
console.print(f"Error running [red]{e.cmd}[/red], see stack above for details")
raise

def _get_dbt_command(self, command):
Expand Down Expand Up @@ -212,6 +211,7 @@ def _get_snowflake_credentials_from_dbt_adapter(self):
connection_dict["password"] = self.config.credentials.password
else:
connection_dict["private_key"] = self._get_snowflake_private_key()
connection_dict["login_timeout"] = 10

return connection_dict

Expand Down

0 comments on commit cba8d10

Please sign in to comment.