Browse Source

[pig] Show progress of running scripts on dashboards

Romain Rigaux 12 years ago
parent
commit
788c039

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

@@ -283,7 +283,7 @@ from django.utils.translation import ugettext as _
                     <label>${_('Group')}</label>
                     ${ edit.selection("group", groups, 'supergroup', "group_other") }
                     <br />
-                    <label style="display: inline;">${_('Recursive')}</label><input type="checkbox" name="recursive">
+                    <label style="display: inline;">${_('Recursive')}</label> <input type="checkbox" name="recursive" style="margin-bottom:4px">
                 </div>
 
 

+ 2 - 2
apps/pig/src/pig/api.py

@@ -71,8 +71,8 @@ class OozieApi:
 
       pig_params = []
       for param in json.loads(params):
-        pig_params.append({"type":"argument","value":"-param"})
-        pig_params.append({"type":"argument","value":"%(name)s=%(value)s" % param})
+        pig_params.append({"type": "argument", "value": "-param"})
+        pig_params.append({"type": "argument", "value": "%(name)s=%(value)s" % param})
 
       files = []
       archives = []

+ 2 - 2
apps/pig/src/pig/templates/app.mako

@@ -255,13 +255,13 @@ ${ commonheader(_('Pig'), "pig", user, "100px") | n,unicode }
               <div class="pull-right">
                   ${ _('Status:') } <a data-bind="text: status, visible: absoluteUrl != '', attr: {'href': absoluteUrl}" target="_blank"/> <i class="icon-share-alt"></i>
               </div>
-              <h4>${ _('Progress:') } <span data-bind="text: progress"></span>${ _('%') } <img src="/static/art/spinner.gif" data-bind="visible: progress != 100"/></h4>
+              <h4>${ _('Progress:') } <span data-bind="text: progress"></span>${ _('%') }</h4>
               <div data-bind="css: {'progress': name != '', 'progress-striped': name != '', 'active': status == 'RUNNING'}" style="margin-top:10px">
                 <div data-bind="css: {'bar': name != '', 'bar-success': status == 'SUCCEEDED' || status == 'OK', 'bar-warning': status == 'RUNNING' || status == 'PREP', 'bar-danger': status != 'RUNNING' && status != 'SUCCEEDED' && status != 'OK' && status != 'PREP' && status != 'SUSPENDED'}, attr: {'style': 'width:' + progressPercent}"></div>
               </div>
             </div>
           </script>
-          <pre id="withoutLogs" class="hide">${ _('No available logs.') }</pre>
+          <pre id="withoutLogs" class="hide">${ _('No available logs.') } <img src="/static/art/spinner.gif"/></pre>
           <pre id="withLogs" class="hide scroll"></pre>
         </div>
 

+ 26 - 10
apps/pig/src/pig/tests.py

@@ -34,20 +34,22 @@ from oozie.tests import OozieBase
 
 
 class TestPigBase(object):
+  SCRIPT_ATTRS = {
+      'id': 1000,
+      'name': 'Test',
+      'script': 'A = LOAD "$data"; STORE A INTO "$output";',
+      'parameters': [],
+      'resources': [],
+  }
+
   def setUp(self):
     self.c = make_logged_in_client(is_superuser=False)
     grant_access("test", "test", "pig")
     self.user = User.objects.get(username='test')
 
   def create_script(self):
-    attrs = {
-      'id': 1000,
-      'name': 'Test',
-      'script': 'A = LOAD "$data"; STORE A INTO "$output";',
-      'user': self.user,
-      'parameters': [],
-      'resources': [],
-    }
+    attrs = {'user': self.user,}
+    attrs.update(TestPigBase.SCRIPT_ATTRS)
     return create_or_update_script(**attrs)
 
 
@@ -57,6 +59,18 @@ class TestMock(TestPigBase):
     pig_script = self.create_script()
     assert_equal('Test', pig_script.dict['name'])
 
+  def test_save(self):
+    attrs = {'user': self.user,}
+    attrs.update(TestPigBase.SCRIPT_ATTRS)
+    attrs['parameters'] = json.dumps([])
+    attrs['resources'] = json.dumps([])
+
+    # Save
+    self.c.post(reverse('pig:save'), data=attrs, follow=True)
+
+    # Update
+    self.c.post(reverse('pig:save'), data=attrs, follow=True)
+
 
 class TestWithHadoop(OozieBase):
 
@@ -102,7 +116,9 @@ class TestWithHadoop(OozieBase):
     }
 
     response = self.c.post(reverse('pig:run'), data=post_data, follow=True)
-    self.wait_until_completion(json.loads(response.content)['id'])
+    job_id = json.loads(response.content)['id']
+
+    self.wait_until_completion(job_id)
 
   def test_stop(self):
     script = PigScript.objects.get(id=1)
@@ -122,5 +138,5 @@ class TestWithHadoop(OozieBase):
     script = PigScript.objects.get(id=json.loads(submit_response.content)['id'])
     assert_true(script.dict['job_id'], script.dict)
 
-    stop_response = self.c.post(reverse('pig:stop'), data={'id': script.id}, follow=True)
+    self.c.post(reverse('pig:stop'), data={'id': script.id}, follow=True)
     self.wait_until_completion(json.loads(submit_response.content)['id'], expected_status='KILLED')