瀏覽代碼

HUE-4414 [editor] Allow to send queries even after closing the session

Clicking on Close session goes to a dead end. Now we still allow the automatically
created new session to be used.

Ideally we will update the UI instead of not displaying the new session at some point.

Note that the session can be closed already if HiveServer2 or Hue were restarted before
clicking on the Close button.

Restart Button works well.
Romain Rigaux 9 年之前
父節點
當前提交
655de2f092

+ 5 - 4
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -492,9 +492,10 @@ class HS2Api(Api):
     if not settings:
     if not settings:
       session = self._get_session(notebook, 'hive')
       session = self._get_session(notebook, 'hive')
       if not session:
       if not session:
-        raise Exception(_('Cannot get jobs, failed to find active HS2 session for user: %s') % self.user.username)
-      properties = session['properties']
-      settings = next((prop['value'] for prop in properties if prop['key'] == 'settings'), None)
+        LOG.warn('Cannot get jobs, failed to find active HS2 session for user: %s' % self.user.username)
+      else:
+        properties = session['properties']
+        settings = next((prop['value'] for prop in properties if prop['key'] == 'settings'), None)
 
 
     if settings:
     if settings:
       engine = next((setting['value'] for setting in settings if setting['key'] == 'hive.execution.engine'), DEFAULT_HIVE_ENGINE)
       engine = next((setting['value'] for setting in settings if setting['key'] == 'hive.execution.engine'), DEFAULT_HIVE_ENGINE)
@@ -558,7 +559,7 @@ class HS2Api(Api):
     settings = snippet['properties'].get('settings', None)
     settings = snippet['properties'].get('settings', None)
     file_resources = snippet['properties'].get('files', None)
     file_resources = snippet['properties'].get('files', None)
     functions = snippet['properties'].get('functions', None)
     functions = snippet['properties'].get('functions', None)
-    properties = session['properties']
+    properties = session['properties'] if session else []
 
 
     # Get properties from session if not defined in snippet
     # Get properties from session if not defined in snippet
     if not settings:
     if not settings:

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1005,7 +1005,7 @@ ${ hueIcons.symbols() }
             <form class="form-horizontal session-config">
             <form class="form-horizontal session-config">
               <fieldset>
               <fieldset>
                 <!-- ko ifnot: sessions().length -->
                 <!-- ko ifnot: sessions().length -->
-               <p>${ _('There are currently no active sessions.') }</p>
+               <p>${ _('There are currently no active sessions, please reload the page.') }</p>
                <!-- /ko -->
                <!-- /ko -->
                <!-- ko foreach: sessions -->
                <!-- ko foreach: sessions -->
                <h4 data-bind="text: $root.getSnippetName(type())" style="clear:left; display: inline-block"></h4>
                <h4 data-bind="text: $root.getSnippetName(type())" style="clear:left; display: inline-block"></h4>