Commit 4f5848a9 by Will Daly

Merge pull request #393 from edx/will/reschedule-task-priority

Will/reschedule task priority
parents 8f9dd4c8 f379a4b1
...@@ -5,6 +5,7 @@ Asynchronous tasks for grading essays using text classifiers. ...@@ -5,6 +5,7 @@ Asynchronous tasks for grading essays using text classifiers.
import datetime import datetime
from celery import task from celery import task
from django.db import DatabaseError from django.db import DatabaseError
from django.conf import settings
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from dogapi import dog_stats_api from dogapi import dog_stats_api
from openassessment.assessment.api import ai_worker as ai_worker_api from openassessment.assessment.api import ai_worker as ai_worker_api
...@@ -17,6 +18,10 @@ MAX_RETRIES = 2 ...@@ -17,6 +18,10 @@ MAX_RETRIES = 2
logger = get_task_logger(__name__) logger = get_task_logger(__name__)
# If the Django settings define a low-priority queue, use that.
# Otherwise, use the default queue.
RESCHEDULE_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None)
@task(max_retries=MAX_RETRIES) # pylint: disable=E1102 @task(max_retries=MAX_RETRIES) # pylint: disable=E1102
def grade_essay(workflow_uuid): def grade_essay(workflow_uuid):
...@@ -93,7 +98,7 @@ def grade_essay(workflow_uuid): ...@@ -93,7 +98,7 @@ def grade_essay(workflow_uuid):
raise grade_essay.retry() raise grade_essay.retry()
@task(max_retries=MAX_RETRIES) # pylint: disable=E1102 @task(queue=RESCHEDULE_TASK_QUEUE, max_retries=MAX_RETRIES) # pylint: disable=E1102
def reschedule_grading_tasks(course_id, item_id): def reschedule_grading_tasks(course_id, item_id):
""" """
Reschedules all incomplete grading workflows with the specified parameters. Reschedules all incomplete grading workflows with the specified parameters.
...@@ -243,4 +248,4 @@ def _log_complete_reschedule_grading(course_id=None, item_id=None, seconds=-1, s ...@@ -243,4 +248,4 @@ def _log_complete_reschedule_grading(course_id=None, item_id=None, seconds=-1, s
if not success: if not success:
msg += u" At least one grading task failed due to internal error." msg += u" At least one grading task failed due to internal error."
msg.format(cid=course_id,iid=item_id,s=seconds) msg.format(cid=course_id,iid=item_id,s=seconds)
logger.info(msg) logger.info(msg)
\ No newline at end of file
...@@ -22,6 +22,8 @@ logger = get_task_logger(__name__) ...@@ -22,6 +22,8 @@ logger = get_task_logger(__name__)
# If the Django settings define a low-priority queue, use that. # If the Django settings define a low-priority queue, use that.
# Otherwise, use the default queue. # Otherwise, use the default queue.
TRAINING_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None) TRAINING_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None)
RESCHEDULE_TASK_QUEUE = getattr(settings, 'LOW_PRIORITY_QUEUE', None)
class InvalidExample(Exception): class InvalidExample(Exception):
""" """
...@@ -146,7 +148,7 @@ def train_classifiers(workflow_uuid): ...@@ -146,7 +148,7 @@ def train_classifiers(workflow_uuid):
raise raise
@task(max_retries=MAX_RETRIES) #pylint: disable E=1102 @task(queue=RESCHEDULE_TASK_QUEUE, max_retries=MAX_RETRIES) #pylint: disable=E1102
def reschedule_training_tasks(course_id, item_id): def reschedule_training_tasks(course_id, item_id):
""" """
Reschedules all incomplete training tasks Reschedules all incomplete training tasks
...@@ -281,4 +283,4 @@ def _log_complete_reschedule_training(course_id=None, item_id=None, seconds=-1, ...@@ -281,4 +283,4 @@ def _log_complete_reschedule_training(course_id=None, item_id=None, seconds=-1,
if not success: if not success:
msg += u" At least one rescheduling task failed due to internal error." msg += u" At least one rescheduling task failed due to internal error."
msg.format(cid=course_id,iid=item_id,s=seconds) msg.format(cid=course_id,iid=item_id,s=seconds)
logger.info(msg) logger.info(msg)
\ No newline at end of file
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