Browse Source

HUE-7712: [spark] Livy-batch not available in HUE

Mykhailo Kysliuk 6 năm trước cách đây
mục cha
commit
64d56a82b5

+ 5 - 4
desktop/core/src/desktop/js/apps/notebook/snippet.js

@@ -1628,6 +1628,7 @@ class Snippet {
             (['spark2'].indexOf(self.type()) != -1 && self.properties().jars().length > 0) ||
             (['shell'].indexOf(self.type()) != -1 && self.properties().command_path().length > 0) ||
             (['mapreduce'].indexOf(self.type()) != -1 && self.properties().app_jar().length > 0) ||
+            (['py'].indexOf(self.type()) != -1 && self.properties().py_file().length > 0) ||
             (['distcp'].indexOf(self.type()) != -1 &&
               self.properties().source_path().length > 0 &&
               self.properties().destination_path().length > 0))) ||
@@ -2255,8 +2256,10 @@ class Snippet {
                 if (!notebook.unloaded()) {
                   self.checkStatusTimeout = setTimeout(self.checkStatus, delay);
                 }
-              } else if (self.status() === 'available') {
-                self.fetchResult(100);
+              } else if (self.status() === 'available' || self.status() === 'success') {
+                if (self.status() === 'available') {
+                  self.fetchResult(100);
+                }
                 self.progress(100);
                 if (self.isSqlDialect()) {
                   if (self.result.handle().has_result_set) {
@@ -2283,8 +2286,6 @@ class Snippet {
                 if (!self.result.handle().has_more_statements && vm.successUrl()) {
                   window.location.href = vm.successUrl(); // Not used anymore in Hue 4
                 }
-              } else if (self.status() === 'success') {
-                self.progress(99);
               }
             } else if (data.status === -3) {
               self.status('expired');

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/spark_batch.py

@@ -42,7 +42,7 @@ class SparkBatchApi(Api):
     elif snippet['type'] == 'py':
         properties = {
             'file': snippet['properties'].get('py_file'),
-            'args': snippet['properties'].get('argument'),
+            'args': snippet['properties'].get('argument', []),
         }
     else:
         properties = {

+ 4 - 4
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1004,7 +1004,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
             </div>
           </div>
           <!-- ko template: { if: ['text', 'markdown'].indexOf(type()) == -1, name: 'snippet-execution-status${ suffix }' } --><!-- /ko -->
-          <!-- ko template: { if: $root.editorMode() && ! $root.isResultFullScreenMode() && ['jar', 'java', 'spark2', 'distcp', 'shell', 'mapreduce'].indexOf(type()) == -1, name: 'snippet-code-resizer${ suffix }' } --><!-- /ko -->
+          <!-- ko template: { if: $root.editorMode() && ! $root.isResultFullScreenMode() && ['jar', 'java', 'spark2', 'distcp', 'shell', 'mapreduce', 'py'].indexOf(type()) == -1, name: 'snippet-code-resizer${ suffix }' } --><!-- /ko -->
           <!-- ko if: !$root.isResultFullScreenMode() -->
             <!-- ko template: 'snippet-log${ suffix }' --><!-- /ko -->
           <!-- /ko -->
@@ -1716,7 +1716,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
     <a class="inactive-action pull-left snippet-logs-btn" href="javascript:void(0)" data-bind="visible: status() === 'running' && errors().length == 0, click: function() { hideFixedHeaders(); $data.showLogs(!$data.showLogs());}, css: {'blue': $data.showLogs}" title="${ _('Toggle Logs') }"><i class="fa fa-fw" data-bind="css: { 'fa-caret-right': !$data.showLogs(), 'fa-caret-down': $data.showLogs() }"></i></a>
     <div class="snippet-progress-container" data-bind="visible: status() != 'canceled' && status() != 'with-optimizer-report'">
       <div class="progress-snippet progress" data-bind="css: {
-        'progress-starting': progress() == 0 && status() == 'running',
+        'progress-starting': progress() == 0 && (status() == 'running' || status() == 'starting'),
         'progress-warning': progress() > 0 && progress() < 100,
         'progress-success': progress() == 100,
         'progress-danger': progress() == 0 && errors().length > 0}" style="background-color: #FFF; width: 100%">
@@ -1790,7 +1790,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
       <div class="pull-left" data-bind="text: (result.statement_id() + 1)"></div><div class="pull-left">/</div><div class="pull-left" data-bind="text: result.statements_count()"></div>
     </div>
     <!-- ko if: !isCanceling() -->
-    <a class="snippet-side-btn red" data-bind="click: cancel, visible: status() == 'running'" title="${ _('Cancel operation') }">
+    <a class="snippet-side-btn red" data-bind="click: cancel, visible: status() == 'running' || status() == 'starting'" title="${ _('Cancel operation') }">
       <i class="fa fa-fw fa-stop snippet-side-single"></i>
     </a>
     <!-- /ko -->
@@ -1806,7 +1806,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
       </a>
       <!-- /ko -->
       <!-- ko if: ! isBatchable() || ! wasBatchExecuted() -->
-      <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="attr: {'title': $root.editorMode() && result.statements_count() > 1 ? '${ _ko('Execute next statement')}' : '${ _ko('Execute or CTRL + ENTER') }'}, click: function() { wasBatchExecuted(false); execute(); }, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }, style: {'padding-left': $parent.isBatchable() ? '2px' : '0' }">
+      <a class="snippet-side-btn" style="padding-right:0" href="javascript: void(0)" data-bind="attr: {'title': $root.editorMode() && result.statements_count() > 1 ? '${ _ko('Execute next statement')}' : '${ _ko('Execute or CTRL + ENTER') }'}, click: function() { wasBatchExecuted(false); execute(); }, visible: status() != 'running' && status() != 'loading' && status() != 'starting', css: {'blue': $parent.history().length == 0 || $root.editorMode(), 'disabled': ! isReady() }, style: {'padding-left': $parent.isBatchable() ? '2px' : '0' }">
         <i class="fa fa-fw fa-play" data-bind="css: { 'snippet-side-single' : ! $parent.isBatchable() }"></i>
       </a>
       <!-- /ko -->