-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Replace usages of XCOM_RETURN_KEY in providers to not be from utils
#53170
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,10 +36,12 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]: | |
| AIRFLOW_V_3_1_PLUS = get_base_airflow_version_tuple() >= (3, 1, 0) | ||
|
|
||
| if AIRFLOW_V_3_1_PLUS: | ||
| from airflow.models.xcom import XCOM_RETURN_KEY | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're changing this, it's should be changed to use something from sdk, not core. Also this reminds me- the airflow version check in providers needs to go soon too - we ideally want to "duck type" off what we can I the sdk (i.e. try import except)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Question: are we going to have task-sdk installable also in Airflow 2 or is it going to be optional dependency of providers? Currently it's not that's why have all the "ifs" and they have to be part of provider's code - so such a version check in sdk will only be really possible to remove from providers if task-sdk is also installable on Airflow 2.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be installable in AF2 and if adding an optional dep in providers is what leads to, I think we should. |
||
| from airflow.sdk import BaseHook, BaseOperator | ||
| else: | ||
| from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef] | ||
| from airflow.models import BaseOperator # type: ignore[no-redef] | ||
| from airflow.utils.xcom import XCOM_RETURN_KEY # type: ignore[no-redef] | ||
|
|
||
| if AIRFLOW_V_3_0_PLUS: | ||
| from airflow.sdk import BaseSensorOperator | ||
|
|
@@ -61,4 +63,5 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]: | |
| "DecoratedOperator", | ||
| "TaskDecorator", | ||
| "task_decorator_factory", | ||
| "XCOM_RETURN_KEY", | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,11 +35,6 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]: | |
| AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0) | ||
| AIRFLOW_V_3_1_PLUS = get_base_airflow_version_tuple() >= (3, 1, 0) | ||
|
|
||
| if AIRFLOW_V_3_1_PLUS: | ||
| from airflow.sdk import BaseHook | ||
| else: | ||
| from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef] | ||
|
|
||
| if AIRFLOW_V_3_0_PLUS: | ||
| from airflow.sdk import ( | ||
| BaseOperator, | ||
|
|
@@ -50,10 +45,19 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]: | |
| from airflow.models import BaseOperator, BaseOperatorLink # type: ignore[no-redef] | ||
| from airflow.sensors.base import BaseSensorOperator # type: ignore[no-redef] | ||
|
|
||
| if AIRFLOW_V_3_1_PLUS: | ||
| from airflow.models.xcom import XCOM_RETURN_KEY | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto - sdk please
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR: #53180 |
||
| from airflow.sdk import BaseHook | ||
| else: | ||
| from airflow.hooks.base import BaseHook # type: ignore[attr-defined,no-redef] | ||
| from airflow.utils.xcom import XCOM_RETURN_KEY # type: ignore[no-redef] | ||
|
|
||
| __all__ = [ | ||
| "AIRFLOW_V_3_0_PLUS", | ||
| "AIRFLOW_V_3_1_PLUS", | ||
| "BaseHook", | ||
| "BaseOperator", | ||
| "BaseOperatorLink", | ||
| "BaseSensorOperator", | ||
| "XCOM_RETURN_KEY", | ||
| ] | ||
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.
Instead of adding this (which is also missing the fns etc) change the import to
from ... import XCOM_RETURN_KEY as XCOM_RETURN_KEY- that should remove the unused import warning