Commit e2ace035 authored by Marc Duez's avatar Marc Duez

server : put schedule_run function in task.py (accesible for more than one controller)

parent 3d131d83
......@@ -64,44 +64,7 @@ def run_request():
error += "run already registered, "
if error == "" :
## create or update data file state
row = db( ( db.data_file.config_id == request.vars["config_id" ] )
& ( db.data_file.sequence_file_id == request.vars["sequence_file_id"] )
).select()
if len(row) > 0 : ## update
data_id = row[0].id
else: ## create
data_id = db.data_file.insert(sequence_file_id = request.vars['sequence_file_id'],
config_id = request.vars['config_id'],
)
## create or update fuse file state
row = db( ( db.fused_file.config_id == request.vars["config_id"] ) &
( db.fused_file.patient_id == id_patient )
).select()
if len(row) > 0 : ## update
fuse_id = row[0].id
else: ## create
fuse_id = db.fused_file.insert(patient_id = id_patient,
config_id = request.vars['config_id'])
##add task to scheduller
task = scheduler.queue_task('run', [request.vars["sequence_file_id"],request.vars["config_id"], data_id, fuse_id]
, repeats = 1, timeout = 6000)
db.data_file[data_id] = dict(scheduler_task_id = task.id)
(filename, str) = db.sequence_file.data_file.retrieve(db.sequence_file[request.vars["sequence_file_id"]].data_file)
config_name = db.config[request.vars["config_id"]].name
patient_name = db.patient[id_patient].first_name + " " + db.patient[id_patient].last_name
res = {"redirect": "patient/info",
"args" : { "id" : id_patient,
"config_id" : request.vars["config_id"]},
"message": "default/run_request : request added to run config " + config_name + " on " + filename + " for " + patient_name }
res = schedule_run(request.vars["sequence_file_id"], request.vars["config_id"])
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
......@@ -110,6 +73,7 @@ def run_request():
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
#########################################################################
## return .data file
# need patient_id, config_id
......
# coding: utf8
def schedule_run(id_sequence, id_config):
id_patient = db.sequence_file[id_sequence].patient_id
row = db( ( db.data_file.config_id == id_config )
& ( db.data_file.sequence_file_id == id_sequence )
).select()
if len(row) > 0 : ## update
data_id = row[0].id
else: ## create
data_id = db.data_file.insert(sequence_file_id = id_sequence,
config_id = id_config,
)
## create or update fuse file state
row = db( ( db.fused_file.config_id == id_config ) &
( db.fused_file.patient_id == id_patient )
).select()
if len(row) > 0 : ## update
fuse_id = row[0].id
else: ## create
fuse_id = db.fused_file.insert(patient_id = id_patient,
config_id = id_config)
##add task to scheduller
task = scheduler.queue_task('run', [id_sequence,id_config, data_id, fuse_id]
, repeats = 1, timeout = 6000)
db.data_file[data_id] = dict(scheduler_task_id = task.id)
(filename, str) = db.sequence_file.data_file.retrieve(db.sequence_file[id_sequence].data_file)
config_name = db.config[id_config].name
patient_name = db.patient[id_patient].first_name + " " + db.patient[id_patient].last_name
res = {"redirect": "patient/info",
"args" : { "id" : id_patient,
"config_id" : id_config},
"message": "default/run_request : request added to run config " + config_name + " on " + filename + " for " + patient_name }
return res
def run_vidjil(id_file, id_config, id_data, id_fuse):
import time, datetime, sys, os.path
......
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