Commit 7f5a9aac authored by HERBERT Ryan's avatar HERBERT Ryan

clear_scheduler_tasks.py purge tasks and runs

A large number of tasks were generated with the arrival of
pre-processing that simply indicated that vidjil could not yet be
started due to a pre-process having not yet finished. These tasks were
saturating the database and serve no purpose beyond the initial attempt
at launching Vidjil. This script deletes such scheduler_tasks and their associated
scheduler_uns.
parent 5268f54e
#!/usr/bin/python
from gluon import current
import gluon
runs_query = db(db.scheduler_run.run_output.like('Pre-process is still pending, re-schedule%'))
tasks_query = db(db.scheduler_task.id.belongs(runs_query._select(db.scheduler_run.task_id)))
tasks = tasks_query.select()
print 'Tasks resulting in Pre-process still pending: %s' % len(tasks)
print 'Would you like to delete them ? y/[n]'
answer = raw_input()
if answer.lower() in ('y', 'yes'):
print 'Deleting tasks'
tasks_query.delete()
runs = runs_query.select()
print 'There are %d runs left after deleting tasks' % len(runs)
print 'Would you like to delete the, ? y/[n]'
answer = raw_input()
if answer.lower() in ('y', 'yes'):
print 'Deleting runs'
runs_query.delete()
print 'Commit to these changes ? y/[n]'
answer = raw_input()
if answer.lower() in ('y', 'yes'):
print 'Committing'
db.commit()
else:
print ' Rollback'
db.rollback()
else:
print 'preserving tasks and runs'
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