phanikumv commented on code in PR #32422:
URL: https://github.com/apache/airflow/pull/32422#discussion_r1255901266
##########
docs/apache-airflow/authoring-and-scheduling/deferring.rst:
##########
@@ -56,38 +56,44 @@ Writing a deferrable operator takes a bit more work. There
are some main points
* You can defer multiple times, and you can defer before/after your Operator
does significant work, or only defer if certain conditions are met (e.g. a
system does not have an immediate answer). Deferral is entirely under your
control.
* Any Operator can defer; no special marking on its class is needed, and it's
not limited to Sensors.
* In order for any changes to a Trigger to be reflected, the *triggerer* needs
to be restarted whenever the Trigger is modified.
-* If you want add an operator or sensor that supports both deferrable and
non-deferrable modes. It's suggested to add ``deferable: bool =
conf.getboolean("operators", "default_deferrable", fallback=False)`` to the
``__init__`` method of the operator and use it to decide whether to run the
operator in deferrable mode. You'll be able to configure the default value of
``deferrable`` of all the operators and sensors that supports switch between
deferrable and non-deferrable mode through ``default_deferrable`` in the
``operator`` section. Here's an example of a sensor that supports both modes.::
+* If you want add an operator or sensor that supports both deferrable and
non-deferrable modes. It's suggested to add ``deferable: bool =
conf.getboolean("operators", "default_deferrable", fallback=False)`` to the
``__init__`` method of the operator and use it to decide whether to run the
operator in deferrable mode. You'll be able to configure the default value of
``deferrable`` of all the operators and sensors that supports switch between
deferrable and non-deferrable mode through ``default_deferrable`` in the
``operator`` section. Here's an example of a sensor that supports both modes.
Review Comment:
```suggestion
* If you want add an operator or sensor that supports both deferrable and
non-deferrable modes. It's suggested to add ``deferrable: bool =
conf.getboolean("operators", "default_deferrable", fallback=False)`` to the
``__init__`` method of the operator and use it to decide whether to run the
operator in deferrable mode. You'll be able to configure the default value of
``deferrable`` of all the operators and sensors that supports switch between
deferrable and non-deferrable mode through ``default_deferrable`` in the
``operator`` section. Here's an example of a sensor that supports both modes.
```
##########
docs/apache-airflow/authoring-and-scheduling/deferring.rst:
##########
@@ -56,38 +56,44 @@ Writing a deferrable operator takes a bit more work. There
are some main points
* You can defer multiple times, and you can defer before/after your Operator
does significant work, or only defer if certain conditions are met (e.g. a
system does not have an immediate answer). Deferral is entirely under your
control.
* Any Operator can defer; no special marking on its class is needed, and it's
not limited to Sensors.
* In order for any changes to a Trigger to be reflected, the *triggerer* needs
to be restarted whenever the Trigger is modified.
-* If you want add an operator or sensor that supports both deferrable and
non-deferrable modes. It's suggested to add ``deferable: bool =
conf.getboolean("operators", "default_deferrable", fallback=False)`` to the
``__init__`` method of the operator and use it to decide whether to run the
operator in deferrable mode. You'll be able to configure the default value of
``deferrable`` of all the operators and sensors that supports switch between
deferrable and non-deferrable mode through ``default_deferrable`` in the
``operator`` section. Here's an example of a sensor that supports both modes.::
+* If you want add an operator or sensor that supports both deferrable and
non-deferrable modes. It's suggested to add ``deferable: bool =
conf.getboolean("operators", "default_deferrable", fallback=False)`` to the
``__init__`` method of the operator and use it to decide whether to run the
operator in deferrable mode. You'll be able to configure the default value of
``deferrable`` of all the operators and sensors that supports switch between
deferrable and non-deferrable mode through ``default_deferrable`` in the
``operator`` section. Here's an example of a sensor that supports both modes.
+
+.. code-block:: python
import time
from datetime import timedelta
+ from typing import Any
+ from airflow.configuration import conf
from airflow.sensors.base import BaseSensorOperator
from airflow.triggers.temporal import TimeDeltaTrigger
+ from airflow.utils.context import Context
class WaitOneHourSensor(BaseSensorOperator):
def __init__(
- self,
- deferable: bool = conf.getboolean("operators",
"default_deferrable", fallback=False),
- **kwargs
- ):
+ self, deferable: bool = conf.getboolean("operators",
"default_deferrable", fallback=False), **kwargs
Review Comment:
```suggestion
self, deferrable: bool = conf.getboolean("operators",
"default_deferrable", fallback=False), **kwargs
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]