amoghrajesh commented on code in PR #77162:
URL: https://github.com/apache/airflow/pull/77162#discussion_r4595839340
##########
providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_data_factory.py:
##########
@@ -496,3 +501,140 @@ def
test_azure_data_factory_run_pipeline_operator_async_execute_complete_fail(se
context={},
event={"status": "error", "message": "error", "run_id":
AZ_PIPELINE_RUN_ID},
)
+
+
[email protected](not AIRFLOW_V_3_3_PLUS, reason="The task state store
arrived in Airflow 3.3")
+class TestAzureDataFactoryRunPipelineOperatorDurable:
+ CONFIG = {
+ "task_id": TASK_ID,
+ "azure_data_factory_conn_id": AZURE_DATA_FACTORY_CONN_ID,
+ "pipeline_name": PIPELINE_NAME,
+ "resource_group_name": "resource-group-name",
+ "factory_name": "factory-name",
+ "check_interval": 1,
+ "timeout": 3,
+ }
+
+ @pytest.fixture(autouse=True)
+ def setup_mocks(self):
+ with (
+ patch.object(
+ AzureDataFactoryHook,
+ "run_pipeline",
+ autospec=True,
+ return_value=MagicMock(run_id=NEW_RUN_ID),
Review Comment:
Handled in 42864afd983
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/data_factory.py:
##########
@@ -181,11 +199,28 @@ def execute(self, context: Context) -> None:
start_from_failure=self.start_from_failure,
parameters=self.parameters,
)
- self.run_id = response.run_id
- # Push the ``run_id`` value to XCom regardless of what happens during
execution. This allows for
- # retrieval the executed pipeline's ``run_id`` for downstream tasks
especially if performing an
- # asynchronous wait.
- context["ti"].xcom_push(key="run_id", value=self.run_id)
+ self._record_run_id(response.run_id, context)
+ return response.run_id
+
+ def get_job_status(self, external_id: JsonValue, context: Context) -> str:
+ try:
+ return self.hook.get_pipeline_run_status(
+ str(external_id), self.resource_group_name, self.factory_name
+ )
+ except ResourceNotFoundError:
+ return "NotFound"
+
+ def is_job_active(self, status: str) -> bool:
+ return self.wait_for_termination and status in
AzureDataFactoryPipelineRunStatus.INTERMEDIATE_STATES
+
+ def is_job_succeeded(self, status: str) -> bool:
+ # Without wait_for_termination a retry does not wait for a run in
progress either.
+ return status == AzureDataFactoryPipelineRunStatus.SUCCEEDED or (
+ not self.wait_for_termination and status in
AzureDataFactoryPipelineRunStatus.INTERMEDIATE_STATES
Review Comment:
Handled in 42864afd983
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/data_factory.py:
##########
@@ -181,11 +199,28 @@ def execute(self, context: Context) -> None:
start_from_failure=self.start_from_failure,
parameters=self.parameters,
)
- self.run_id = response.run_id
- # Push the ``run_id`` value to XCom regardless of what happens during
execution. This allows for
- # retrieval the executed pipeline's ``run_id`` for downstream tasks
especially if performing an
- # asynchronous wait.
- context["ti"].xcom_push(key="run_id", value=self.run_id)
+ self._record_run_id(response.run_id, context)
+ return response.run_id
+
+ def get_job_status(self, external_id: JsonValue, context: Context) -> str:
+ try:
+ return self.hook.get_pipeline_run_status(
+ str(external_id), self.resource_group_name, self.factory_name
+ )
+ except ResourceNotFoundError:
+ return "NotFound"
+
+ def is_job_active(self, status: str) -> bool:
+ return self.wait_for_termination and status in
AzureDataFactoryPipelineRunStatus.INTERMEDIATE_STATES
Review Comment:
Handled in 42864afd983
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/data_factory.py:
##########
@@ -181,11 +199,28 @@ def execute(self, context: Context) -> None:
start_from_failure=self.start_from_failure,
parameters=self.parameters,
)
- self.run_id = response.run_id
- # Push the ``run_id`` value to XCom regardless of what happens during
execution. This allows for
- # retrieval the executed pipeline's ``run_id`` for downstream tasks
especially if performing an
- # asynchronous wait.
- context["ti"].xcom_push(key="run_id", value=self.run_id)
+ self._record_run_id(response.run_id, context)
Review Comment:
Handled in 42864afd983
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/data_factory.py:
##########
@@ -163,13 +177,17 @@ def __init__(
self.timeout = timeout
self.check_interval = check_interval
self.deferrable = deferrable
+ self.run_id: str | None = None
Review Comment:
Handled in 42864afd983
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]