-
Notifications
You must be signed in to change notification settings - Fork 16.3k
docs(deferring): add type annotation to code examples #32422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(deferring): add type annotation to code examples #32422
Conversation
pankajastro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
Co-authored-by: Syed Hussain <[email protected]>
syedahsn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.