Skip to content

Commit 9a0f36d

Browse files
authored
opendbt cli fixes (#25)
1 parent 0da7344 commit 9a0f36d

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

opendbt/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
import logging
33
import os
44
import sys
5-
import tempfile
65
from pathlib import Path
76

87
from dbt.cli.main import dbtRunner as DbtCliRunner
98
from dbt.cli.main import dbtRunnerResult
109
from dbt.contracts.graph.manifest import Manifest
11-
from dbt.contracts.results import RunResult
1210
from dbt.exceptions import DbtRuntimeError
1311

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

5553
# print query for user to run and see the failing rows
56-
rer: RunResult
57-
5854
_exception = result.exception if result.exception else None
5955
if (_exception is None and hasattr(result.result, 'results') and result.result.results and
6056
len(result.result.results) > 0 and result.result.results[0].message
6157
):
6258
_exception = DbtRuntimeError(result.result.results[0].message)
6359

6460
if _exception is None:
65-
DbtRuntimeError(f"DBT execution failed!")
61+
raise DbtRuntimeError(f"DBT execution failed!")
6662
if _exception:
6763
raise _exception
6864
else:
@@ -95,18 +91,15 @@ def run(self, command: str = "build", target: str = None, args: list = None, use
9591
if write_json:
9692
run_args.remove("--no-write-json")
9793

98-
if False:
94+
if use_subprocess:
9995
shell = False
10096
self.log.info("Working dir is %s" % os.getcwd())
10197
self.log.info("Running command (shell=%s) `%s`" % (shell, " ".join(command)))
10298
Utils.runcommand(command=['opendbt'] + run_args)
10399
return None
104100
else:
105-
with tempfile.TemporaryDirectory() as tmp_working_dir:
106-
os.chdir(tmp_working_dir)
107-
self.log.info(f"Running `dbt {' '.join(run_args)}`")
108-
self.log.info("CWD is %s" % os.getcwd())
109-
return OpenDbtCli.run(args=run_args)
101+
self.log.info(f"Running `dbt {' '.join(run_args)}`")
102+
return OpenDbtCli.run(args=run_args)
110103

111104
def manifest(self, partial_parse=True, no_write_manifest=True) -> Manifest:
112105
args = []

opendbt/dbt/v18/task/docs/generate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ def deploy_user_index_html(self):
2020

2121
def run(self):
2222
# Call the original dbt run method
23-
super().run()
23+
result = super().run()
2424
self.deploy_user_index_html()
25+
return result

0 commit comments

Comments
 (0)