Переглянути джерело

HUE-4327 [editor] Disable batch submit by default when oozie is not setup

Of by setting up the flag to off.
Romain Rigaux 9 роки тому
батько
коміт
210b57a

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -580,6 +580,9 @@
   ## Show the notebook menu or not
   # show_notebooks=true
 
+  ## Flag to enable the bulk submission of queries as a background task through Oozie.
+  # enable_batch_execute=true
+
   ## Base URL to Remote GitHub Server
   # github_remote_url=https://github.com
 

+ 3 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -588,6 +588,9 @@
   ## Show the notebook menu or not
   # show_notebooks=true
 
+  ## Flag to enable the bulk submission of queries as a background task through Oozie.
+  # enable_batch_execute=true
+
   ## Base URL to Remote GitHub Server
   # github_remote_url=https://github.com
 

+ 14 - 1
desktop/libs/notebook/src/notebook/conf.py

@@ -22,11 +22,12 @@ except ImportError:
 
 from django.utils.translation import ugettext_lazy as _t
 
+from desktop import appmanager
 from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection,\
   coerce_json_dict, coerce_string, coerce_bool
 
 
-def get_interpreters(user=None):  
+def get_interpreters(user=None):
   if not INTERPRETERS.get():
     _default_interpreters()
 
@@ -40,6 +41,10 @@ def get_interpreters(user=None):
       for i in interpreters
   ]
 
+def is_oozie_enabled():
+  """Oozie needs to be available as it is the backend."""
+  return len([app for app in appmanager.DESKTOP_MODULES if app.name == 'oozie']) > 0
+
 
 SHOW_NOTEBOOKS = Config(
     key="show_notebooks",
@@ -97,6 +102,14 @@ ENABLE_QUERY_SCHEDULING = Config(
   default=True
 )
 
+ENABLE_BATCH_EXECUTE = Config(
+  key="enable_batch_execute",
+  help=_t("Flag to enable the bulk submission of queries as a background task through Oozie."),
+  type=bool,
+  dynamic_default=is_oozie_enabled
+)
+
+
 GITHUB_REMOTE_URL = Config(
     key="github_remote_url",
     help=_t("Base URL to GitHub Remote Server"),

+ 6 - 2
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -15,11 +15,13 @@
 ## limitations under the License.
 
 <%!
+from django.utils.translation import ugettext as _
+
 from desktop import conf
 from desktop.lib.i18n import smart_unicode
-from django.utils.translation import ugettext as _
 from desktop.views import _ko
-from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING
+
+from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_BATCH_EXECUTE
 %>
 
 <%namespace name="require" file="/require.mako" />
@@ -1834,6 +1836,7 @@ ${ hueIcons.symbols() }
         <i class="fa fa-fw fa-play" data-bind="css: { 'snippet-side-single' : type() !== 'hive' }"></i>
       </a>
       <!-- /ko -->
+      % if ENABLE_BATCH_EXECUTE.get():
       <!-- ko if: type() == 'hive' && status() != 'running' && status() != 'loading' -->
         <a class="dropdown-toggle snippet-side-btn" style="padding:0" data-toggle="dropdown" href="javascript: void(0)" data-bind="css: {'disabled': statement() === '', 'blue': currentQueryTab() == 'queryExplain' }">
           <i class="fa fa-caret-down"></i>
@@ -1851,6 +1854,7 @@ ${ hueIcons.symbols() }
           </li>
         </ul>
       <!-- /ko -->
+      % endif
     </div>
 
     <!-- ko if: isSqlDialect -->