|
2 | 2 | import logging
|
3 | 3 | import os
|
4 | 4 | import sys
|
5 |
| -import tempfile |
6 | 5 | from pathlib import Path
|
7 | 6 |
|
8 | 7 | from dbt.cli.main import dbtRunner as DbtCliRunner
|
9 | 8 | from dbt.cli.main import dbtRunnerResult
|
10 | 9 | from dbt.contracts.graph.manifest import Manifest
|
11 |
| -from dbt.contracts.results import RunResult |
12 | 10 | from dbt.exceptions import DbtRuntimeError
|
13 | 11 |
|
14 | 12 | from opendbt.dbt import patch_dbt
|
@@ -53,16 +51,14 @@ def run(args: list) -> dbtRunnerResult:
|
53 | 51 | return result
|
54 | 52 |
|
55 | 53 | # print query for user to run and see the failing rows
|
56 |
| - rer: RunResult |
57 |
| - |
58 | 54 | _exception = result.exception if result.exception else None
|
59 | 55 | if (_exception is None and hasattr(result.result, 'results') and result.result.results and
|
60 | 56 | len(result.result.results) > 0 and result.result.results[0].message
|
61 | 57 | ):
|
62 | 58 | _exception = DbtRuntimeError(result.result.results[0].message)
|
63 | 59 |
|
64 | 60 | if _exception is None:
|
65 |
| - DbtRuntimeError(f"DBT execution failed!") |
| 61 | + raise DbtRuntimeError(f"DBT execution failed!") |
66 | 62 | if _exception:
|
67 | 63 | raise _exception
|
68 | 64 | else:
|
@@ -95,18 +91,15 @@ def run(self, command: str = "build", target: str = None, args: list = None, use
|
95 | 91 | if write_json:
|
96 | 92 | run_args.remove("--no-write-json")
|
97 | 93 |
|
98 |
| - if False: |
| 94 | + if use_subprocess: |
99 | 95 | shell = False
|
100 | 96 | self.log.info("Working dir is %s" % os.getcwd())
|
101 | 97 | self.log.info("Running command (shell=%s) `%s`" % (shell, " ".join(command)))
|
102 | 98 | Utils.runcommand(command=['opendbt'] + run_args)
|
103 | 99 | return None
|
104 | 100 | 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) |
110 | 103 |
|
111 | 104 | def manifest(self, partial_parse=True, no_write_manifest=True) -> Manifest:
|
112 | 105 | args = []
|
|
0 commit comments