Commit ca3f0aa7 authored by marc's avatar marc
Browse files

file.py/task.py : task wait for pre-process to end before starting

parent d4273574
......@@ -101,8 +101,10 @@ def add_form():
if not auth.can_modify_run(run_id) :
error += " missing permission for run "+str(run_id)
pre_process = None
pre_process_flag = True
if request.vars['pre_process'] != "0":
pre_process = request.vars['pre_process']
pre_process_flag = False
if error=="" :
......@@ -111,6 +113,7 @@ def add_form():
info=request.vars['file_info'],
filename=request.vars['filename'],
pre_process_id=pre_process,
pre_process_flag=pre_process_flag,
provider=auth.user_id)
#add a default sample_set for this sequence file
......
......@@ -142,11 +142,15 @@ def index():
)
)
query_pre_process = db( db.pre_process.id >0 ).select()
pre_process_list = {}
for row in query_pre_process:
pre_process_list[row.id] = row.name
log.debug('sample_set (%s)' % request.vars["id"])
#if (auth.can_view_patient(request.vars["id"]) ):
return dict(query=query,
pre_process_list=pre_process_list,
config_id=config_id,
info=info_file,
can_modify=auth.can_modify_sample_set(sample_set_id),
......
......@@ -146,6 +146,7 @@ db.define_table('sequence_file',
Field('provider','reference auth_user'),
Field('pre_process_id', 'reference pre_process'),
Field('pre_process_result', 'text'),
Field('pre_process_flag', 'boolean'),
Field('data_file', 'upload',
uploadfolder=defs.DIR_SEQUENCES,
length=LENGTH_UPLOAD, autodelete=AUTODELETE),
......
......@@ -142,6 +142,24 @@ def schedule_run(id_sequence, id_sample_set, id_config, grep_reads=None):
def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads,
clean_before=False, clean_after=False):
from subprocess import Popen, PIPE, STDOUT, os
from datetime import timedelta as timed
## re schedule if pre_process is still pending
if db.sequence_file[id_file].pre_process_flag != True :
print "re-schedule"
args = [id_file, id_config, id_data, id_fuse, grep_reads]
task = scheduler.queue_task("vidjil", args,
repeats = 1, timeout = defs.TASK_TIMEOUT,
start_time=request.now + timed(seconds=120))
db.results_file[id_data] = dict(scheduler_task_id = task.id)
db.commit()
print task.id
sys.stdout.flush()
return "SUCCESS"
## les chemins d'acces a vidjil / aux fichiers de sequences
germline_folder = defs.DIR_VIDJIL + '/germline/'
......@@ -656,7 +674,8 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
raise IOError
db.sequence_file[sequence_file_id] = dict(data_file = stream,
data_file2 = None)
data_file2 = None,
pre_process_flag = True)
db.commit()
if clean_after:
......
......@@ -48,6 +48,7 @@
<td class="column_100"> sampling date </td>
<td> info </td>
<td> size </td>
<td> pre-process </td>
{{if auth.is_admin():}} <td> uploader </td> {{pass}}
<td class="column5"> </td>
<td class="column5"> </td>
......@@ -81,6 +82,9 @@
<td> {{=row.sequence_file.info}} </td>
<td {{if row.sequence_file.data_file == None :}} {{=XML("class='inactive' title='file is missing' ")}} {{pass}} >
{{=vidjil_utils.format_size(row.sequence_file.size_file)}} </td>
<td>{{if row.sequence_file.pre_process_id != None :}} {{=pre_process_list[row.sequence_file.pre_process_id]}} {{pass}}
{{if row.sequence_file.pre_process_flag == False :}}<i class="icon-spin4" style="animation: spin 2s 1000 linear;
display: inline-block;" title="pending pre-process"></i>{{pass}} </td>
{{if auth.is_admin():}}
<td> {{=row.sequence_file.provider}} {{if row.sequence_file.provider:}}{{=row.sequence_file.provider.last_name}}{{pass}}</td>
{{pass}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment