From eb0c9af5b8eb444d8db3e8759d3a83e8c6d41ee1 Mon Sep 17 00:00:00 2001 From: Maciej Tronowski Date: Mon, 30 Mar 2015 11:49:24 +0200 Subject: [PATCH 1/1] fixes in selecting files from grid ftp --- qcg/forms.py | 8 ++++++-- qcg/service.py | 15 +++++++-------- qcg/templates/qcg/job_new.html | 20 +++++++++++++++----- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/qcg/forms.py b/qcg/forms.py index 74eec37..ef571a6 100644 --- a/qcg/forms.py +++ b/qcg/forms.py @@ -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], diff --git a/qcg/service.py b/qcg/service.py index 6f44f49..6658638 100644 --- a/qcg/service.py +++ b/qcg/service.py @@ -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 diff --git a/qcg/templates/qcg/job_new.html b/qcg/templates/qcg/job_new.html index cac10a6..6f829d0 100644 --- a/qcg/templates/qcg/job_new.html +++ b/qcg/templates/qcg/job_new.html @@ -21,7 +21,16 @@ '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(); @@ -43,15 +54,14 @@ }); }).wrap('
'); - $('#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); }); -- 1.7.9.5