Skip to content

Commit

Permalink
Add deprecation warning in core provider (#1439)
Browse files Browse the repository at this point in the history
* Add a deprecation warning in the core provider

add a deprecation warning in the core provider to warn users about removal and encourage them to use the upcoming OSS sensor
  • Loading branch information
pankajastro authored Jan 22, 2024
1 parent 2bb2e1c commit dda8064
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
10 changes: 10 additions & 0 deletions astronomer/providers/core/sensors/external_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import warnings
from typing import TYPE_CHECKING, Any, Dict, List, Optional

from airflow.sensors.external_task import ExternalTaskSensor
Expand All @@ -23,6 +24,15 @@ def __init__(
poke_interval: float = 5.0,
**kwargs: Any,
) -> None:
warnings.warn(
(
"This module is deprecated and will be removed in airflow>=2.9.0"
"Please use `airflow.sensors.external_task.ExternalTaskSensor` "
"and set deferrable to True instead."
),
DeprecationWarning,
stacklevel=2,
)
super().__init__(**kwargs)
self.poke_interval = poke_interval

Expand Down
13 changes: 13 additions & 0 deletions astronomer/providers/core/sensors/filesystem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import warnings
from datetime import timedelta
from typing import Any, Dict, Optional

Expand All @@ -23,6 +24,18 @@ class FileSensorAsync(FileSensor):
``**`` in glob filepath parameter. Defaults to ``False``.
"""

def __init__(self, *args, **kwargs):
warnings.warn(
(
"This module is deprecated and will be removed in airflow>=2.9.0"
"Please use `airflow.sensors.filesystem.FileSensor` "
"and set deferrable to True instead."
),
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)

def execute(self, context: Context) -> None:
"""Airflow runs this method on the worker and defers using the trigger."""
if not self.poke(context=context):
Expand Down
10 changes: 10 additions & 0 deletions astronomer/providers/core/triggers/external_task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import datetime
import typing
import warnings
from typing import Any, AsyncIterator, Dict, List, Tuple

from airflow import AirflowException
Expand Down Expand Up @@ -105,6 +106,15 @@ def __init__(
execution_dates: List[datetime.datetime],
poll_interval: float = 5.0,
):
warnings.warn(
(
"This module is deprecated and will be removed in airflow>=2.9.0"
"Please use `airflow.triggers.external_task.WorkflowTrigger` "
"and set deferrable to True instead."
),
DeprecationWarning,
stacklevel=2,
)
super().__init__()
self.dag_id = dag_id
self.states = states
Expand Down
10 changes: 10 additions & 0 deletions astronomer/providers/core/triggers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import os
import typing
import warnings
from glob import glob
from typing import Any, Dict, Tuple

Expand All @@ -26,6 +27,15 @@ def __init__(
recursive: bool = False,
poll_interval: float = 5.0,
):
warnings.warn(
(
"This module is deprecated and will be removed in airflow>=2.9.0"
"Please use `airflow.triggers.file.FileTrigger` "
"and set deferrable to True instead."
),
DeprecationWarning,
stacklevel=2,
)
super().__init__()
self.filepath = filepath
self.recursive = recursive
Expand Down

0 comments on commit dda8064

Please sign in to comment.