瀏覽代碼

HUE-1176 [history] Skeleton to display submitted tasks in the UI

Romain Rigaux 9 年之前
父節點
當前提交
2996c4b

+ 2 - 2
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -1617,9 +1617,9 @@ from django.utils.translation import ugettext as _
           if (data.status == 0) {
             var jobId = '';
             if (data.handle) {
-              jobId = data.handle.id;
+              jobId = data.history_id;
             }
-            $.jHueNotify.info("${ _('Oozie job ') }" + jobId + "${_(' submitted for archive extraction.') }");
+            $.jHueNotify.info("${ _('Task ') }" + jobId + "${_(' submitted for archive extraction.') }");
           } else {
             $(document).trigger("error", data.message);
           }

+ 1 - 1
apps/jobbrowser/src/jobbrowser/apis/batch_api.py

@@ -49,7 +49,7 @@ class BatchApi(Api):
         'progress': 100,
         'duration': 10 * 3600,
         'submitted': 10 * 3600
-    } for app in wf_list.jobs if app.appName.startswith(OozieApi.BATCH_JOB_PREFIX)]
+    } for app in wf_list.jobs] # if app.appName.startswith(OozieApi.BATCH_JOB_PREFIX)]
 
   def app(self, appid):
     oozie_api = get_oozie(self.user)

+ 1 - 1
apps/jobbrowser/src/jobbrowser/templates/apps.mako

@@ -130,7 +130,7 @@ ${ assist.assistPanel() }
 
             <span class="form-inline">
               <input class="btn btn-status" type="radio" name="interface" value="jobs" data-bind="checked: interface" id="jobs"><label for="jobs">${ _('Jobs') }</label>
-              <input class="btn btn-status" type="radio" name="interface" value="batches" data-bind="checked: interface" id="batches"><label for="batches">${ _('Batches') }</label>
+              <input class="btn btn-status" type="radio" name="interface" value="batches" data-bind="checked: interface" id="batches"><label for="batches">${ _('Workflows') }</label>
               <input class="btn btn-status" type="radio" name="interface" value="schedules" data-bind="checked: interface" id="schedules"><label for="schedules">${ _('Schedules') }</label>
             </span>
 

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

@@ -15,24 +15,33 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from notebook.connectors.base import Notebook
+from django.utils.translation import ugettext as _
+
 from desktop.conf import DEFAULT_USER
 from desktop.lib.paths import get_desktop_root
 
+from notebook.connectors.base import Notebook
 
-def extract_archive_in_hdfs(request, upload_path, file_name):
 
+def extract_archive_in_hdfs(request, upload_path, file_name):
   _upload_extract_archive_script_to_hdfs(request.fs)
 
-  shell_notebook = Notebook()
+  shell_notebook = Notebook(
+      description=_('HDFS Extraction of %(upload_path)s/%(file_name)s') % {'upload_path': upload_path, 'file_name': file_name},
+      isManaged=True
+  )
+
   shell_notebook.add_shell_snippet(
       shell_command='extract_archive_in_hdfs.sh',
       arguments=[{'value': '-u=' + upload_path}, {'value': '-f=' + file_name}],
       archives=[],
       files=[{'value': '/user/' + DEFAULT_USER.get() + '/common/extract_archive_in_hdfs.sh'}, {"value": upload_path + '/' + file_name}],
-      env_var=[{'value': 'HADOOP_USER_NAME=${wf:user()}'}])
+      env_var=[{'value': 'HADOOP_USER_NAME=${wf:user()}'}]
+  )
+
   return shell_notebook.execute(request, batch=True)
 
+
 def _upload_extract_archive_script_to_hdfs(fs):
   if not fs.exists('/user/' + DEFAULT_USER.get() + '/common/'):
     fs.do_as_user(DEFAULT_USER.get(), fs.mkdir, '/user/' + DEFAULT_USER.get() + '/common/')
@@ -41,4 +50,4 @@ def _upload_extract_archive_script_to_hdfs(fs):
   if not fs.do_as_user(DEFAULT_USER.get(), fs.exists, '/user/' + DEFAULT_USER.get() + '/common/extract_archive_in_hdfs.sh'):
     fs.do_as_user(DEFAULT_USER.get(), fs.copyFromLocal, get_desktop_root() + '/core/src/desktop/lib/tasks/extract_archive/extract_in_hdfs.sh',
                           '/user/' + DEFAULT_USER.get() + '/common/extract_archive_in_hdfs.sh')
-    fs.do_as_user(DEFAULT_USER.get(), fs.chmod, '/user/' + DEFAULT_USER.get() + '/common/', 0755)
+    fs.do_as_user(DEFAULT_USER.get(), fs.chmod, '/user/' + DEFAULT_USER.get() + '/common/', 0755)

+ 13 - 7
desktop/core/src/desktop/templates/responsive.mako

@@ -14,11 +14,13 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 <%!
+  from django.utils.translation import ugettext as _
+
   from desktop import conf
   from desktop.views import _ko
-  from django.utils.translation import ugettext as _
   from desktop.lib.i18n import smart_unicode
   from desktop.views import login_modal
+
   from metadata.conf import has_optimizer, OPTIMIZER
 %>
 
