Skip to content

Commit

Permalink
Fixes #7785: Make fail-fast return list instead of single element
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Jun 20, 2023
1 parent 0a1c73e commit 5aee0cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
12 changes: 6 additions & 6 deletions core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,11 @@ def execute_nodes(self):
self._cancel_connections(pool)
print_run_end_messages(self.node_results, keyboard_interrupt=True)
raise
finally:
pool.close()
pool.join()

pool.close()
pool.join()

return self.node_results
return self.node_results

def _mark_dependent_errors(self, node_id, result, cause):
if self.graph is None:
Expand Down Expand Up @@ -483,7 +483,7 @@ def interpret_results(cls, results):
NodeStatus.RuntimeErr,
NodeStatus.Error,
NodeStatus.Fail,
NodeStatus.Skipped, # propogate error message causing skip
NodeStatus.Skipped, # propagate error message causing skip
)
]
return len(failures) == 0
Expand Down Expand Up @@ -567,7 +567,7 @@ def create_schema(relation: BaseRelation) -> None:
create_futures.append(fut)

for create_future in as_completed(create_futures):
# trigger/re-raise any excceptions while creating schemas
# trigger/re-raise any exceptions while creating schemas
create_future.result()

def get_result(self, results, elapsed_time, generated_at):
Expand Down
23 changes: 14 additions & 9 deletions tests/functional/fail_fast/test_fail_fast_run.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import pytest
import json
from pathlib import Path

import pytest

from dbt.contracts.results import RunResult
from dbt.contracts.results import RunExecutionResult, NodeStatus
from dbt.tests.util import run_dbt


models__one_sql = """
select 1
"""
Expand All @@ -30,15 +29,19 @@ def test_fail_fast_run(
models, # noqa: F811
):
res = run_dbt(["run", "--fail-fast", "--threads", "1"], expect_pass=False)
# a RunResult contains only one node so we can be sure only one model was run
assert type(res) == RunResult

assert isinstance(res, RunExecutionResult)
assert len(res.results) == 2
assert res.results[0].status == NodeStatus.Success
assert res.results[1].status == NodeStatus.Error

run_results_file = Path(project.project_root) / "target/run_results.json"
assert run_results_file.is_file()
with run_results_file.open() as run_results_str:
run_results = json.loads(run_results_str.read())
assert len(run_results["results"]) == 2
assert run_results["results"][0]["status"] == "success"
assert run_results["results"][1]["status"] == "error"
assert run_results["results"][0]["status"] == NodeStatus.Success
assert run_results["results"][1]["status"] == NodeStatus.Error


class TestFailFastFromConfig(FailFastBase):
Expand All @@ -57,5 +60,7 @@ def test_fail_fast_run_user_config(
models, # noqa: F811
):
res = run_dbt(["run", "--threads", "1"], expect_pass=False)
# a RunResult contains only one node so we can be sure only one model was run
assert type(res) == RunResult
assert isinstance(res, RunExecutionResult)
assert len(res.results) == 2
assert res.results[0].status == NodeStatus.Success
assert res.results[1].status == NodeStatus.Error

0 comments on commit 5aee0cc

Please sign in to comment.