Skip to content
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

Merged
merged 1 commit into from
Oct 11, 2021

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Oct 10, 2021

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.

Copy link
Member

@ashb ashb left a 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.

docs/apache-airflow/tutorial_taskflow_api.rst Outdated Show resolved Hide resolved
@potiuk potiuk force-pushed the add-current-context-to-docs branch from 28b0fcb to da0b307 Compare October 11, 2021 13:27
@potiuk potiuk requested a review from ashb October 11, 2021 13:28
@potiuk potiuk force-pushed the add-current-context-to-docs branch 2 times, most recently from c1b2c80 to 426b545 Compare October 11, 2021 13:34
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.
@potiuk potiuk force-pushed the add-current-context-to-docs branch from 426b545 to 96af814 Compare October 11, 2021 13:35
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Oct 11, 2021
@github-actions
Copy link

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.

@ashb
Copy link
Member

ashb commented Oct 11, 2021

Nice one!

@potiuk potiuk merged commit d6c8730 into apache:main Oct 11, 2021
@potiuk potiuk deleted the add-current-context-to-docs branch October 11, 2021 15:12
.. code-block:: python

@task
def my_python_callable(ti, next_ds):
Copy link

@yan-hic yan-hic Dec 2, 2021

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 ?

@jedcunningham jedcunningham added this to the Airflow 2.2.3 milestone Dec 7, 2021
@jedcunningham jedcunningham added the type:doc-only Changelog: Doc Only label Dec 7, 2021
jedcunningham pushed a commit that referenced this pull request Dec 7, 2021
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)
potiuk added a commit that referenced this pull request Jan 23, 2022
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)
@potiuk potiuk modified the milestones: Airflow 2.2.3, Airflow 2.2.4 Jan 23, 2022
jedcunningham pushed a commit that referenced this pull request Jan 27, 2022
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)
@jedcunningham
Copy link
Member

(Kicking this back to the 2.2.3 milestone as that's when this landed in a release)

@potiuk potiuk restored the add-current-context-to-docs branch April 26, 2022 20:48
@potiuk potiuk deleted the add-current-context-to-docs branch July 29, 2022 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full tests needed We need to run full set of tests for this PR to merge kind:documentation type:doc-only Changelog: Doc Only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants