You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Lee-W (via GitHub)" <gi...@apache.org> on 2023/08/08 09:33:10 UTC
[GitHub] [airflow] Lee-W opened a new pull request, #33196: respect soft_fail argument when ExternalTskSensor runs in deferrable mode
Lee-W opened a new pull request, #33196:
URL: https://github.com/apache/airflow/pull/33196
We notice that not all the sensors respect [soft_fail](https://airflow.apache.org/docs/apache-airflow/stable/_api/airflow/sensors/base/index.html#airflow.sensors.base.BaseSensorOperator). This PR is meant to demonstrate how I'd like to address this issue. Will send PRs to fix other sensors when we finalize the way to fix it.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
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 an 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/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+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 a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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 #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33196:
URL: https://github.com/apache/airflow/pull/33196#discussion_r1292948518
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,12 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
Review Comment:
```suggestion
def raise_failed_or_skiping_exception(self, *, failed_message: str, skipping_message: str = "") -> None:
```
Let’s make these keyword-only
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,12 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
Review Comment:
```suggestion
def raise_failed_or_skiping_exception(self, *, failed_message: str, skipping_message: str = "") -> None:
```
Let’s make these keyword-only
--
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] Lee-W commented on a diff in pull request #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #33196:
URL: https://github.com/apache/airflow/pull/33196#discussion_r1289755110
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,16 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
+ """Raise AirflowSkipException if self.soft_fail is set to True. Otherwise raise AirflowException."""
+ if self.soft_fail:
+ if skipping_message:
+ message = skipping_message
+ else:
+ message = failed_message
+ raise AirflowSkipException(message)
Review Comment:
It's not always `{failed_message}{self._skipping_message_postfix}`. e.g., https://github.com/apache/airflow/pull/33196/files#diff-257fa1956f6fafd5d9136377b3d84c795882835712892903ff610e37ed688922R289-R293
Even though I think doing it in this function would be ideal, it changes the message of existing messages. (I guess this is likely the case for other sensors I've not yet started to work on as well)
--
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 #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33196:
URL: https://github.com/apache/airflow/pull/33196#discussion_r1289740240
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,16 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
+ """Raise AirflowSkipException if self.soft_fail is set to True. Otherwise raise AirflowException."""
+ if self.soft_fail:
+ if skipping_message:
+ message = skipping_message
+ else:
+ message = failed_message
+ raise AirflowSkipException(message)
Review Comment:
But, since `skipping_message` is always `{failed_message}{self._skipping_message_postfix}`, why not just do it in this function?
--
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] Lee-W commented on a diff in pull request #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #33196:
URL: https://github.com/apache/airflow/pull/33196#discussion_r1292954293
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,12 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
Review Comment:
Sounds good 👍 Just updated it
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,12 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
Review Comment:
Sounds good 👍 Just updated 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] uranusjr commented on a diff in pull request #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33196:
URL: https://github.com/apache/airflow/pull/33196#discussion_r1289738390
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,16 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
+ """Raise AirflowSkipException if self.soft_fail is set to True. Otherwise raise AirflowException."""
+ if self.soft_fail:
+ if skipping_message:
+ message = skipping_message
+ else:
+ message = failed_message
+ raise AirflowSkipException(message)
Review Comment:
```suggestion
raise AirflowSkipException(skipping_message or failed_message)
```
--
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 #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #33196:
URL: https://github.com/apache/airflow/pull/33196
--
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] Lee-W commented on a diff in pull request #33196: respect soft_fail argument when ExternalTaskSensor runs in deferrable mode
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on code in PR #33196:
URL: https://github.com/apache/airflow/pull/33196#discussion_r1292882258
##########
airflow/sensors/base.py:
##########
@@ -330,6 +330,16 @@ def reschedule(self):
def get_serialized_fields(cls):
return super().get_serialized_fields() | {"reschedule"}
+ def raise_failed_or_skiping_exception(self, failed_message: str, skipping_message: str = "") -> None:
+ """Raise AirflowSkipException if self.soft_fail is set to True. Otherwise raise AirflowException."""
+ if self.soft_fail:
+ if skipping_message:
+ message = skipping_message
+ else:
+ message = failed_message
+ raise AirflowSkipException(message)
Review Comment:
Just updated the code as suggestion
--
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