frodo2000 opened a new issue, #76711:
URL: https://github.com/apache/airflow/issues/76711

   ### Description
   
   PowerBI offers manual refresh capability which could block API refresh. 
Current operator implementation doesn't support wait_for_termination for manual 
refresh which is performed during API refresh startup.
   
   Some idea to extension below (of course could be implemented with some flag 
in current operator aswell):
   ```
   class PowerBIDatasetRefreshWithWaitOperator(PowerBIDatasetRefreshOperator):
   
       def submit_job(self, context):
         
           histories = self.hook.run_sync(
               self.hook.get_refresh_history(
                   dataset_id=self.dataset_id,
                   group_id=self.group_id,
               )
           )
   
           if histories:
               latest = histories[0]  # Power BI zwraca od najnowszych
               status = latest.get(PowerBIDatasetRefreshFields.STATUS.value)
               request_id = 
latest.get(PowerBIDatasetRefreshFields.REQUEST_ID.value)
   
               if status == PowerBIDatasetRefreshStatus.IN_PROGRESS:
                   self.log.info(
                       "Existing refresh %s is in progress — waiting for it to 
finish",
                       request_id,
                   )
   
                   self.defer(
                       trigger=PowerBITrigger(
                           conn_id=self.conn_id,
                           group_id=self.group_id,
                           dataset_id=self.dataset_id,
                           dataset_refresh_id=request_id,
                           timeout=self.timeout,
                           check_interval=self.check_interval,
                           wait_for_termination=True,
                           proxies=self.proxies,
                           api_version=self.api_version,
                       ),
                       method_name="on_existing_refresh_finished",
                   )
                   return 
   
           return super().submit_job(context)
   
       def on_existing_refresh_finished(self, context, event):
           if not event or event.get("status") == "error":
               raise AirflowException(
                   event.get("message", "Existing refresh failed or timed out")
               )
   
           self.log.info(
               "Existing refresh finished with status %s — triggering new one",
               event.get("dataset_refresh_status"),
           )
   
           return self.submit_job(context)  
   ```
   
   ### Use case/motivation
   
   _No response_
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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]

Reply via email to