-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Add back information about current context to the docs #18868
Conversation
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.
get_current_context
isn't needed in the vast majority of cases.
28b0fcb
to
da0b307
Compare
c1b2c80
to
426b545
Compare
There were many questions recently along the line of "How do I access context from TaskFlow task". Surprisingly, the paragraph about accessing current context was removed from the "Concepts" (where it was there for Airflow 2.0.0) but was never added to the "TaskFlow Tutorial" where it actually belongs. Also Python Operator's description about passing context variables as kwargs have been removed when `provide_context` parameter was removed (it was only present in the docstring of `provide_context` and you could likely deduce this behaviour from several examples, but it was not mentioned anywhere. This PR adds the description with examples to the Python operator as well as adds similar description in TaskFlow tutorial, including the possibility of using `get_current_context` deep down the stack to retrieve the context variables even if they are not passed via kwargs.
426b545
to
96af814
Compare
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
Nice one! |
.. code-block:: python | ||
|
||
@task | ||
def my_python_callable(ti, next_ds): |
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.
Thought: can user-defined-macros
(i.e. defined at dag-level) be passed too ?
There were many questions recently along the line of "How do I access context from TaskFlow task". Surprisingly, the paragraph about accessing current context was removed from the "Concepts" (where it was there for Airflow 2.0.0) but was never added to the "TaskFlow Tutorial" where it actually belongs. Also Python Operator's description about passing context variables as kwargs have been removed when `provide_context` parameter was removed (it was only present in the docstring of `provide_context` and you could likely deduce this behaviour from several examples, but it was not mentioned anywhere. This PR adds the description with examples to the Python operator as well as adds similar description in TaskFlow tutorial, including the possibility of using `get_current_context` deep down the stack to retrieve the context variables even if they are not passed via kwargs. (cherry picked from commit d6c8730)
There were many questions recently along the line of "How do I access context from TaskFlow task". Surprisingly, the paragraph about accessing current context was removed from the "Concepts" (where it was there for Airflow 2.0.0) but was never added to the "TaskFlow Tutorial" where it actually belongs. Also Python Operator's description about passing context variables as kwargs have been removed when `provide_context` parameter was removed (it was only present in the docstring of `provide_context` and you could likely deduce this behaviour from several examples, but it was not mentioned anywhere. This PR adds the description with examples to the Python operator as well as adds similar description in TaskFlow tutorial, including the possibility of using `get_current_context` deep down the stack to retrieve the context variables even if they are not passed via kwargs. (cherry picked from commit d6c8730)
There were many questions recently along the line of "How do I access context from TaskFlow task". Surprisingly, the paragraph about accessing current context was removed from the "Concepts" (where it was there for Airflow 2.0.0) but was never added to the "TaskFlow Tutorial" where it actually belongs. Also Python Operator's description about passing context variables as kwargs have been removed when `provide_context` parameter was removed (it was only present in the docstring of `provide_context` and you could likely deduce this behaviour from several examples, but it was not mentioned anywhere. This PR adds the description with examples to the Python operator as well as adds similar description in TaskFlow tutorial, including the possibility of using `get_current_context` deep down the stack to retrieve the context variables even if they are not passed via kwargs. (cherry picked from commit d6c8730)
(Kicking this back to the 2.2.3 milestone as that's when this landed in a release) |
There were many questions recently along the line of
"How do I access context from TaskFlow task". Surprisingly,
the paragraph about accessing current context was removed from
the "Concepts" (where it was there for Airflow 2.0.0) but was
never added to the "TaskFlow Tutorial" where it actually belongs.
This PR adds the paragraph back.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 UPDATING.md.