docs(deferring): add type annotation to code examples#32422
docs(deferring): add type annotation to code examples#32422potiuk merged 3 commits intoapache:mainfrom
Conversation
pankajastro
left a comment
There was a problem hiding this comment.
we should add the same for exampleDateTimeTrigger too we have 2 serialize and run methods there wdyt?
Sorry, I kinda don't get it. Could you point out where is it? |
sure, type annotation for trigger examples also code block https://github.com/apache/airflow/blob/main/docs/apache-airflow/authoring-and-scheduling/deferring.rst?plain=1#L111-L124 |
|
ah yes, I've changed all the code block into that |
4c34d66 to
0ceeac9
Compare
| * 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 ``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. |
There was a problem hiding this comment.
Here we are talking about both operators and sensors, but giving an example of deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False) only for operators.
There was a problem hiding this comment.
As the sensor is a kind of operator as well https://github.com/apache/airflow/blob/main/airflow/sensors/base.py#L82, it seems to me this should be fine. But I'm good with making this change as well. We probably should add default_deferrable here. Maybe that should be another PR?
As discussed in #32355 (comment), I'm thinking of adding some type annotations to the documentation.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.