Browse Source

HUE-9705 [Django Upgrade] Remove old unused commit option to loaddata.handle

ayush.goyal 4 years ago
parent
commit
e74502c722
2 changed files with 11 additions and 7 deletions
  1. 1 1
      desktop/core/requirements.txt
  2. 10 6
      desktop/core/src/desktop/api2.py

+ 1 - 1
desktop/core/requirements.txt

@@ -18,7 +18,7 @@ django-crequest==2018.5.11
 django-debug-panel==0.8.3
 django-debug-panel==0.8.3
 django-debug-toolbar==1.9.1
 django-debug-toolbar==1.9.1
 django-extensions==1.8.0
 django-extensions==1.8.0
-django-nose==1.4.5
+django-nose==1.4.7
 django_opentracing==1.1.0
 django_opentracing==1.1.0
 django_prometheus==1.0.15
 django_prometheus==1.0.15
 django-webpack-loader==0.5.0
 django-webpack-loader==0.5.0

+ 10 - 6
desktop/core/src/desktop/api2.py

@@ -37,7 +37,8 @@ from django.views.decorators.csrf import ensure_csrf_cookie
 from django.views.decorators.http import require_POST
 from django.views.decorators.http import require_POST
 
 
 from metadata.conf import has_catalog
 from metadata.conf import has_catalog
-from metadata.catalog_api import search_entities as metadata_search_entities, _highlight, search_entities_interactive as metadata_search_entities_interactive
+from metadata.catalog_api import search_entities as metadata_search_entities, _highlight, \
+  search_entities_interactive as metadata_search_entities_interactive
 from notebook.connectors.altus import SdxApi, AnalyticDbApi, DataEngApi, DataWarehouse2Api
 from notebook.connectors.altus import SdxApi, AnalyticDbApi, DataEngApi, DataWarehouse2Api
 from notebook.connectors.base import Notebook, get_interpreter
 from notebook.connectors.base import Notebook, get_interpreter
 from notebook.models import Analytics
 from notebook.models import Analytics
@@ -188,7 +189,8 @@ def get_context_namespaces(request, interface):
         sdx_namespaces = SdxApi(request.user).list_namespaces()
         sdx_namespaces = SdxApi(request.user).list_namespaces()
 
 
       # Adding "fake" namespace for cluster without one
       # Adding "fake" namespace for cluster without one
-      sdx_namespaces.extend([_cluster for _cluster in adb_clusters if not _cluster.get('namespaceCrn') or (IS_K8S_ONLY.get() and 'TERMINAT' not in _cluster['status'])])
+      sdx_namespaces.extend([_cluster for _cluster in adb_clusters if not _cluster.get('namespaceCrn') or \
+        (IS_K8S_ONLY.get() and 'TERMINAT' not in _cluster['status'])])
 
 
       namespaces.extend([{
       namespaces.extend([{
           'id': namespace.get('crn', 'None'),
           'id': namespace.get('crn', 'None'),
@@ -774,7 +776,9 @@ def export_documents(request):
 
 
   if doc_ids:
   if doc_ids:
     doc_ids = ','.join(map(str, doc_ids))
     doc_ids = ','.join(map(str, doc_ids))
-    management.call_command('dumpdata', 'desktop.Document2', primary_keys=doc_ids, indent=2, use_natural_foreign_keys=True, verbosity=2, stdout=f)
+    management.call_command(
+      'dumpdata', 'desktop.Document2', primary_keys=doc_ids, indent=2, use_natural_foreign_keys=True, verbosity=2, stdout=f
+    )
 
 
   if request.GET.get('format') == 'json':
   if request.GET.get('format') == 'json':
     return JsonResponse(f.getvalue(), safe=False)
     return JsonResponse(f.getvalue(), safe=False)
@@ -860,7 +864,7 @@ def import_documents(request):
   stdout = string_io()
   stdout = string_io()
   try:
   try:
     with transaction.atomic(): # We wrap both commands to commit loaddata & sync
     with transaction.atomic(): # We wrap both commands to commit loaddata & sync
-      management.call_command('loaddata', f.name, verbosity=3, traceback=True, stdout=stdout, commit=False) # We need to use commit=False because commit=True will close the connection and make Document.objects.sync fail.
+      management.call_command('loaddata', f.name, verbosity=3, traceback=True, stdout=stdout)
       Document.objects.sync()
       Document.objects.sync()
 
 
     if request.POST.get('redirect'):
     if request.POST.get('redirect'):
@@ -1158,8 +1162,8 @@ def _create_or_update_document_with_owner(doc, owner, uuids_map):
     history_deps_list = []
     history_deps_list = []
     for index, (uuid, version, is_history) in enumerate(doc['fields']['dependencies']):
     for index, (uuid, version, is_history) in enumerate(doc['fields']['dependencies']):
       if not uuid in list(uuids_map.keys()) and not is_history and \
       if not uuid in list(uuids_map.keys()) and not is_history and \
-              not Document2.objects.filter(uuid=uuid, version=version).exists():
-          raise PopupException(_('Cannot import document, dependency with UUID: %s not found.') % uuid)
+      not Document2.objects.filter(uuid=uuid, version=version).exists():
+        raise PopupException(_('Cannot import document, dependency with UUID: %s not found.') % uuid)
       elif is_history:
       elif is_history:
         history_deps_list.insert(0, index) # Insert in decreasing order to facilitate delete
         history_deps_list.insert(0, index) # Insert in decreasing order to facilitate delete
         LOG.warn('History dependency with UUID: %s ignored while importing document %s' % (uuid, doc['fields']['name']))
         LOG.warn('History dependency with UUID: %s ignored while importing document %s' % (uuid, doc['fields']['name']))