This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new c282c1bc8e1 Docs: Use `BaseSensorOperator` from Task SDK (#48822)
c282c1bc8e1 is described below
commit c282c1bc8e1f33d76bd59343382cb9fee58e158b
Author: Kaxil Naik <[email protected]>
AuthorDate: Sat Apr 5 05:39:07 2025 +0530
Docs: Use `BaseSensorOperator` from Task SDK (#48822)
---
airflow-core/docs/authoring-and-scheduling/deferring.rst | 10 +++++-----
airflow-core/docs/tutorial/taskflow.rst | 4 ++--
.../src/airflow/example_dags/example_sensor_decorator.py | 2 +-
airflow-core/tests/unit/models/test_taskinstance.py | 2 +-
task-sdk/src/airflow/sdk/__init__.py | 4 +++-
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/airflow-core/docs/authoring-and-scheduling/deferring.rst
b/airflow-core/docs/authoring-and-scheduling/deferring.rst
index d7b78d73b3e..c2e1619754d 100644
--- a/airflow-core/docs/authoring-and-scheduling/deferring.rst
+++ b/airflow-core/docs/authoring-and-scheduling/deferring.rst
@@ -67,7 +67,7 @@ When writing a deferrable operators these are the main points
to consider:
from typing import Any
from airflow.configuration import conf
- from airflow.sensors.base import BaseSensorOperator
+ from airflow.sdk import BaseSensorOperator
from airflow.providers.standard.triggers.temporal import TimeDeltaTrigger
from airflow.utils.context import Context
@@ -177,7 +177,7 @@ Here's a basic example of how a sensor might trigger
deferral:
from datetime import timedelta
from typing import TYPE_CHECKING, Any
- from airflow.sensors.base import BaseSensorOperator
+ from airflow.sdk import BaseSensorOperator
from airflow.providers.standard.triggers.temporal import TimeDeltaTrigger
if TYPE_CHECKING:
@@ -290,7 +290,7 @@ In the sensor part, we'll need to provide the path to
``TimeDeltaTrigger`` as ``
from datetime import timedelta
from typing import TYPE_CHECKING, Any
- from airflow.sensors.base import BaseSensorOperator
+ from airflow.sdk import BaseSensorOperator
from airflow.triggers.base import StartTriggerArgs
if TYPE_CHECKING:
@@ -321,7 +321,7 @@ In the sensor part, we'll need to provide the path to
``TimeDeltaTrigger`` as ``
from datetime import timedelta
from typing import TYPE_CHECKING, Any
- from airflow.sensors.base import BaseSensorOperator
+ from airflow.sdk import BaseSensorOperator
from airflow.triggers.base import StartTriggerArgs
if TYPE_CHECKING:
@@ -360,7 +360,7 @@ After the trigger has finished executing, the task may be
sent back to the worke
from datetime import timedelta
from typing import TYPE_CHECKING, Any
- from airflow.sensors.base import BaseSensorOperator
+ from airflow.sdk import BaseSensorOperator
from airflow.triggers.base import StartTriggerArgs
if TYPE_CHECKING:
diff --git a/airflow-core/docs/tutorial/taskflow.rst
b/airflow-core/docs/tutorial/taskflow.rst
index c022a3d8f4b..ef2355f114e 100644
--- a/airflow-core/docs/tutorial/taskflow.rst
+++ b/airflow-core/docs/tutorial/taskflow.rst
@@ -369,7 +369,7 @@ an instance of the ``PokeReturnValue`` object at the end of
the ``poke()`` metho
.. code-block:: python
- from airflow.sensors.base import PokeReturnValue
+ from airflow.sdk import PokeReturnValue
class SensorWithXcomValue(BaseSensorOperator):
@@ -386,7 +386,7 @@ pre-2.3, you need to explicitly push the XCOM value if the
version is pre-2.3.
.. code-block:: python
try:
- from airflow.sensors.base import PokeReturnValue
+ from airflow.sdk import PokeReturnValue
except ImportError:
PokeReturnValue = None
diff --git a/airflow-core/src/airflow/example_dags/example_sensor_decorator.py
b/airflow-core/src/airflow/example_dags/example_sensor_decorator.py
index db3059398c0..3557e874ede 100644
--- a/airflow-core/src/airflow/example_dags/example_sensor_decorator.py
+++ b/airflow-core/src/airflow/example_dags/example_sensor_decorator.py
@@ -25,7 +25,7 @@ from __future__ import annotations
import pendulum
from airflow.decorators import dag, task
-from airflow.sensors.base import PokeReturnValue
+from airflow.sdk import PokeReturnValue
# [END import_module]
diff --git a/airflow-core/tests/unit/models/test_taskinstance.py
b/airflow-core/tests/unit/models/test_taskinstance.py
index ff1b6559d29..cabeab09c70 100644
--- a/airflow-core/tests/unit/models/test_taskinstance.py
+++ b/airflow-core/tests/unit/models/test_taskinstance.py
@@ -75,6 +75,7 @@ from airflow.providers.standard.operators.bash import
BashOperator
from airflow.providers.standard.operators.empty import EmptyOperator
from airflow.providers.standard.operators.python import PythonOperator
from airflow.providers.standard.sensors.python import PythonSensor
+from airflow.sdk import BaseSensorOperator
from airflow.sdk.api.datamodels._generated import AssetEventResponse,
AssetResponse
from airflow.sdk.bases.notifier import BaseNotifier
from airflow.sdk.definitions.asset import Asset, AssetAlias
@@ -82,7 +83,6 @@ from airflow.sdk.definitions.param import process_params
from airflow.sdk.execution_time.comms import (
AssetEventsResult,
)
-from airflow.sensors.base import BaseSensorOperator
from airflow.serialization.serialized_objects import SerializedBaseOperator,
SerializedDAG
from airflow.stats import Stats
from airflow.ti_deps.dep_context import DepContext
diff --git a/task-sdk/src/airflow/sdk/__init__.py
b/task-sdk/src/airflow/sdk/__init__.py
index 075b4fbef16..b174d2f3147 100644
--- a/task-sdk/src/airflow/sdk/__init__.py
+++ b/task-sdk/src/airflow/sdk/__init__.py
@@ -36,6 +36,7 @@ __all__ = [
"Label",
"Metadata",
"Param",
+ "PokeReturnValue",
"TaskGroup",
"Variable",
"XComArg",
@@ -55,7 +56,7 @@ if TYPE_CHECKING:
from airflow.sdk.bases.notifier import BaseNotifier
from airflow.sdk.bases.operator import BaseOperator, chain, chain_linear,
cross_downstream
from airflow.sdk.bases.operatorlink import BaseOperatorLink
- from airflow.sdk.bases.sensor import BaseSensorOperator
+ from airflow.sdk.bases.sensor import BaseSensorOperator, PokeReturnValue
from airflow.sdk.definitions.asset import Asset, AssetAlias, AssetAll,
AssetAny, AssetWatcher
from airflow.sdk.definitions.asset.decorators import asset
from airflow.sdk.definitions.asset.metadata import Metadata
@@ -86,6 +87,7 @@ __lazy_imports: dict[str, str] = {
"Label": ".definitions.edges",
"Metadata": ".definitions.asset.metadata",
"Param": ".definitions.param",
+ "PokeReturnValue": ".bases.sensor",
"TaskGroup": ".definitions.taskgroup",
"Variable": ".definitions.variable",
"XComArg": ".definitions.xcom_arg",