Skip to content

Commit

Permalink
opendbt cli fixes (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailsimsek authored Oct 22, 2024
1 parent 0da7344 commit 9a0f36d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 4 additions & 11 deletions opendbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
import logging
import os
import sys
import tempfile
from pathlib import Path

from dbt.cli.main import dbtRunner as DbtCliRunner
from dbt.cli.main import dbtRunnerResult
from dbt.contracts.graph.manifest import Manifest
from dbt.contracts.results import RunResult
from dbt.exceptions import DbtRuntimeError

from opendbt.dbt import patch_dbt
Expand Down Expand Up @@ -53,16 +51,14 @@ def run(args: list) -> dbtRunnerResult:
return result

# print query for user to run and see the failing rows
rer: RunResult

_exception = result.exception if result.exception else None
if (_exception is None and hasattr(result.result, 'results') and result.result.results and
len(result.result.results) > 0 and result.result.results[0].message
):
_exception = DbtRuntimeError(result.result.results[0].message)

if _exception is None:
DbtRuntimeError(f"DBT execution failed!")
raise DbtRuntimeError(f"DBT execution failed!")
if _exception:
raise _exception
else:
Expand Down Expand Up @@ -95,18 +91,15 @@ def run(self, command: str = "build", target: str = None, args: list = None, use
if write_json:
run_args.remove("--no-write-json")

if False:
if use_subprocess:
shell = False
self.log.info("Working dir is %s" % os.getcwd())
self.log.info("Running command (shell=%s) `%s`" % (shell, " ".join(command)))
Utils.runcommand(command=['opendbt'] + run_args)
return None
else:
with tempfile.TemporaryDirectory() as tmp_working_dir:
os.chdir(tmp_working_dir)
self.log.info(f"Running `dbt {' '.join(run_args)}`")
self.log.info("CWD is %s" % os.getcwd())
return OpenDbtCli.run(args=run_args)
self.log.info(f"Running `dbt {' '.join(run_args)}`")
return OpenDbtCli.run(args=run_args)

def manifest(self, partial_parse=True, no_write_manifest=True) -> Manifest:
args = []
Expand Down
3 changes: 2 additions & 1 deletion opendbt/dbt/v18/task/docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ def deploy_user_index_html(self):

def run(self):
# Call the original dbt run method
super().run()
result = super().run()
self.deploy_user_index_html()
return result

0 comments on commit 9a0f36d

Please sign in to comment.