-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add --fail-fast argument for dbt run and dbt test #2224
Conversation
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Standard.
|
The cla-bot has been summoned, and re-checked this pull request! |
Hmmm... it looks like the CLA bot is mad about those first two commits in this PR. If you're able to rebase this PR and force-push, i think that issue should go away |
@drewbanin I've "amend" the first commit but seems to pushed old commits also after rebase. Maybe I should switch to new branch 😢 ? |
Here's what I do for that kind of problem:
You can also use the |
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.
This looks good! Can you please rebase your branch on top of dev/octavius-catto
? I merged the latest dev/barbara-gittings
changes into it, and I think it will make this diff a bit easier for me to read.
19a4882
to
6f33e6c
Compare
@beckjake Ok. I've cleanup the dups commits, squash all mine and rebase. Now It looks pretty neat. Enjoy 🚀 |
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.
This is shaping up to be a great PR!
I'm currently looking for suggestions how to (unit/integration) test the linker, graph parts and of course the tests severity levels. 🍺
Unfortunately, cancellation is always a high-risk, hard-to-test change. The postgres RPC tests should exercise a decent chunk of this code's existing behavior, in particular the stuff around KeyboardInterrupt
handling. So if those all pass I'll feel pretty good about us not having regressions!
One path for a kind of hacky integration test I can think of:
- In setup, create a new audit table in the schema that has a
model_name
column or something - Create a pre-hook that inserts the current model's name into the audit table
- Create a few models that all should fail at runtime (maybe something like
select id from {{ this.schema }}.table_that_does_not_exist
?) - Run them with something like
self.run_dbt(['run', '--threads', '1'])
. You will need to wrap the call in awith self.assertRaises(FailFastError):
... I think. - assert that there is only one row in the audit table
@@ -153,6 +155,7 @@ def mark_done(self, node_id): | |||
self.graph.remove_node(node_id) | |||
self._find_new_additions() | |||
self.inner.task_done() | |||
self.some_task_done.notify_all() |
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.
Do we need to change the context manager here to use with self.some_task_done
instead of with self.lock
? I assume it's equivalent since some_task_done
just owns the lock, but that's what queue.Queue
does.
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.
That's a great advise 🥇 . I was thinking that it was at least safe and working. I know it should be more consistent with self.lock
. I'll be working about it 😉. Thanks a lot for suggestion.
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.
Ok. You're right that it's same to use self.lock
as the Condition is actually based upon it. I've changed that to be more confident with other GraphQueue methods as suggested.
@@ -248,6 +264,34 @@ def _handle_result(self, result): | |||
cause = None | |||
self._mark_dependent_errors(node.unique_id, result, cause) | |||
|
|||
def _cancel_connections(self, pool): |
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.
This is a good idea, we should have split this out a long time ago!
You don't need to do this in this PR unless you're feeling ambitious, but a note for us: Once this merges, we should add the |
I was thinking about the RPC part but currently I'm not comfortable with at least running an RPC server/client (only a few moments with dbt Cloud editor) 😢 |
No problem at all! That's on me, I have been putting off an argument unification issue/PR for a long time and fixing it up every time we add a new flag is just the price I have to pay for that 😄. |
core/dbt/exceptions.py
Outdated
@@ -281,6 +281,17 @@ def __init__(self, message, project=None, result_type='invalid_project'): | |||
self.result_type = result_type | |||
|
|||
|
|||
class FailFastException(Exception): |
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.
@beckjake What about this part? I'm not feeling 100% ok with all this logic about Exception/Errors
and I was working about something similar to the other ones but without deep understanding what should be here.
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.
Hmm, that's an interesting question. Maybe derive from RuntimeException
and skip __init__
/__str__
? It would be nice to attach the failed node to the exception, if we can!
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.
So when raising it, something like this (if it works - I have not tested literally anything about it!):
raise FailFastException(result.error, node=getattr(result, 'node', None))
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.
Ok. Thanks
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.
Done 😉
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Rafał Jankowski.
|
I've added such integration test. |
That's totally correct, great point. For the tests, it's almost like the |
resolves #1649
Description
Optional flag
-x
or--fail-fast
which enforce adbt run
to end up on first error (or test failure duringdbt test
). It's really beneficial during long-time runs and development (Continuous Integration pipelines will be grateful).I'm currently looking for suggestions how to (unit/integration) test the linker, graph parts and of course the tests severity levels. 🍺
Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section.