fixes in selecting files from grid ftp
authorMaciej Tronowski <mtro@man.poznan.pl>
Mon, 30 Mar 2015 09:49:24 +0000 (11:49 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Mon, 30 Mar 2015 09:49:24 +0000 (11:49 +0200)
qcg/forms.py
qcg/service.py
qcg/templates/qcg/job_new.html

index 74eec37..ef571a6 100644 (file)
@@ -136,7 +136,7 @@ class JobDescriptionForm(forms.Form):
     reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False)
 
     # TODO grid ftp
-    input = forms.MultipleChoiceField(label=u"Standardowe wejście", required=False)
+    input = forms.CharField(label=u"Standardowe wejście", max_length=500, required=False)
     stage_in = forms.MultipleChoiceField(label=u"Stage in", required=False)
     # stage_out = forms.MultipleChoiceField(label=u"Stage out", required=False)
 
@@ -169,7 +169,6 @@ class JobDescriptionForm(forms.Form):
             self.fields['arguments'].choices += ((v, v) for v in data.getlist('arguments'))
             self.fields['properties'].choices += ((v, v) for v in data.getlist('properties'))
             self.fields['native'].choices += ((v, v) for v in data.getlist('native'))
-            self.fields['input'].choices += ((v, v) for v in data.getlist('input'))
             self.fields['stage_in'].choices += ((v, v) for v in data.getlist('stage_in'))
             # self.fields['stage_out'].choices += ((v, v) for v in data.getlist('stage_out'))
 
@@ -207,6 +206,11 @@ class JobDescriptionForm(forms.Form):
     def clean_nodes(self):
         return map(int, self.cleaned_data['nodes'].split(':', 2)) if self.cleaned_data['nodes'] else ''
 
+    def clean_input(self):
+        return 'gsiftp://' + self.cleaned_data['input'] if self.cleaned_data['input'] else ''
+
+    def clean_stage_in(self):
+        return ['gsiftp://' + item for item in self.cleaned_data['stage_in']]
 
 class EnvForm(forms.Form):
     name = forms.CharField(label=u"Nazwa", max_length=100, validators=[env_name_validator],
index 6f44f49..6658638 100644 (file)
@@ -6,7 +6,7 @@ from django.utils.timezone import now
 from pyqcg import QCG
 from pyqcg.description import JobDescription
 from pyqcg.service import Registry
-from pyqcg.utils import Credential, TimePeriod
+from pyqcg.utils import Credential, TimePeriod, JobStatus, TaskStatus
 
 
 logger = logging.getLogger(__name__)
@@ -30,7 +30,8 @@ def update_user_data(user, proxy):
     # Jobs
     ###################################
     jts = time.time()
-    jobs = registry.jobs(**changed_filter)
+    jobs = registry.jobs(stats=[v for k, v in vars(JobStatus).iteritems() if not k.startswith('__')],
+                         **changed_filter)
     jte = time.time()
 
     jobs_count = 0
@@ -45,7 +46,8 @@ def update_user_data(user, proxy):
     # Tasks
     ###################################
     tts = time.time()
-    tasks = registry.tasks(**changed_filter)
+    tasks = registry.tasks(stats=[v for k, v in vars(TaskStatus).iteritems() if not k.startswith('__')],
+                           **changed_filter)
     tte = time.time()
 
     jobs_cache = {j.job_id: j for j in Job.objects.filter(owner=user)}
@@ -86,8 +88,8 @@ def submit_job(params, proxy):
     desc = JobDescription(Credential(proxy))
 
     direct_map = ('env_variables', 'executable', 'arguments', 'note', 'grant', 'hosts', 'properties', 'queue', 'procs',
-                  'wall_time', 'memory', 'memory_per_slot', 'modules', 'native', 'notify', 'preprocess', 'postprocess',
-                  'persistent')
+                  'wall_time', 'memory', 'memory_per_slot', 'modules', 'input', 'stage_in', 'native', 'notify',
+                  'preprocess', 'postprocess', 'persistent')
 
     for name in direct_map:
         if params[name]:
@@ -102,9 +104,6 @@ def submit_job(params, proxy):
     if params['watch_output']:
         desc.set_watch_output(params['watch_output'], params['watch_output_pattern'])
     # TODO script
-    # TODO executable
-    # TODO input
-    # TODO stage_in
     # TODO stage_out
     # TODO monitoring
 
index cac10a6..6f829d0 100644 (file)
                 'data-target': '#gridftp'
             });
 
-            $('#id_master_file,#id_executable,#id_preprocess_script,#id_postprocess_script').before(function() {
+            function fullPath(path, file) {
+                var res = path + file.get('name');
+
+                if (file.isDir())
+                    res += '/';
+
+                return res;
+            }
+
+            $('#id_master_file,#id_executable,#id_input,#id_preprocess_script,#id_postprocess_script').before(function() {
                 var target = this;
                 return gridftpButton.clone().click(function() {
                     $('#select-btn').off().click(function() {
@@ -32,7 +41,9 @@
                             return;
                         }
 
-                        var file = filex.host + filex.path.full() + '/' + selected[0].get('name');
+                        var file = fullPath(filex.host + filex.path.full() + '/', selected[0]);
+
+                        target.selectize.clear();
                         target.selectize.addOption({value: file, text: file});
                         target.selectize.addItem(file);
                         target.selectize.refreshItems();
                 });
             }).wrap('<div style="margin-right: 80px"></div>');
 
-            $('#id_input,#id_stage_in').before(function() {
+            $('#id_stage_in').before(function() {
                 var target = this;
                 return gridftpButton.clone().click(function() {
                     $('#select-btn').off().click(function() {
                         var path = filex.host + filex.path.full() + '/';
 
                         _.each(filex.selectedFiles(), function(item) {
-                            console.log(arguments);
-                            var file = path + item.get('name');
+                            var file = fullPath(path, item);
                             target.selectize.addOption({value: file, text: file});
                             target.selectize.addItem(file);
                         });