-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #7785: fail-fast behavior #8066
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e8018f7
Fixes #7785: fail-fast behavior
aranke 7b71ea0
Merge branch 'main' into 7785_fail_fast
aranke 4d4ba6c
add changie
aranke 86b030c
fix failing integration tests
aranke b295bf5
Merge branch 'main' into 7785_fail_fast
aranke 1813c03
status dict instead of single element
aranke 56bcfd2
Merge branch 'main' into 7785_fail_fast
aranke 60f1cc9
address pr comments
aranke 5ab8438
Merge branch 'main' into 7785_fail_fast
aranke 717bf31
add new from_node method to RunResult
aranke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Fix fail-fast behavior (including retry) | ||
time: 2023-07-10T17:25:47.912129-05:00 | ||
custom: | ||
Author: aranke | ||
Issue: "7785" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,22 +145,6 @@ def test_run_operation(self, project): | |
results = run_dbt(["retry"], expect_pass=False) | ||
assert {n.unique_id: n.status for n in results.results} == expected_statuses | ||
|
||
def test_fail_fast(self, project): | ||
result = run_dbt(["--warn-error", "build", "--fail-fast"], expect_pass=False) | ||
|
||
assert result.status == RunStatus.Error | ||
assert result.node.name == "sample_model" | ||
|
||
results = run_dbt(["retry"], expect_pass=False) | ||
|
||
assert len(results.results) == 1 | ||
assert results.results[0].status == RunStatus.Error | ||
assert results.results[0].node.name == "sample_model" | ||
|
||
result = run_dbt(["retry", "--fail-fast"], expect_pass=False) | ||
assert result.status == RunStatus.Error | ||
assert result.node.name == "sample_model" | ||
|
||
def test_removed_file(self, project): | ||
run_dbt(["build"], expect_pass=False) | ||
|
||
|
@@ -180,3 +164,57 @@ def test_removed_file_leaf_node(self, project): | |
rm_file("models", "third_model.sql") | ||
with pytest.raises(ValueError, match="Couldn't find model 'model.test.third_model'"): | ||
run_dbt(["retry"], expect_pass=False) | ||
|
||
|
||
class TestFailFast: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"sample_model.sql": models__sample_model, | ||
"second_model.sql": models__second_model, | ||
"union_model.sql": models__union_model, | ||
"final_model.sql": "select * from {{ ref('union_model') }};", | ||
} | ||
|
||
def test_fail_fast(self, project): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Love the functional test here! |
||
results = run_dbt(["--fail-fast", "build"], expect_pass=False) | ||
assert {r.node.unique_id: r.status for r in results.results} == { | ||
"model.test.sample_model": RunStatus.Error, | ||
"model.test.second_model": RunStatus.Success, | ||
"model.test.union_model": RunStatus.Skipped, | ||
"model.test.final_model": RunStatus.Skipped, | ||
} | ||
|
||
# Check that retry inherits fail-fast from upstream command (build) | ||
results = run_dbt(["retry"], expect_pass=False) | ||
assert {r.node.unique_id: r.status for r in results.results} == { | ||
"model.test.sample_model": RunStatus.Error, | ||
"model.test.union_model": RunStatus.Skipped, | ||
"model.test.final_model": RunStatus.Skipped, | ||
} | ||
|
||
fixed_sql = "select 1 as id, 1 as foo" | ||
write_file(fixed_sql, "models", "sample_model.sql") | ||
|
||
results = run_dbt(["retry"], expect_pass=False) | ||
assert {r.node.unique_id: r.status for r in results.results} == { | ||
"model.test.sample_model": RunStatus.Success, | ||
"model.test.union_model": RunStatus.Success, | ||
"model.test.final_model": RunStatus.Error, | ||
} | ||
|
||
results = run_dbt(["retry"], expect_pass=False) | ||
assert {r.node.unique_id: r.status for r in results.results} == { | ||
"model.test.final_model": RunStatus.Error, | ||
} | ||
|
||
fixed_sql = "select * from {{ ref('union_model') }}" | ||
write_file(fixed_sql, "models", "final_model.sql") | ||
|
||
results = run_dbt(["retry"]) | ||
assert {r.node.unique_id: r.status for r in results.results} == { | ||
"model.test.final_model": RunStatus.Success, | ||
} | ||
|
||
results = run_dbt(["retry"]) | ||
assert {r.node.unique_id: r.status for r in results.results} == {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why return is also moved into the
finally
block?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
is moved to thefinally
block, otherwise only the current node is returned, but information about all the other node results is lost.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
finally
blocks are executed whether an exception is raised or not