@@ -45,7 +47,6 @@
   <link href="${ static('desktop/css/jquery-ui.css') }" rel="stylesheet">
 
   ${ commonHeaderFooterComponents.header_i18n_redirection(user, is_s3_enabled, apps) }
-
 </head>
 
 <body>
@@ -202,7 +203,12 @@ ${ hueIcons.symbols() }
           <button class="btn" title="${_('Submission history')}" data-bind="toggle: historyPanelVisible"><i class="fa fa-history"></i>  <div class="jobs-badge">20</div></button>
         </div>
         <div class="jobs-panel" data-bind="visible: historyPanelVisible" style="display: none;">
-          <span style="font-size: 15px; font-weight: 300">${_('Workflows')} (20)</span>
+          <div style="font-size: 15px; font-weight: 300">1hours ago <i class="fa fa-fighter-jet fa-fw"></i> Extracting hdfs://.../mini-earthquake.csv.zip to /user/romain/mini-earthquake.csv</div>
+          <div style="font-size: 15px; font-weight: 300">3hours ago <i class="fa fa-fighter-jet fa-fw"></i> Executing query 'SELECT * FROM web_logs limit 500' </div>
+          <div style="font-size: 15px; font-weight: 300">3hours ago <i class="fa fa-fighter-jet fa-fw"></i> Running Schedule 'Data log usage by day' </div>
+          <div style="font-size: 15px; font-weight: 300">3hours ago <i class="fa fa-fighter-jet fa-fw"></i> Exporting query result 'SELECT * FROM sample_07 where salary is not NULL' to /user/romain/escalation</div>
+          <div style="font-size: 15px; font-weight: 300">4hours ago <i class="fa fa-check fa-fw"></i> Exporting query result 'Top 25 Hue escalations' to /user/romain/escalation</div>
+          <div style="font-size: 15px; font-weight: 300">3hours ago <i class="fa fa-check fa-fw"></i> Indexing /user/romain/mini-earthquake.csv to mini-earthquake</div>
         </div>
 
         <div class="compose-action btn-group">
@@ -212,7 +218,7 @@ ${ hueIcons.symbols() }
           </button>
         </div>
         <div class="jobs-panel" data-bind="visible: jobsPanelVisible" style="display: none;">
-          <span style="font-size: 15px; font-weight: 300">${_('Workflows')} (20)</span>
+          <span style="font-size: 15px; font-weight: 300">${_('Jobs')} | ${_('Workflows')} | ${_('Schedules')}</span>
         </div>
       % endif
     </div>
@@ -232,11 +238,11 @@ ${ hueIcons.symbols() }
         <li><a href="javascript: void(0);">Custom App 3</a></li>
         <li class="header">&nbsp;</li>
         <li class="header" style="padding-left: 4px; border-bottom: 1px solid #DDD; padding-bottom: 3px;">${ _('Browse') }</li>
-        <li data-bind="click: function () { onePageViewModel.currentApp('jobbrowser') }"><a href="javascript: void(0);">Jobs</a></li>
-        <li data-bind="click: function () { onePageViewModel.currentApp('metastore') }"><a href="javascript: void(0);">Tables</a></li>
-        <li data-bind="click: function () { onePageViewModel.currentApp('indexes') }"><a href="javascript: void(0);">Indexes</a></li>
         <li data-bind="click: function () { onePageViewModel.currentApp('filebrowser') }"><a href="javascript: void(0);">Files</a></li>
         <li data-bind="click: function () { onePageViewModel.currentApp('filebrowser_s3') }"><a href="javascript: void(0);">S3</a></li>
+        <li data-bind="click: function () { onePageViewModel.currentApp('metastore') }"><a href="javascript: void(0);">Tables</a></li>
+        <li data-bind="click: function () { onePageViewModel.currentApp('indexes') }"><a href="javascript: void(0);">Indexes</a></li>
+        <li data-bind="click: function () { onePageViewModel.currentApp('jobbrowser') }"><a href="javascript: void(0);">Jobs</a></li>
         <li><a href="javascript: void(0);">HBase</a></li>
         <li><a href="javascript: void(0);">Security</a></li>
       </ul>

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

@@ -175,12 +175,9 @@ def execute_and_watch(request):
     sql, success_url = api.export_data_as_table(notebook, snippet, destination)
     editor = make_notebook(name='Execute and watch', editor_type=editor_type, statement=sql, status='ready-execute', database=snippet['database'])
   elif action == 'insert_as_query':
-    if IS_HUE_4.get():
-      # TODO: checks/workarounds in case of non impersonation or Sentry
-      # TODO: keep older simpler way in case of known not many rows?
-      sql, success_url = api.export_large_data_to_hdfs(notebook, snippet, destination)
-    else:
-      sql, success_url = api.export_large_data_to_hdfs1(notebook, snippet, destination)
+    # TODO: checks/workarounds in case of non impersonation or Sentry
+    # TODO: keep older simpler way in case of known not many rows?
+    sql, success_url = api.export_large_data_to_hdfs(notebook, snippet, destination)
     editor = make_notebook(name='Execute and watch', editor_type=editor_type, statement=sql, status='ready-execute', database=snippet['database'], on_success_url=success_url)
   elif action == 'index_query':
     if destination == '__hue__':