Skip to content

AIP-72: Gracefully handle 'not-found' XCOMs in task sdk API client - #45344

Merged
amoghrajesh merged 2 commits into
apache:mainfrom
astronomer:gracefully-handle-no-xcom-situation
Jan 3, 2025
Merged

AIP-72: Gracefully handle 'not-found' XCOMs in task sdk API client#45344
amoghrajesh merged 2 commits into
apache:mainfrom
astronomer:gracefully-handle-no-xcom-situation

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

closes: #45341

Testing results

DAG used:

from airflow import DAG
from airflow.providers.standard.operators.python import PythonOperator
def push_to_xcom(**kwargs):
value = "Hello, XCom!"
return value
def pull_from_xcom(**kwargs):
ti = kwargs['ti']
xcom_value = ti.xcom_pull(task_ids='invalid_id')
print(f"Retrieved XCom Value: {xcom_value}")
with DAG(
'xcom_example',
schedule=None,
catchup=False,
) as dag:
push_xcom_task = PythonOperator(
task_id='push_xcom_task',
python_callable=push_to_xcom,
)
pull_xcom_task = PythonOperator(
task_id='pull_xcom_task',
python_callable=pull_from_xcom,
)
push_xcom_task >> pull_xcom_task

Legacy

Task 1 XCom pushed:
image

Task 2 XCom consumed as None when absent:
image

Task SDK

Task 1 XCom pushed:
image

Task 2 XCom consumed as None when absent:
image


^ 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.rst or {issue_number}.significant.rst, in newsfragments.

Comment threadtask_sdk/src/airflow/sdk/execution_time/supervisor.py Outdated
Comment threadtask_sdk/tests/execution_time/test_supervisor.py Outdated
@amoghrajeshamoghrajesh changed the title AIP-72: Gracefully handle not-found XCOMs in task sdk API clientAIP-72: Gracefully handle 'not-found' XCOMs in task sdk API clientJan 2, 2025

@jscheffljscheffl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one comment. But not critical to move ahead.

@amoghrajesh
amoghrajeshforce-pushed the gracefully-handle-no-xcom-situation branch from 8862d7d to f8e4be0CompareJanuary 2, 2025 11:00

@jscheffljscheffl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, much simpler now :-D

Comment threadtask_sdk/src/airflow/sdk/api/client.py
@potiuk

Copy link
Copy Markdown
Member

@amoghrajesh - can you please rebase that one -> we found and issue with @jscheffl with the new caching scheme - fixed in #45347 that would run "main" version of the tests. I am asking in all affected PRs to rebase.

@amoghrajeshamoghrajesh left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uranusjr@jscheffl its already handled using an event hook

Comment threadtask_sdk/src/airflow/sdk/api/client.py
@amoghrajesh

Copy link
Copy Markdown
ContributorAuthor

@amoghrajesh - can you please rebase that one -> we found and issue with @jscheffl with the new caching scheme - fixed in #45347 that would run "main" version of the tests. I am asking in all affected PRs to rebase.

Oh ok, let me rebase this one

@amoghrajesh

Copy link
Copy Markdown
ContributorAuthor

Hi @uranusjr are you ok with the reply on this comment? #45344 (comment)

@amoghrajesh
amoghrajeshforce-pushed the gracefully-handle-no-xcom-situation branch from 7c807b7 to 482fab5CompareJanuary 3, 2025 06:38
@amoghrajesh
amoghrajesh merged commit aae1a57 into apache:mainJan 3, 2025
@amoghrajesh
amoghrajesh deleted the gracefully-handle-no-xcom-situation branch January 3, 2025 09:11
HariGS-DB pushed a commit to HariGS-DB/airflow that referenced this pull request Jan 16, 2025
…pache#45344)
* AIP-72: Gracefully handle not-found XCOMs in task sdk API client
* re raising exception for non 404
got686-yandex pushed a commit to got686-yandex/airflow that referenced this pull request Jan 30, 2025
…pache#45344)
* AIP-72: Gracefully handle not-found XCOMs in task sdk API client
* re raising exception for non 404
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AIP-72: Gracefully handle "not-found" XCOMs in task sdk API client

4 participants

@amoghrajesh@potiuk@uranusjr@jscheffl