Selaa lähdekoodia

HUE-7275 [jb] Extract / Compress job has wrong timestamps and task names

krish 8 vuotta sitten
vanhempi
commit
9d6a754

+ 3 - 1
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1664,6 +1664,7 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
         $.post("/filebrowser/extract_archive", {
           "archive_name": self.selectedFile().name,
           "upload_path": self.currentPath(),
+          "start_time": ko.mapping.toJSON((new Date()).getTime())
         }, function (data) {
           if (data.status == 0) {
             $.jHueNotify.info("${ _('Task ') }" + data.history_uuid + "${_(' submitted.') }");
@@ -1698,7 +1699,8 @@ from filebrowser.conf import ENABLE_EXTRACT_UPLOADED_ARCHIVE
         $.post("/filebrowser/compress_files", {
           "files": fileNames,
           "upload_path": self.currentPath(),
-          "archive_name": self.compressArchiveName()
+          "archive_name": self.compressArchiveName(),
+          "start_time": ko.mapping.toJSON((new Date()).getTime())
         }, function (data) {
           if (data.status == 0) {
             $.jHueNotify.info("${ _('Task ') }" + data.history_uuid + "${_(' submitted.') }");

+ 6 - 2
desktop/core/src/desktop/lib/tasks/compress_files/compress_utils.py

@@ -15,6 +15,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import json
+
 from django.core.urlresolvers import reverse
 from django.utils.translation import ugettext as _
 
@@ -29,9 +31,10 @@ def compress_files_in_hdfs(request, file_names, upload_path, archive_name):
 
   files = [{"value": upload_path + '/' + file_name} for file_name in file_names]
   files.append({'value': '/user/' + DEFAULT_USER.get() + '/common/compress_files_in_hdfs.sh'})
+  start_time = json.loads(request.POST.get('start_time', '-1'))
 
   shell_notebook = Notebook(
-    description=_('HDFS Compression to %(upload_path)s/hue_compressed.zip') % {'upload_path': upload_path},
+    name=_('HDFS Compression to %(upload_path)s/hue_compressed.zip') % {'upload_path': upload_path},
     isManaged=True,
     onSuccessUrl=reverse('filebrowser.views.view', kwargs={'path': upload_path})
   )
@@ -41,7 +44,8 @@ def compress_files_in_hdfs(request, file_names, upload_path, archive_name):
       arguments=[{'value': '-u=' + upload_path}, {'value': '-f=' + ','.join(file_names)}, {'value': '-n=' + archive_name}],
       archives=[],
       files=files,
-      env_var=[{'value': 'HADOOP_USER_NAME=${wf:user()}'}]
+      env_var=[{'value': 'HADOOP_USER_NAME=${wf:user()}'}],
+      last_executed=start_time
   )
 
   return shell_notebook.execute(request, batch=True)

+ 5 - 2
desktop/core/src/desktop/lib/tasks/extract_archive/extract_utils.py

@@ -15,6 +15,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import json
 import urllib
 
 from django.core.urlresolvers import reverse
@@ -30,9 +31,10 @@ def extract_archive_in_hdfs(request, upload_path, file_name):
   _upload_extract_archive_script_to_hdfs(request.fs)
 
   output_path = upload_path + '/' + file_name.split('.')[0]
+  start_time = json.loads(request.POST.get('start_time', '-1'))
 
   shell_notebook = Notebook(
-      description=_('HDFS Extraction of %(upload_path)s/%(file_name)s') % {'upload_path': upload_path, 'file_name': file_name},
+      name=_('HDFS Extraction of %(upload_path)s/%(file_name)s') % {'upload_path': upload_path, 'file_name': file_name},
       isManaged=True,
       onSuccessUrl=reverse('filebrowser.views.view', kwargs={'path': output_path})
   )
@@ -42,7 +44,8 @@ def extract_archive_in_hdfs(request, upload_path, file_name):
       arguments=[{'value': '-u=' + upload_path}, {'value': '-f=' + file_name}, {'value': '-o=' + output_path}],
       archives=[],
       files=[{'value': '/user/' + DEFAULT_USER.get() + '/common/extract_archive_in_hdfs.sh'}, {"value": upload_path + '/' + urllib.quote(file_name)}],
-      env_var=[{'value': 'HADOOP_USER_NAME=${wf:user()}'}]
+      env_var=[{'value': 'HADOOP_USER_NAME=${wf:user()}'}],
+      last_executed=start_time
   )
 
   return shell_notebook.execute(request, batch=True)

+ 6 - 4
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -154,7 +154,7 @@ class Notebook(object):
 
     self.data = json.dumps(_data)
 
-  def add_shell_snippet(self, shell_command, arguments, archives, files, env_var):
+  def add_shell_snippet(self, shell_command, arguments, archives, files, env_var, last_executed):
     _data = json.loads(self.data)
 
     _data['snippets'].append(self._make_snippet({
@@ -166,8 +166,9 @@ class Notebook(object):
           u'arguments': arguments,
           u'archives': archives,
           u'env_var': env_var,
-          'command_path': shell_command,
-        }
+          u'command_path': shell_command
+        },
+        u'lastExecuted': last_executed
     }))
     self._add_session(_data, 'shell')
 
@@ -184,7 +185,8 @@ class Notebook(object):
          'name': _snippet.get('name', '%(type)s snippet' % _snippet),
          'database': _snippet.get('database'),
          'result': {},
-         'variables': []
+         'variables': [],
+         'lastExecuted': _snippet.get('lastExecuted')
     }
 
   def _add_session(self, data, snippet_type):