瀏覽代碼

[oozie] Add Spark Example for new Editor

Romain Rigaux 10 年之前
父節點
當前提交
8c91ec7

文件差異過大導致無法顯示
+ 17 - 0
apps/oozie/src/oozie/fixtures/initial_oozie_examples.json


+ 8 - 2
apps/oozie/src/oozie/management/commands/oozie_setup.py

@@ -19,6 +19,7 @@ import logging
 import os
 from lxml import etree
 
+from django.core import management
 from django.core.management.base import NoArgsCommand
 from django.utils.translation import ugettext as _
 
@@ -26,7 +27,7 @@ from hadoop import cluster
 
 from desktop.models import Document
 from liboozie.submittion import create_directories
-from oozie.conf import LOCAL_SAMPLE_DATA_DIR, LOCAL_SAMPLE_DIR, REMOTE_SAMPLE_DIR
+from oozie.conf import LOCAL_SAMPLE_DATA_DIR, LOCAL_SAMPLE_DIR, REMOTE_SAMPLE_DIR, ENABLE_V2
 from oozie.models import Workflow, Coordinator, Bundle
 from oozie.importlib.workflows import import_workflow_root
 from oozie.importlib.coordinators import import_coordinator_root
@@ -131,6 +132,11 @@ class Command(NoArgsCommand):
 
     # Load jobs
     LOG.info(_("Installing examples..."))
-    self.install_examples()
+
+    if ENABLE_V2.get():
+      self.fs.do_as_user(self.fs.DEFAULT_USER, self.fs.copyFromLocal, local_dir, remote_data_dir)
+      management.call_command('loaddata', 'initial_oozie_examples.json', verbosity=2)
+    else:
+      self.install_examples()
 
     Document.objects.sync()

+ 19 - 20
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -733,14 +733,12 @@
 
         <div class="row-fluid">
           <div class="span6">
-        <span data-bind="text: $root.workflow_properties.spark_master.label" style="display: inline-block"></span>
-        <input type="text" class="input-medium" data-bind="value: properties.spark_master, attr: { placeholder: $root.workflow_properties.spark_master.help_text }" />
-
+            <span data-bind="text: $root.workflow_properties.spark_master.label" style="display: inline-block"></span>
+            <input type="text" class="input-medium" data-bind="value: properties.spark_master, attr: { placeholder: $root.workflow_properties.spark_master.help_text }" />
           </div>
           <div class="span6">
-                 <span data-bind="text: $root.workflow_properties.mode.label" style="display: inline-block"></span>
-        <input type="text" class="input-medium" data-bind="value: properties.mode, attr: { placeholder: $root.workflow_properties.mode.help_text }" />
-
+            <span data-bind="text: $root.workflow_properties.mode.label" style="display: inline-block"></span>
+            <input type="text" class="input-medium" data-bind="value: properties.mode, attr: { placeholder: $root.workflow_properties.mode.help_text }" />
           </div>
         </div>
 
@@ -758,20 +756,21 @@
         <input type="text" class="filechooser-input" data-bind="filechooser: properties.jars, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: properties.jars, attr: { placeholder:  $root.workflow_properties.jars.help_text }" />
         <span data-bind='template: { name: "common-fs-link", data: {path: properties.jars(), with_label: false}}'></span>
 
-  <h6>
-    <a class="pointer" data-bind="click: function(){ properties.spark_arguments.push({'value': ''}); $(document).trigger('drawArrows') }">
-      ${ _('Arguments') } <i class="fa fa-plus"></i>
-    </a>
-  </h6>
-  <ul class="unstyled" data-bind="visible: properties.spark_arguments().length > 0, foreach: properties.spark_arguments">
-    <li>
-      <input type="text" class="input-xlarge" data-bind="value: value, attr: { placeholder: $root.workflow_properties.spark_arguments.help_text }"/>
-      <a href="#" data-bind="click: function(){ $parent.properties.spark_arguments.remove(this); $(document).trigger('drawArrows') }">
-        <i class="fa fa-minus"></i>
-      </a>
-    </li>
-  </ul>
-  <em data-bind="visible: properties.spark_arguments().length == 0">${ _('No arguments defined.') }</em>
+        <h6>
+          <a class="pointer" data-bind="click: function(){ properties.spark_arguments.push({'value': ''}); $(document).trigger('drawArrows') }">
+            ${ _('Arguments') } <i class="fa fa-plus"></i>
+          </a>
+        </h6>
+        <ul class="unstyled" data-bind="visible: properties.spark_arguments().length > 0, foreach: properties.spark_arguments">
+          <li>
+            <input type="text" class="input-xlarge filechooser-input" data-bind="filechooser: value, filechooserOptions: globalFilechooserOptions, hdfsAutocomplete: value, attr: { placeholder:  $root.workflow_properties.spark_arguments.help_text }" />
+            <span data-bind='template: { name: "common-fs-link", data: {path: value, with_label: false}}'></span>
+            <a href="#" data-bind="click: function(){ $parent.properties.spark_arguments.remove(this); $(document).trigger('drawArrows') }">
+              <i class="fa fa-minus"></i>
+            </a>
+          </li>
+       </ul>
+       <em data-bind="visible: properties.spark_arguments().length == 0">${ _('No arguments defined.') }</em>
       </div>
     </div>
 

+ 4 - 0
desktop/core/src/desktop/models.py

@@ -338,6 +338,10 @@ class DocumentManager(models.Manager):
             else:
               extra = ''
             doc = Document.objects.link(job, owner=job.owner, name=job.name, description=job.description, extra=extra)
+          if job.owner.username == SAMPLE_USERNAME:
+            job.doc.get().share_to_default()
+            tag = DocumentTag.objects.get_example_tag(user=job.owner)
+            doc.tags.add(tag)
     except Exception, e:
       LOG.warn(force_unicode(e))
 

部分文件因文件數量過多而無法顯示