Fix: added re-raising of exceptions to dag.test() execution#34311
Fix: added re-raising of exceptions to dag.test() execution#34311styannik wants to merge 2 commits into
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
|
|
This implementation will bring back the behavior that #30965 attempts to fix. That is, no callbacks will be ran. |
|
Fixing the callback is out of scope in my opinion. However updating the documentation to address this missing behavior is a good add to this PR. The users can always add their own calls to the callback after checking the state dagrun = dag.test()
if dagrun.state == "failed":
# run callback |
hussein-awala
left a comment
There was a problem hiding this comment.
Why do you think we need to fail the command and stop the execution when a TI fails? Even in a real execution, we could have a success run with some failed TIs (if we change the trigger rule).
I just checked the main issue and the suggestion, but IMHO if we want to fix this, we need to somehow check the trigger rules instead of randomly fast failing the execution.
|
@hussein-awala Because that was the original behavior of Redefining the behavior of |
|
Yes. I think (and maybe @dimberman as original creator can confirm) the dags.test is not really a replacement for all the scheduling features. I believe the change as it is implemented might undermine a bit the story to be told at the upcoming Airflow Summit talk: https://airflowsummit.org/sessions/2023/to-debug-a-dag-the-airflow-local-dev-story/ so it would be great to make sure that the talk and the implementation are consistent. @dimberman - what would you say ? |
|
Will it be a better way that we check the dr.state at the end of test(), and raise exception in case it equals to DagRunState.FAILED? |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
Are you still working on it @styannik ? @dimberman - I think it waits for your input. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
@potiuk @hussein-awala @styannik apologies for being out of the loop here. Been a bit swamped on my end :). I think that raising an exception here is the wrong way to go about this. I think there should be a slightly larger conversation about what we do/return when we run One thought I've been having recently is that we should have dag.test return a dictionary of tasks -> status. So let's say we have a task that fails with an exception, maybe we could have a dictionary read {
"task_a": { "status": "success"},
"task_b": {"status": "failed", "exc_info": DivideByZeroException(...)},
"dag_status": "failed",
}This way people can run tests against their DAGs with different inputs and see what failure/acceptance scenarios have, and the tests will correctly fail as you can take the result and run assertions. WDYT? |
|
/ |
|
@dimberman That idea of generally allowing users to define their own failures sounds great to me. |
Welcome back :).
Yep. I think we should document design decisions for it and provide some best practices on what is expected of this command and how to use it. The current description https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/executor/debug.html#testing-dags-with-dag-test is rather rudimentary and does not explain what happens and what to expect I think there are two things that maybe need clarification/explanation that I saw people asked (and maybe making decisions):
|
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
Fixing the exception handling issue from #34282