henry3260 commented on code in PR #63829:
URL: https://github.com/apache/airflow/pull/63829#discussion_r3295148991
##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/powerbi.py:
##########
@@ -121,40 +120,56 @@ def api_version(self) -> str | None:
def execute(self, context: Context):
"""Refresh the Power BI Dataset."""
- if not self.wait_for_completion:
- # Fire and forget - synchronous execution, no deferral
- hook = PowerBIHook(
- conn_id=self.conn_id, proxies=self.proxies,
api_version=self.api_version, timeout=self.timeout
- )
-
- dataset_refresh_id = hook.trigger_dataset_refresh(
- dataset_id=self.dataset_id,
+ self.defer(
+ trigger=PowerBITrigger(
+ conn_id=self.conn_id,
group_id=self.group_id,
+ dataset_id=self.dataset_id,
+ timeout=self.timeout,
+ proxies=self.proxies,
+ api_version=self.api_version,
+ check_interval=self.check_interval,
+ wait_for_termination=False,
request_body=self.request_body,
+ ),
+ method_name=self.handle_refresh.__name__,
+ )
+
+ def handle_refresh(self, context: Context, event: dict[str, str] | None)
-> None:
+ """
+ Handle refresh-trigger event and optionally defer again to wait for
refresh completion.
+
+ :param context: Airflow context dictionary
+ :param event: Event dict from trigger with status and
dataset_refresh_id
+ """
+ if not event:
+ return
+
+ dataset_refresh_id = event.get("dataset_refresh_id")
+ if dataset_refresh_id:
+ context["ti"].xcom_push(
Review Comment:
> Isn’t there a direct wcom_push method available on the operator instead of
going via context[“ti”]?
I checked `xcom_push `is available on the runtime task instance
(`context["ti"]`), not on BaseOperator, so `context["ti"].xcom_push(...)` is
intentional here.
This is also consistent with the other XCom pushes in this operator, for
example:
https://github.com/apache/airflow/blob/428c5d285ac07b92a16216b6e78439102fe000c8/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/powerbi.py#L254-L257
--
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]