You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/13 13:05:19 UTC

[GitHub] [airflow] kaxil opened a new pull request #13651: BugFix: Dag-level Callback Requests were not run

kaxil opened a new pull request #13651:
URL: https://github.com/apache/airflow/pull/13651


   In https://github.com/apache/airflow/pull/13163 - I attempted to only run
   Callback requests when they are defined on DAG. But I just found out
   that while we were storing the task-level callbacks as string in Serialized
   JSON, we were not storing DAG level callbacks and hence it default to None
   when the Serialized DAG was deserialized which meant that the DAG callbacks
   were not run.
   
   This PR fixes it, we don't need to store DAG level callbacks as string, as
   we don't display them in the Webserver and the actual contents are not used anywhere
   in the Scheduler itself. Scheduler just checks if the callbacks are defined and sends
   it to DagFileProcessorProcess to run with the actual DAG file. So instead of storing
   the actual callback as string which would have resulted in larger JSON blob, I have
   added properties to determine whether a callback is defined or not.
   
   (`dag.has_on_success_callback` and `dag.has_on_failure_callback`)
   
   Note: SLA callbacks don't have issue, as we currently check that SLAs are defined on
   any tasks are not, if yes, we send it to DagFileProcessorProcess which then executes
   the SLA callback defined on DAG.
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil commented on a change in pull request #13651: BugFix: Dag-level Callback Requests were not run

Posted by GitBox <gi...@apache.org>.
kaxil commented on a change in pull request #13651:
URL: https://github.com/apache/airflow/pull/13651#discussion_r556590950



##########
File path: airflow/models/dag.py
##########
@@ -348,6 +348,12 @@ def __init__(
         self.partial = False
         self.on_success_callback = on_success_callback
         self.on_failure_callback = on_failure_callback
+
+        # To keep it in parity with Serialized DAGs
+        # and identify if DAG has on_*_callback without actually storing them in Serialized JSON
+        self.has_on_success_callback = bool(self.on_success_callback is not None)
+        self.has_on_failure_callback = bool(self.on_failure_callback is not None)

Review comment:
       Oh yea not needed now.
   
   Previously I had:
   
   ```python
           self.has_on_success_callback = bool(self.on_success_callback)
           self.has_on_failure_callback = bool(self.on_failure_callback)
   ```
   
   before I changed it couple of times :D 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #13651: BugFix: Dag-level Callback Requests were not run

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #13651:
URL: https://github.com/apache/airflow/pull/13651#issuecomment-759705209


   [The Workflow run](https://github.com/apache/airflow/actions/runs/483621608) is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] kaxil merged pull request #13651: BugFix: Dag-level Callback Requests were not run

Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #13651:
URL: https://github.com/apache/airflow/pull/13651


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #13651: BugFix: Dag-level Callback Requests were not run

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #13651:
URL: https://github.com/apache/airflow/pull/13651#discussion_r556584232



##########
File path: airflow/models/dag.py
##########
@@ -348,6 +348,12 @@ def __init__(
         self.partial = False
         self.on_success_callback = on_success_callback
         self.on_failure_callback = on_failure_callback
+
+        # To keep it in parity with Serialized DAGs
+        # and identify if DAG has on_*_callback without actually storing them in Serialized JSON
+        self.has_on_success_callback = bool(self.on_success_callback is not None)
+        self.has_on_failure_callback = bool(self.on_failure_callback is not None)

Review comment:
       ```suggestion
           self.has_on_success_callback = self.on_success_callback is not None
           self.has_on_failure_callback = self.on_failure_callback is not None
   ```
   
   No need for bool I don't think




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org