Преглед изворни кода

HUE-8758 [connectors] Preparing config check for connectors

Romain пре 5 година
родитељ
комит
724937f2d6

+ 2 - 2
apps/beeswax/src/beeswax/server/dbms.py

@@ -50,9 +50,9 @@ from beeswax.models import QueryHistory, QUERY_TYPES
 
 
 if sys.version_info[0] > 2:
-    from django.utils.encoding import force_text as force_unicode
+  from django.utils.encoding import force_text as force_unicode
 else:
-    from django.utils.encoding import force_unicode
+  from django.utils.encoding import force_unicode
 
 
 LOG = logging.getLogger(__name__)

+ 10 - 6
apps/hive/src/hive/conf.py

@@ -29,21 +29,25 @@ from beeswax.settings import NICE_NAME
 LOG = logging.getLogger(__name__)
 
 
-#
-# All the configuration happens in apps/beeswax.
-#
+'''
+v2
+When using the connectors, now 'hive' is seen as a dialect and only the list of connections
+(instance of the 'hive' connector, e.g. pointing to a Hive server in the Cloud) should be tested.
+The Editor/Notebook app is the one testing it.
 
+v1
+All the configuration happens in apps/beeswax.
+'''
 
 def config_validator(user):
-  # dbms is dependent on beeswax.conf (this file)
-  # import in method to avoid circular dependency
+  # dbms is dependent on beeswax.conf, import in method to avoid circular dependency
   from beeswax.design import hql_query
   from beeswax.server import dbms
 
   res = []
   try:
     try:
-      if not 'test' in sys.argv: # Avoid tests hanging
+      if not 'test' in sys.argv:  # Avoid tests hanging
         server = dbms.get(user)
         query = hql_query("SELECT 'Hello World!';")
         handle = server.execute_and_wait(query, timeout_sec=10.0)

+ 2 - 3
desktop/core/src/desktop/views.py

@@ -591,7 +591,7 @@ def _get_config_errors(request, cache=True):
   global _CONFIG_ERROR_LIST
 
   if not cache or _CONFIG_ERROR_LIST is None:
-    error_list = [ ]
+    error_list = []
     for module in appmanager.DESKTOP_MODULES:
       # Get the config_validator() function
       try:
@@ -600,8 +600,7 @@ def _get_config_errors(request, cache=True):
         continue
 
       if not callable(validator):
-        LOG.warn("Auto config validation: %s.%s is not a function" %
-                 (module.conf.__name__, CONFIG_VALIDATOR))
+        LOG.warn("Auto config validation: %s.%s is not a function" % (module.conf.__name__, CONFIG_VALIDATOR))
         continue
 
       try:

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

@@ -37,7 +37,7 @@ def _remove_duplications(a_list):
 def check_permissions(user, interpreter, user_apps=None):
   # TODO: port to cluster config
   if user_apps is None:
-    user_apps = appmanager.get_apps_dict(user) # Expensive method
+    user_apps = appmanager.get_apps_dict(user)  # Expensive method
   return (interpreter == 'hive' and 'hive' not in user_apps) or \
          (interpreter == 'impala' and 'impala' not in user_apps) or \
          (interpreter == 'pig' and 'pig' not in user_apps) or \

+ 6 - 1
desktop/libs/notebook/src/notebook/tests.py

@@ -575,7 +575,12 @@ class TestEditor(object):
 
   def test_open_saved_impala_query_when_no_hive_interepreter(self):
     try:
-      doc, created = Document2.objects.get_or_create(name='open_saved_query_with_hive_not_present', type='query-impala', owner=self.user, data={})
+      doc, created = Document2.objects.get_or_create(
+          name='open_saved_query_with_hive_not_present',
+          type='query-impala',
+          owner=self.user,
+          data={}
+      )
 
       with patch('desktop.middleware.fsmanager') as fsmanager:
         response = self.client.get(reverse('notebook:editor'), {'editor': doc.id, 'is_embeddable': True})

+ 10 - 3
desktop/libs/notebook/src/notebook/views.py

@@ -53,12 +53,20 @@ def notebooks(request):
     if USE_NEW_EDITOR.get():
       notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['query-%s' % editor_type])]
     else:
-      notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra__startswith='query')) if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type]
+      notebooks = [
+        d.content_object.to_dict()
+          for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra__startswith='query'))
+          if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type
+      ]
   else:
     if USE_NEW_EDITOR.get():
       notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['notebook'])]
     else:
-      notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook')) if not d.content_object.is_history]
+      notebooks = [
+        d.content_object.to_dict()
+          for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook'))
+          if not d.content_object.is_history
+      ]
 
   return render('notebooks.mako', request, {
       'notebooks_json': json.dumps(notebooks, cls=JSONEncoderForHTML),
@@ -181,7 +189,6 @@ def browse(request, database, table, partition_spec=None):
         namespace=namespace,
         compute=compute
     )
-
     return render('editor.mako', request, {
         'notebooks_json': json.dumps([editor.get_data()]),
         'options_json': json.dumps({