view to submitting jobs
[qcg-portal.git] / qcg / forms.py
index 8906e2d..1771327 100644 (file)
@@ -4,10 +4,15 @@ from django.core.validators import RegexValidator
 from django.template.defaultfilters import capfirst
 from pyqcg.utils import TaskStatus
 
+from qcg.fields import PredefinedChoiceField, MultiplePredefinedChoiceField
 from qcg.models import Task, Allocation
 
 
 date_range_validator = RegexValidator(r'[0-9]{2}\.[0-9]{2}\.[0-9]{4} - [0-9]{2}\.[0-9]{2}\.[0-9]{4}')
+nodes_validator = RegexValidator(r'^[0-9]{1,3}(:[0-9]{1,2}){0,2}$')
+env_name_validator = RegexValidator(r'^[a-zA-Z_][a-zA-Z0-9_]*$')
+
+CHOICES_PLACEHOLDER = (None, '')
 
 
 class FiltersForm(forms.Form):
@@ -54,3 +59,113 @@ class FiltersForm(forms.Form):
         self.fields['host'].choices = tuple(
             (host, capfirst(host.split('.', 1)[0]))
             for host in Allocation.objects.values_list('host_name', flat=True).order_by('host_name').distinct())
+
+
+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'),
+        )
+    APPLICATION_CHOICES = (
+        CHOICES_PLACEHOLDER,
+        ('bash', 'BASH'),
+        ('python', 'Python'),
+        ('matlab', 'MATLAB'),
+    )
+    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'),
+    )
+    NOTIFY_CHOICES = (
+        (0, u'Brak'),
+        (1, u'E-mail'),
+        (2, u'XMPP'),
+    )
+    PROCESS_CHOICES = (
+        (0, u'Brak'),
+        (1, u'Polecenie'),
+        (2, u'Skrypt'),
+    )
+
+    application = forms.ChoiceField(choices=APPLICATION_CHOICES, label=u"Aplikacja", required=False)  # TODO choices
+    executable = forms.CharField(label=u"Polecenie", max_length=500, required=False)  # TODO grid ftp
+    arguments = forms.CharField(label=u"Argumenty", max_length=1000, required=False)
+
+    name = forms.CharField(label=u"Nazwa", max_length=100, required=False)
+    note = forms.CharField(label=u"Notatka", widget=forms.Textarea(attrs={'rows': 2, 'cols': 40}), required=False)
+    grant = forms.CharField(label=u"Grant", max_length=100, required=False)
+
+    host = forms.ChoiceField(label=u"Host", choices=Host.CHOICES, required=False)
+    queue = PredefinedChoiceField(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 = forms.IntegerField(label=u"Wall time (s)", min_value=0, required=False)  # TODO duration field
+    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)
+
+    # TODO grid ftp
+    input = forms.CharField(label=u"Standardowe wejście", max_length=500, required=False)
+    output = forms.CharField(label=u"Standardowe wyjście", max_length=500, required=False)
+    error = forms.CharField(label=u"Standardowe wyjście błędów", 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)
+
+    properties = MultiplePredefinedChoiceField(label=u"Właściwości węzłów", required=False)
+    modules = forms.MultipleChoiceField(label=u"Moduły", choices=MODULES_CHOICES, required=False)  # TODO choices
+
+    not_after = forms.DateTimeField(label=u"Nie później niż", required=False)
+    not_before = forms.DateTimeField(label=u"Nie wcześniej niż", required=False)
+    deadline = forms.IntegerField(label=u"Deadline (s)", min_value=0, required=False)  # TODO duration field
+    reservation = forms.CharField(label=u"Rezerwacja", max_length=100, required=False)
+
+    monitoring = forms.BooleanField(label=u"Portal QCG-Monitoring", required=False)
+    notify_type = forms.ChoiceField(label=u"Monitorowanie stanu", choices=NOTIFY_CHOICES, required=False, initial=0,
+                                    widget=forms.RadioSelect)
+    notify_address = forms.EmailField(label=u"Adres", required=False)
+    watch_output_type = forms.ChoiceField(label=u"Monitorowanie wyjścia", choices=NOTIFY_CHOICES, required=False,
+                                          initial=0, widget=forms.RadioSelect)
+    watch_output_address = forms.EmailField(label=u"Adres", required=False)
+    watch_output_pattern = forms.CharField(label=u"Wzorzec", max_length=500, required=False)
+
+    preprocess_type = forms.ChoiceField(label=u"Preprocessing", choices=PROCESS_CHOICES, required=False, initial=0,
+                                        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
+    postprocess_type = forms.ChoiceField(label=u"Postprocessing", choices=PROCESS_CHOICES, required=False, initial=0,
+                                         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
+    native = MultiplePredefinedChoiceField(label=u"Parametry natywne", required=False)
+    persistent = forms.BooleanField(label=u"Trwałe", required=False)
+    use_scratch = forms.BooleanField(label=u"Scratch", required=False)
+
+
+class EnvForm(forms.Form):
+    name = forms.CharField(label=u"Nazwa", max_length=100, validators=[env_name_validator],
+                           widget=forms.TextInput(attrs={'placeholder': u'Nazwa'}))
+    value = forms.CharField(label=u"Wartość", max_length=500,
+                            widget=forms.TextInput(attrs={'placeholder': u'Wartość'}))
+
+
+EnvFormSet = forms.formset_factory(EnvForm, can_delete=True, extra=0)