milton0825 commented on a change in pull request #5059: [AIRFLOW-161] New 
redirect route and extra links
URL: https://github.com/apache/airflow/pull/5059#discussion_r274774742
 
 

 ##########
 File path: airflow/contrib/hooks/qubole_hook.py
 ##########
 @@ -207,6 +210,30 @@ def get_jobs_id(self, ti):
             cmd_id = ti.xcom_pull(key="qbol_cmd_id", task_ids=self.task_id)
         Command.get_jobs_id(self.cls, cmd_id)
 
+    def get_extra_links(self, task, dttm):
+        log = LoggingMixin().log
+        session = settings.Session()
+        url = ''
+
+        try:
+            conn = BaseHook.get_connection(task.kwargs['qubole_conn_id'])
+            if conn and conn.host:
+                host = re.sub(r'api$', 'v2/analyze?command_id=', conn.host)
+            else:
+                host = 'https://api.qubole.com/v2/analyze?command_id='
+
+            ti = TaskInstance(task=task, execution_date=dttm)
+            qds_command_id = ti.xcom_pull(task_ids=task.task_id, 
key='qbol_cmd_id')
+
+            url = host + str(qds_command_id) if qds_command_id else ''
+        except Exception as e:
+            log.warning('Could not find the url to redirect. Error: %s' % 
str(e))
 
 Review comment:
   Taking a closer look and I think we don't need the `try...except` and we can 
probably remote the `Session`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to