handling master file for application type jobs
authorMaciej Tronowski <mtro@man.poznan.pl>
Tue, 28 Apr 2015 10:54:14 +0000 (12:54 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Tue, 28 Apr 2015 10:54:14 +0000 (12:54 +0200)
qcg/forms.py
qcg/service.py

index 35b34d7..4cd49e7 100644 (file)
@@ -117,7 +117,7 @@ class JobDescriptionForm(forms.Form):
     )
 
     application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False)  # TODO choices
-    master_file = forms.CharField(label=u"Plik główny", max_length=500, required=False)  # TODO grid ftp
+    master_file = forms.CharField(label=u"Plik główny", max_length=500, required=False)
     executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False)
     script = forms.CharField(label=u"Skrypt", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)  # TODO saving to grid ftp
     arguments = forms.MultipleChoiceField(label=u"Argumenty", required=False)
@@ -174,6 +174,9 @@ class JobDescriptionForm(forms.Form):
     def clean(self):
         data = super(JobDescriptionForm, self).clean()
 
+        if data['application'] and not data['master_file']:
+            self.add_error('master_file', u"W trybie uruchamiania aplikacji należy podać plik główny")
+
         notify_type = data.get('notify_type')
         data['notify'] = u'{}:{}'.format(notify_type, data['notify_address']) if notify_type else ''
 
@@ -204,6 +207,9 @@ class JobDescriptionForm(forms.Form):
     def clean_executable(self):
         return self._gsiftp_suffix(self.cleaned_data['executable'])
 
+    def clean_master_file(self):
+        return self._gsiftp_suffix(self.cleaned_data['master_file'])
+
     def clean_nodes(self):
         return map(int, self.cleaned_data['nodes'].split(':', 2)) if self.cleaned_data['nodes'] else ''
 
index be0ccac..44cb42e 100644 (file)
@@ -1,4 +1,5 @@
 import logging
+import os
 import time
 
 from django.db import transaction
@@ -147,6 +148,8 @@ def submit_job(params, proxy):
 
     if params['application']:
         desc.set_application(*params['application'])
+        desc.stage_in += [params['master_file']]
+        desc.arguments.insert(0, os.path.basename(params['master_file']))
     if params['nodes']:
         desc.set_nodes(*params['nodes'])
     if params['reservation']: