You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "mis98zb (via GitHub)" <gi...@apache.org> on 2023/04/30 00:59:30 UTC
[GitHub] [airflow] mis98zb opened a new pull request, #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
mis98zb opened a new pull request, #30965:
URL: https://github.com/apache/airflow/pull/30965
The DAG.test() code is as below:
```python
# Instead of starting a scheduler, we run the minimal loop possible to check
# for task readiness and dependency management. This is notably faster
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
for ti in schedulable_tis:
add_logger_if_needed(ti)
ti.task = tasks[ti.task_id]
_run_task(ti, session=session)
if conn_file_path or variable_file_path:
# Remove the local variables we have added to the secrets_backend_list
secrets_backend_list.pop(0)
```
When exception occurred in a task, the exception will be raised from `_run_task(ti, session=session)`.
In the loop, there is no try...except, so the function is terminated immediately.
This is the reason why DAG's on_failure_callback cannot be invoked during testing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1584018347
Don't know why the build keep failing, ToT
Seems the failed test is not related to the code change in this PR....
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1528909811
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)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/BREEZE.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#coding-style-and-best-practices).
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1209751643
##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,16 @@ def add_logger_if_needed(ti: TaskInstance):
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
- for ti in schedulable_tis:
- add_logger_if_needed(ti)
- ti.task = tasks[ti.task_id]
- _run_task(ti, session=session)
+ try:
+ for ti in schedulable_tis:
+ add_logger_if_needed(ti)
+ ti.task = tasks[ti.task_id]
+ _run_task(ti, session=session)
+ except Exception:
+ self.log.info(
+ "Task failed. DAG will continue to run until finished "
+ "and be marked as failed."
+ )
Review Comment:
```suggestion
self.log.info(
"Task failed. DAG will continue to run until finished "
"and be marked as failed.",
exc_info=True,
)
```
If we want to include the exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1209751281
##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,16 @@ def add_logger_if_needed(ti: TaskInstance):
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
- for ti in schedulable_tis:
- add_logger_if_needed(ti)
- ti.task = tasks[ti.task_id]
- _run_task(ti, session=session)
+ try:
+ for ti in schedulable_tis:
+ add_logger_if_needed(ti)
+ ti.task = tasks[ti.task_id]
+ _run_task(ti, session=session)
+ except Exception:
+ self.log.info(
+ "Task failed. DAG will continue to run until finished "
+ "and be marked as failed."
+ )
Review Comment:
Should we add the exception to the log so the user knows what happened? Or would that be unhelpful? (Not sure.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1205051311
##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,13 @@ def add_logger_if_needed(ti: TaskInstance):
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
- for ti in schedulable_tis:
- add_logger_if_needed(ti)
- ti.task = tasks[ti.task_id]
- _run_task(ti, session=session)
+ try:
+ for ti in schedulable_tis:
+ add_logger_if_needed(ti)
+ ti.task = tasks[ti.task_id]
+ _run_task(ti, session=session)
+ except Exception:
+ self.log.info("Task failed, continue looping. DAG will be marked as failed at the end of looping.")
Review Comment:
This wording is likely better than “looping”.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1209961530
##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,16 @@ def add_logger_if_needed(ti: TaskInstance):
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
- for ti in schedulable_tis:
- add_logger_if_needed(ti)
- ti.task = tasks[ti.task_id]
- _run_task(ti, session=session)
+ try:
+ for ti in schedulable_tis:
+ add_logger_if_needed(ti)
+ ti.task = tasks[ti.task_id]
+ _run_task(ti, session=session)
+ except Exception:
+ self.log.info(
+ "Task failed. DAG will continue to run until finished "
+ "and be marked as failed."
+ )
Review Comment:
I see. Thank you for the advise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1205050272
##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,13 @@ def add_logger_if_needed(ti: TaskInstance):
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
- for ti in schedulable_tis:
- add_logger_if_needed(ti)
- ti.task = tasks[ti.task_id]
- _run_task(ti, session=session)
+ try:
+ for ti in schedulable_tis:
+ add_logger_if_needed(ti)
+ ti.task = tasks[ti.task_id]
+ _run_task(ti, session=session)
+ except Exception:
+ self.log.info("Task failed, continue looping. DAG will be marked as failed at the end of looping.")
Review Comment:
```suggestion
self.log.info(
"Task %s failed. DAG will continue to run until finished "
"and be marked as failed.",
ti.key,
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #30965:
URL: https://github.com/apache/airflow/pull/30965#discussion_r1205050272
##########
airflow/models/dag.py:
##########
@@ -2698,10 +2698,13 @@ def add_logger_if_needed(ti: TaskInstance):
# than creating a BackfillJob and allows us to surface logs to the user
while dr.state == State.RUNNING:
schedulable_tis, _ = dr.update_state(session=session)
- for ti in schedulable_tis:
- add_logger_if_needed(ti)
- ti.task = tasks[ti.task_id]
- _run_task(ti, session=session)
+ try:
+ for ti in schedulable_tis:
+ add_logger_if_needed(ti)
+ ti.task = tasks[ti.task_id]
+ _run_task(ti, session=session)
+ except Exception:
+ self.log.info("Task failed, continue looping. DAG will be marked as failed at the end of looping.")
Review Comment:
```suggestion
self.log.info(
"Task failed. DAG will continue to run until finished "
"and be marked as failed."
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1584025980
Please set up pre-commit as described in the contributor’s guide.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1584228697
> Please set up pre-commit as described in the contributor’s guide.
The instructions were actually printed by pre-commit, but could be lost in see of messages - I made PR to display far more prominent https://github.com/apache/airflow/pull/31813
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1584020322
May I know how can I format code in local machine?
I tried `--config .\pyproject.toml airflow`, but it cannot get the same result in the build...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1556526196
Sorry for late. I have added the actual test for dag.test() with failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1577854014
@potiuk I have added some tests for the code change. May I know if the is enough? Thanks & Best Regards.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1584230042
Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk merged pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #30965:
URL: https://github.com/apache/airflow/pull/30965
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1533990557
got it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mis98zb commented on pull request #30965: fix issue: DAG's on_failure_callback is not invoked when task failed during testing dag.
Posted by "mis98zb (via GitHub)" <gi...@apache.org>.
mis98zb commented on PR #30965:
URL: https://github.com/apache/airflow/pull/30965#issuecomment-1562348217
I have removed the wrong test code. Can anyone help to approve the testing?
thanks & best regards.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org