from pyqcg.utils import TaskStatus
from qcg.fields import TimeRangeField
-from qcg.models import Task, Allocation
+from qcg.models import Task, Allocation, JobTemplate
date_range_validator = RegexValidator(r'[0-9]{2}\.[0-9]{2}\.[0-9]{4} - [0-9]{2}\.[0-9]{2}\.[0-9]{4}')
}
STATUS_CHOICES_DICT = dict(STATUS_CHOICES)
+ keywords = forms.CharField(max_length=100, label=u"Wyszukaj frazę", required=False)
status = forms.MultipleChoiceField(choices=STATUS_CHOICES, label=u"Status", required=False,
widget=forms.CheckboxSelectMultiple)
- host = forms.MultipleChoiceField(label=u"Host", required=False, widget=forms.CheckboxSelectMultiple)
# advanced
- keywords = forms.CharField(max_length=100, label=u"Wyszukaj frazę", required=False)
+ host = forms.MultipleChoiceField(label=u"Host", required=False, widget=forms.CheckboxSelectMultiple)
+ purged = forms.TypedChoiceField(label=u"Istniejący katalog roboczy?", required=False, coerce=lambda x: bool(int(x)),
+ choices=((0, 'Tak'), (1, 'Nie')), widget=forms.RadioSelect)
submission = forms.CharField(label=u"Data zlecenia", validators=[date_range_validator], required=False)
finish = forms.CharField(label=u"Data zakończenia", validators=[date_range_validator], required=False)
class JobDescriptionForm(forms.Form):
- class Host(object):
- GALERA = 'galera.task.gda.pl'
- HYDRA = 'hydra.icm.edu.pl'
- INULA = 'inula.man.poznan.pl'
- MOSS = 'moss.man.poznan.pl'
- NOVA = 'nova.wcss.wroc.pl'
- REEF = 'reef.man.poznan.pl'
- ZEUS = 'zeus.cyfronet.pl'
-
- CHOICES = (
- CHOICES_PLACEHOLDER,
- (GALERA, u'Galera'),
- (HYDRA, u'Hydra'),
- (INULA, u'Inula'),
- (MOSS, u'Moss'),
- (NOVA, u'Supernova'),
- (REEF, u'Reef'),
- (ZEUS, u'Zeus'),
- )
-
class Process(object):
NONE = ''
CMD = 'c'
(SCRIPT, u'Skrypt'),
)
+
APPLICATION_CHOICES = (
CHOICES_PLACEHOLDER,
- ('bash', 'BASH'),
- ('gromacs/4.6.3', 'GROMACS 4.6.3'),
- ('matlab', 'MATLAB'),
- ('python', 'Python'),
+ ('unres-gab', 'UNRES GAB'),
+ ('unres-e0ll2y', 'UNRES E0LL2Y'),
)
+
+
QUEUE_CHOICES = (
CHOICES_PLACEHOLDER,
- ('plgid', 'plgrid'),
- ('plgid-long', 'plgrid-long'),
- ('plgid-testing', 'plgrid-testing'),
- )
- MODULES_CHOICES = (
- ('plgrid/apps/python', 'plgrid/apps/python'),
- ('plgrid/apps/matlab', 'plgrid/apps/matlab'),
+ ('plgrid', 'plgrid'),
+ ('plgrid-long', 'plgrid-long'),
+ ('plgrid-testing', 'plgrid-testing'),
)
+
PROTOCOL_CHOICES = (
('', u'Brak'),
('mailto', u'E-mail'),
('xmpp', u'XMPP'),
)
- application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False) # TODO choices
- executable = forms.CharField(label=u"Plik wykonywalny", max_length=500, required=False) # TODO grid ftp
- script = forms.CharField(label=u"Skrypt", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False) # TODO saving to grid ftp
+
+ FORCE_FIELD_CHOICES = (
+ ('GAB', u'GAB'),
+ ('E0LL2Y', u'E0LL2Y'),
+ )
+
+ nstep = forms.IntegerField(label=u"NSTEP", help_text=u"Liczba kroków w trajektorii", min_value=1, initial=500000, required=False)
+ ntwe = forms.IntegerField(label=u"NTWE", help_text=u"Częstość zapisu energii w krokach", min_value=0, initial=100, required=False)
+ ntwx = forms.IntegerField(label=u"NTWX", help_text=u"Częstość zapisu współrzędnych w krokach", min_value=0, initial=1000, required=False)
+ dt = forms.DecimalField(label=u"DT", help_text=u"Krok czasowy. Wartość kroku równa jedności to 48.9 fs", max_digits=5, decimal_places=2, min_value=0.01, initial=0.1, required=False)
+ damax = forms.DecimalField(label=u"DAMAX", help_text=u"Maksymalna dopuszczalna zmiana przyspieszenia podczas jednego kroku czasowego", max_digits=5, decimal_places=2, min_value=0.01, initial=1.0, required=False)
+ force_field = forms.ChoiceField(choices=FORCE_FIELD_CHOICES, label=u"Pole siłowe", required=False, initial='GAB')
+
+ pdb_file = forms.CharField(label=u"Plik PDB", max_length=500, required=False)
+ #retmin = forms.IntegerField(label=u"RETMIN", help_text=u"Dolny zakres temparatur dla wymiany replik", min_value=2, initial=250, required=False)
+ #retmax = forms.IntegerField(label=u"RETMAX", help_text=u"Górny zakres temperatur dla wymiany replik", min_value=2, initial=450, required=False)
+ sequence = forms.CharField(label=u"Sekwencja", help_text=u"Sekwencja aminokwasów w zapisie jednoliterowym", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
+
+
+ application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False, initial='unres-gab')
+ #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)
arguments = forms.MultipleChoiceField(label=u"Argumenty", required=False)
note = forms.CharField(label=u"Opis", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
grant = forms.CharField(label=u"Grant", max_length=100, required=False)
- hosts = forms.MultipleChoiceField(label=u"Host", choices=Host.CHOICES, required=False)
- properties = forms.MultipleChoiceField(label=u"Właściwości węzłów", required=False)
+ hosts = forms.MultipleChoiceField(label=u"Host", required=False)
+ properties = forms.CharField(label=u"Właściwości węzłów", required=False)
queue = forms.ChoiceField(choices=QUEUE_CHOICES, label=u"Kolejka", required=False)
procs = forms.IntegerField(label=u"Liczba procesów", min_value=0, required=False)
nodes = forms.CharField(label=u"Topologia węzłów", max_length=10, validators=[nodes_validator], required=False)
wall_time = TimeRangeField(label=u"Wall time", required=False)
memory = forms.IntegerField(label=u"Pamięć (MB)", min_value=0, required=False)
memory_per_slot = forms.IntegerField(label=u"Pamięci per proces (MB)", min_value=0, required=False)
- modules = forms.MultipleChoiceField(label=u"Moduły", choices=MODULES_CHOICES, required=False) # TODO choices
+ modules = forms.MultipleChoiceField(label=u"Moduły", required=False)
reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False)
- # TODO grid ftp
input = forms.CharField(label=u"Standardowe wejście", max_length=500, required=False)
- stage_in = forms.CharField(label=u"Stage in", max_length=500, required=False)
- stage_out = forms.CharField(label=u"Stage out", max_length=500, required=False)
+ stage_in = forms.MultipleChoiceField(label=u"Stage in", required=False)
monitoring = forms.BooleanField(label=u"Portal QCG-Monitoring", required=False)
notify_type = forms.ChoiceField(label=u"Monitorowanie stanu", choices=PROTOCOL_CHOICES, required=False, initial='',
preprocess_type = forms.ChoiceField(label=u"Preprocessing", choices=Process.CHOICES, required=False,
initial=Process.NONE, widget=forms.RadioSelect)
preprocess_cmd = forms.CharField(label=u"Polecenie", max_length=1000, required=False)
- preprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False) # TODO grid ftp
+ preprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)
postprocess_type = forms.ChoiceField(label=u"Postprocessing", choices=Process.CHOICES, required=False,
- initial=Process.CHOICES, widget=forms.RadioSelect)
+ initial=Process.NONE, widget=forms.RadioSelect)
postprocess_cmd = forms.CharField(label=u"Polecenie", max_length=1000, required=False)
- postprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False) # TODO grid ftp
+ postprocess_script = forms.CharField(label=u"Skrypt", max_length=500, required=False)
native = forms.MultipleChoiceField(label=u"Opcje systemu kolejkowego", required=False)
persistent = forms.BooleanField(label=u"Trwałe", required=False)
- def __init__(self, data=None, *args, **kwargs):
- super(JobDescriptionForm, self).__init__(data, *args, **kwargs)
+ def __init__(self, data=None, initial=None, hosts=(), applications=(), modules=(), *args, **kwargs):
+ super(JobDescriptionForm, self).__init__(data, initial=initial, *args, **kwargs)
+
+ self.fields['hosts'].choices = hosts
+ self.fields['application'].choices = applications
+ self.fields['modules'].choices = modules
+
+ if data or initial:
+ self._init_user_choices('queue')
+ self._init_user_choices('arguments')
+ self._init_user_choices('native')
+ self._init_user_choices('stage_in')
+ self._init_user_choices('force_field')
- if data is not None:
- # accept user defined choices
- self.fields['queue'].choices += ((data.get('queue'), data.get('queue')), )
- 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'))
+ if not hosts:
+ self._init_user_choices('hosts')
+ self._init_user_choices('application')
+ self._init_user_choices('modules')
+
+
+ self.fields['monitoring'].widget.attrs['disabled'] = True
def clean(self):
data = super(JobDescriptionForm, self).clean()
+
+ force_field = data.get('force_field')
+
+ if force_field == u'GAB':
+ data['application'] = [u'unres-gab']
+ else:
+ data['application'] = [u'unres-e0ll2y']
+
+ if data['pdb_file']== None:
+ self.add_error('pdb_file', u"Należy podać plik PDB.")
+
+ if data['sequence']== '':
+ self.add_error('sequence', u"Należy podać sekwencję aminokwasów.")
+
+ if data['procs'] and data['nodes']:
+ self.add_error(None, u"Zdefiniuj tylko jedno z pól: liczbę procesów lub topologię węzłów")
notify_type = data.get('notify_type')
data['notify'] = u'{}:{}'.format(notify_type, data['notify_address']) if notify_type else ''
else:
data['postprocess'] = ''
+ return data
+
def clean_application(self):
- value = self.cleaned_data['application']
+ return self.cleaned_data['application'].split('/', 1) if self.cleaned_data['application'] else ''
+
+ def clean_nodes(self):
+ return map(int, self.cleaned_data['nodes'].split(':', 2)) if self.cleaned_data['nodes'] else ''
- if '/' in value:
- return value.split('/', 1)
+ def clean_executable(self):
+ return self._gsiftp_suffix(self.cleaned_data['executable'])
- return value, None
+ def clean_master_file(self):
+ return self._gsiftp_suffix(self.cleaned_data['master_file'])
- def clean_nodes(self):
- value = map(int, self.cleaned_data['nodes'].split(':', 2))
+ def clean_input(self):
+ return self._gsiftp_suffix(self.cleaned_data['input'])
- if len(value) == 3:
- return tuple(value)
+ def clean_stage_in(self):
+ return [self._gsiftp_suffix(item) for item in self.cleaned_data['stage_in']]
- nodes, slots = value
- return nodes, slots, slots
+ def clean_preprocess_script(self):
+ return self._gsiftp_suffix(self.cleaned_data['preprocess_script'])
+
+ def clean_postprocess_script(self):
+ return self._gsiftp_suffix(self.cleaned_data['postprocess_script'])
+
+ def clean_pdb_file(self):
+ return self._gsiftp_suffix(self.cleaned_data['pdb_file'])
+
+ def clean_sequence(self):
+ return self.cleaned_data['sequence'].strip(' \t\n\r')
+
+ @staticmethod
+ def _gsiftp_suffix(url):
+ if url:
+ return url if url.startswith('gsiftp://') else 'gsiftp://' + url
+
+ def _init_user_choices(self, name):
+ initial = self.initial.get(name)
+ choices = self.data.getlist(name)[:] if self.data else []
+
+ if initial:
+ choices += initial if isinstance(initial, list) else [initial]
+
+ if choices:
+ self.fields[name].choices += ((v, v) for v in choices)
class EnvForm(forms.Form):
columns = forms.MultipleChoiceField(choices=COLUMNS_CHOICES, initial=[k for k, v in COLUMNS_CHOICES[1:]],
label=u"Kolumny", required=False, widget=forms.CheckboxSelectMultiple)
+
+
+class JobTemplateForm(forms.ModelForm):
+ class Meta:
+ model = JobTemplate
+ fields = ('name',)