-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate AzureDataFactoryPipelineRunStatusSensorAsync
Deprecate AzureDataFactoryPipelineRunStatusSensorAsync and proxy it to its Airflow OSS provider's counterpart related: #1412
- Loading branch information
1 parent
e7bf96c
commit 98edef8
Showing
4 changed files
with
31 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 8 additions & 47 deletions
55
astronomer/providers/microsoft/azure/sensors/data_factory.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,29 @@ | ||
import warnings | ||
from datetime import timedelta | ||
from typing import Any, Dict | ||
from typing import Any | ||
|
||
from airflow.providers.microsoft.azure.sensors.data_factory import ( | ||
AzureDataFactoryPipelineRunStatusSensor, | ||
) | ||
|
||
from astronomer.providers.microsoft.azure.triggers.data_factory import ( | ||
ADFPipelineRunStatusSensorTrigger, | ||
) | ||
from astronomer.providers.utils.sensor_util import poke, raise_error_or_skip_exception | ||
from astronomer.providers.utils.typing_compat import Context | ||
from airflow.providers.microsoft.azure.sensors.data_factory import AzureDataFactoryPipelineRunStatusSensor | ||
|
||
|
||
class AzureDataFactoryPipelineRunStatusSensorAsync(AzureDataFactoryPipelineRunStatusSensor): | ||
""" | ||
Checks the status of a pipeline run. | ||
:param azure_data_factory_conn_id: The connection identifier for connecting to Azure Data Factory. | ||
:param run_id: The pipeline run identifier. | ||
:param resource_group_name: The resource group name. | ||
:param factory_name: The data factory name. | ||
:param poll_interval: polling period in seconds to check for the status | ||
This class is deprecated. | ||
Use :class: `~airflow.providers.microsoft.azure.sensors.data_factory.AzureDataFactoryPipelineRunStatusSensor` | ||
instead and set `deferrable` param to `True` instead. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
*, | ||
*args: Any, | ||
poll_interval: float = 5, | ||
**kwargs: Any, | ||
): | ||
# TODO: Remove once deprecated | ||
if poll_interval: | ||
self.poke_interval = poll_interval | ||
kwargs["poke_interval"] = poll_interval | ||
warnings.warn( | ||
"Argument `poll_interval` is deprecated and will be removed " | ||
"in a future release. Please use `poke_interval` instead.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
super().__init__(**kwargs) | ||
|
||
def execute(self, context: Context) -> None: | ||
"""Defers trigger class to poll for state of the job run until it reaches a failure state or success state""" | ||
if not poke(self, context): | ||
self.defer( | ||
timeout=timedelta(seconds=self.timeout), | ||
trigger=ADFPipelineRunStatusSensorTrigger( | ||
run_id=self.run_id, | ||
azure_data_factory_conn_id=self.azure_data_factory_conn_id, | ||
resource_group_name=self.resource_group_name, | ||
factory_name=self.factory_name, | ||
poke_interval=self.poke_interval, | ||
), | ||
method_name="execute_complete", | ||
) | ||
|
||
def execute_complete(self, context: Context, event: Dict[str, str]) -> None: | ||
""" | ||
Callback for when the trigger fires - returns immediately. | ||
Relies on trigger to throw an exception, otherwise it assumes execution was | ||
successful. | ||
""" | ||
if event: | ||
if event["status"] == "error": | ||
raise_error_or_skip_exception(self.soft_fail, event["message"]) | ||
self.log.info(event["message"]) | ||
super().__init__(*args, deferrable=True, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters