Commit c8f66d05 authored by marc's avatar marc

pre_process.py: improve pre_process_flag

before > true/false
after > WAIT/QUEUD/RUN/DONE/FAILED
parent 12f59014
......@@ -122,10 +122,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
pre_process_flag = "DONE"
if request.vars['pre_process'] != "0":
pre_process = request.vars['pre_process']
pre_process_flag = False
pre_process_flag = "WAIT"
if error=="" :
......@@ -358,6 +358,9 @@ def upload():
error += "no data file"
if data_file is not None and data_file2 is not None and request.vars['pre_process'] != '0':
db.sequence_file[request.vars["id"]] = dict(pre_process_flag = "WAIT")
if db.scheduler_task[db.sequence_file[request.vars["id"]].pre_process_scheduler_task_id] != None:
scheduler.stop_task(db.sequence_file[request.vars["id"]].pre_process_scheduler_task_id)
schedule_pre_process(int(request.vars['id']), int(request.vars['pre_process']))
mes += "files uploaded, start pre-process !! "+ request.vars['id'] + "-" +request.vars['pre_process']
......
......@@ -148,7 +148,8 @@ 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('pre_process_flag', 'text'),
Field('pre_process_scheduler_task_id', 'integer'),
Field('data_file', 'upload',
uploadfolder=defs.DIR_SEQUENCES,
length=LENGTH_UPLOAD, autodelete=AUTODELETE),
......
......@@ -145,7 +145,7 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads,
from datetime import timedelta as timed
## re schedule if pre_process is still pending
if db.sequence_file[id_file].pre_process_flag != True :
if db.sequence_file[id_file].pre_process_flag != "DONE" and db.sequence_file[id_file].pre_process_flag != None :
print "Pre-process is still pending, re-schedule"
......@@ -620,7 +620,8 @@ def schedule_pre_process(sequence_file_id, pre_process_id):
task = scheduler.queue_task("pre_process", args,
repeats = 1, timeout = defs.TASK_TIMEOUT)
db.sequence_file[sequence_file_id] = dict(pre_process_scheduler_task_id = task.id)
res = {"redirect": "reload",
"message": "[%s] (%s): process requested" % (sequence_file_id, pre_process_id)}
......@@ -654,7 +655,9 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
from subprocess import Popen, PIPE, STDOUT, os
sequence_file = db.sequence_file[sequence_file_id]
db.sequence_file[sequence_file_id] = dict(pre_process_flag = "RUN")
db.commit()
out_folder = defs.DIR_PRE_VIDJIL_ID % sequence_file_id
output_filename = get_preprocessed_filename(sequence_file.data_file, sequence_file.data_file2)
......@@ -695,13 +698,15 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
print "!!! Pre-process failed, no result file"
res = {"message": "[%s] c%s: 'pre-process' FAILED - %s" % (sequence_file_id, pre_process_id, output_file)}
log.error(res)
db.sequence_file[sequence_file_id] = dict(pre_process_flag = "FAILED")
db.commit()
raise IOError
# Now we update the sequence file with the result of the pre-process
# We forget the initial data_file (and possibly data_file2)
db.sequence_file[sequence_file_id] = dict(data_file = stream,
data_file2 = None,
pre_process_flag = True)
pre_process_flag = "DONE")
db.commit()
# Dump log in scheduler_run.run_output
......
......@@ -82,9 +82,13 @@
<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>
<td onclick="db.call('pre_process/info', {'sequence_file_id' :'{{=row.sequence_file.id }}', 'sample_set_id' : '{{=request.vars["id"]}}'} )"
>{{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 == "RUN" :}}<i class="icon-spin4" style="animation: spin 2s 1000 linear;
display: inline-block;" title="running pre_processs"></i>{{pass}}
{{if row.sequence_file.pre_process_flag == "WAIT" :}}[queued]{{pass}}
{{if row.sequence_file.pre_process_flag == "FAILED" :}}[failed]{{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