You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/16 08:21:33 UTC

[GitHub] [airflow] ciancolo commented on a change in pull request #17034: Refactored waiting function for Tableau Jobs

ciancolo commented on a change in pull request #17034:
URL: https://github.com/apache/airflow/pull/17034#discussion_r671059904



##########
File path: airflow/providers/tableau/hooks/tableau.py
##########
@@ -133,3 +138,28 @@ def get_all(self, resource_name: str) -> Pager:
         except AttributeError:
             raise ValueError(f"Resource name {resource_name} is not found.")
         return Pager(resource.get)
+
+    def get_job_status(self, job_id: str) -> Enum:
+        """
+        Get the current state of a defined Tableau Job.
+        .. see also:: https://tableau.github.io/server-client-python/docs/api-ref#jobs
+
+        :param job_id: The id of the job to check.
+        :type job_id: str
+        :rtype: Enum
+        """
+        return TableauJobFinishCode(int(self.server.jobs.get_by_id(job_id).finish_code))
+
+    def waiting_until_succeeded(self, job_id: str) -> bool:
+        """
+        Wait until the current state of a defined Tableau Job is not PENDING.
+        :param job_id: The id of the job to check.
+        :type job_id: str
+        :return: return True if the job has SUCCESS status, False otherwise.
+        :rtype: bool
+        """
+        finish_code = TableauJobFinishCode.PENDING
+        while finish_code == TableauJobFinishCode.PENDING:
+            finish_code = self.get_job_status(job_id=job_id)

Review comment:
       Yeah you're right especially for a long refresh. But now I am a little bit confused, the original request was to remove the sensor from the operator and to implement the waiting code in the hook. But why just not use the sensor and the already implemented poke function instead to create a new one?
   
   What do you think?




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org