Commit 16213774 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-s/refuse_full' into 'dev'

Fully refuse when deleting a sequence file

Closes #2478

See merge request !49
parents 4dd1a39f 3e981032
Pipeline #2584 passed with stages
in 2 minutes and 26 seconds
......@@ -588,11 +588,11 @@ def delete():
if not(delete_results):
delete_sequence_file(request.vars['id'])
else:
results_file = db(db.results_file.sequence_file_id == request.vars["id"]).select().first()
config_id = results_file.config_id
sample_set_ids = get_sequence_file_sample_sets(request.vars["id"])
config_ids = get_sequence_file_config_ids(request.vars["id"])
db(db.results_file.sequence_file_id == request.vars["id"]).delete()
db(db.sequence_file.id == request.vars["id"]).delete()
schedule_fuse(sample_set.id, config_id)
schedule_fuse(sample_set_ids, config_ids)
res = {"redirect": "sample_set/index",
"args" : { "id" : request.vars["redirect_sample_set_id"]},
......
......@@ -107,3 +107,23 @@ def get_run_id(file_id):
run_id = row.id
return run_id
def get_sequence_file_sample_sets(sequence_file_id):
'''
return the list of sample_sets a sequence_file belongs to
'''
query = db((db.sample_set_membership.sequence_file_id == sequence_file_id)).select(db.sample_set_membership.sample_set_id)
sample_set_ids = []
for row in query:
sample_set_ids.append(row.sample_set_id)
return sample_set_ids
def get_sequence_file_config_ids(sequence_file_id):
'''
return the list of configs run ona sequence_file
'''
query = db((db.results_file.sequence_file_id == sequence_file_id)).select(db.results_file.config_id)
config_ids = []
for row in query:
config_ids.append(row.config_id)
return config_ids
......@@ -128,20 +128,21 @@ def schedule_run(id_sequence, id_config, grep_reads=None):
log.info(res)
return res
def schedule_fuse(id_sample_set, id_config):
sample_set = db.sample_set[id_sample_set]
sequence_file_id = db((db.sample_set_membership.sample_set_id == sample_set.id)
&(db.sample_set_membership.sequence_file_id == db.sequence_file.id)
).select(db.sequence_file.id).first().id
results_file_id = db((db.results_file.sequence_file_id == sequence_file_id)
& (db.results_file.config_id == id_config)
).select(db.results_file.id).first().id
args = [sequence_file_id, id_config, results_file_id, id_sample_set, False]
task = scheduler.queue_task('fuse', args,
repeats = 1, timeout = defs.TASK_TIMEOUT)
def schedule_fuse(sample_set_ids, config_ids):
args = []
for sample_set_id in sample_set_ids:
for config_id in config_ids:
row = db((db.sample_set_membership.sample_set_id == sample_set_id)
& (db.sample_set_membership.sequence_file_id == db.results_file.sequence_file_id)
& (db.results_file.config_id == config_id)
).select(db.sample_set_membership.sample_set_id, db.sample_set_membership.sequence_file_id,
db.results_file.id, db.results_file.config_id).first()
if row:
args.append([row.sample_set_membership.sequence_file_id, row.results_file.config_id,
row.results_file.id, row.sample_set_membership.sample_set_id, False])
if len(args) > 0:
task = scheduler.queue_task('refuse', [args],
repeats = 1, timeout = defs.TASK_TIMEOUT)
def run_vidjil(id_file, id_config, id_data, grep_reads,
clean_before=False, clean_after=False):
......@@ -469,6 +470,10 @@ def run_copy(id_file, id_config, id_data, clean_before=False, clean_after=False)
return "SUCCESS"
def run_refuse(args):
for arg in args:
run_fuse(arg[0], arg[1], arg[2], arg[3], arg[4])
return "SUCCESS"
def run_fuse(id_file, id_config, id_data, sample_set_id, clean_before=True, clean_after=False):
from subprocess import Popen, PIPE, STDOUT, os
......@@ -778,5 +783,5 @@ scheduler = Scheduler(db, dict(vidjil=run_vidjil,
mixcr=run_mixcr,
none=run_copy,
pre_process=run_pre_process,
fuse=run_fuse),
refuse=run_refuse),
heartbeat=defs.SCHEDULER_HEARTBEAT)
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