Commit fe534349 by Will Daly

Merge pull request #395 from edx/will/commit-workflow-params

Bugfix!  Commit the AIGradingWorkflow model before scheduling a grading task.
parents 4f5848a9 9e75d8fb
...@@ -14,7 +14,7 @@ from openassessment.assessment.errors import ( ...@@ -14,7 +14,7 @@ from openassessment.assessment.errors import (
from openassessment.assessment.models import ( from openassessment.assessment.models import (
Assessment, AITrainingWorkflow, AIGradingWorkflow, Assessment, AITrainingWorkflow, AIGradingWorkflow,
InvalidOptionSelection, NoTrainingExamples, InvalidOptionSelection, NoTrainingExamples,
AIClassifierSet, AI_ASSESSMENT_TYPE AI_ASSESSMENT_TYPE
) )
from openassessment.assessment.worker import training as training_tasks from openassessment.assessment.worker import training as training_tasks
from openassessment.assessment.worker import grading as grading_tasks from openassessment.assessment.worker import grading as grading_tasks
...@@ -129,18 +129,8 @@ def submit(submission_uuid, rubric, algorithm_id): ...@@ -129,18 +129,8 @@ def submit(submission_uuid, rubric, algorithm_id):
raise AIGradingInternalError(msg) raise AIGradingInternalError(msg)
try: try:
classifier_set_candidates = AIClassifierSet.objects.filter( # Schedule the grading task only if the workflow has a classifier set
rubric=workflow.rubric, algorithm_id=algorithm_id if workflow.classifier_set is not None:
)[:1]
# If we find classifiers for this rubric/algorithm
# then associate the classifiers with the workflow
# and schedule a grading task.
# Otherwise, the task will need to be scheduled later,
# once the classifiers have been trained.
if len(classifier_set_candidates) > 0:
workflow.classifier_set = classifier_set_candidates[0]
workflow.save()
grading_tasks.grade_essay.apply_async(args=[workflow.uuid]) grading_tasks.grade_essay.apply_async(args=[workflow.uuid])
logger.info(( logger.info((
u"Scheduled grading task for AI grading workflow with UUID {workflow_uuid} " u"Scheduled grading task for AI grading workflow with UUID {workflow_uuid} "
......
...@@ -590,8 +590,21 @@ class AIGradingWorkflow(AIWorkflow): ...@@ -590,8 +590,21 @@ class AIGradingWorkflow(AIWorkflow):
rubric=rubric rubric=rubric
) )
workflow._log_start_workflow() # Retrieve classifier set candidates
classifier_set_candidates = AIClassifierSet.objects.filter(
rubric=rubric, algorithm_id=algorithm_id
)[:1]
# If we find classifiers for this rubric/algorithm
# then associate the classifiers with the workflow
# and schedule a grading task.
# Otherwise, the task will need to be scheduled later,
# once the classifiers have been trained.
if len(classifier_set_candidates) > 0:
workflow.classifier_set = classifier_set_candidates[0]
workflow.save()
workflow._log_start_workflow()
return workflow return workflow
@transaction.commit_on_success @transaction.commit_on_success
......
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