Commit 53d095ab by Will Daly

Add info-level logging for AI grading and training

parent ac4251dd
......@@ -83,7 +83,16 @@ def submit(submission_uuid, rubric, algorithm_id):
workflow.classifier_set = classifier_set_candidates[0]
workflow.save()
grading_tasks.grade_essay.apply_async(args=[workflow.uuid])
logger.info((
u"Scheduled grading task for AI grading workflow with UUID {workflow_uuid} "
u"(submission UUID = {sub_uuid}, algorithm ID = {algorithm_id})"
).format(workflow_uuid=workflow.uuid, sub_uuid=submission_uuid, algorithm_id=algorithm_id))
else:
logger.info((
u"Cannot schedule a grading task for AI grading workflow with UUID {workflow_uuid} "
u"because no classifiers are available for the rubric associated with submission {sub_uuid} "
u"for the algorithm {algorithm_id}"
).format(workflow_uuid=workflow.uuid, sub_uuid=submission_uuid, algorithm_id=algorithm_id))
return workflow.uuid
except Exception as ex:
msg = (
......@@ -171,6 +180,10 @@ def train_classifiers(rubric_dict, examples, algorithm_id):
# Schedule the task, parametrized by the workflow UUID
try:
training_tasks.train_classifiers.apply_async(args=[workflow.uuid])
logger.info((
u"Scheduled training task for the AI training workflow with UUID {workflow_uuid} "
u"(algorithm ID = {algorithm_id})"
).format(workflow_uuid=workflow.uuid, algorithm_id=algorithm_id))
except:
msg = (
u"An unexpected error occurred while scheduling "
......
......@@ -115,6 +115,13 @@ def create_assessment(grading_workflow_uuid, criterion_scores):
try:
if not workflow.is_complete:
workflow.complete(criterion_scores)
logger.info((
u"Created assessment for AI grading workflow with UUID {workflow_uuid} "
u"(algorithm ID {algorithm_id})"
).format(workflow_uuid=workflow.uuid, algorithm_id=workflow.algorithm_id))
else:
msg = u"Grading workflow with UUID {} is already marked complete".format(workflow.uuid)
logger.info(msg)
except DatabaseError as ex:
msg = (
u"An unexpected error occurred while creating the assessment "
......@@ -226,12 +233,16 @@ def create_classifiers(training_workflow_uuid, classifier_set):
workflow = AITrainingWorkflow.objects.get(uuid=training_workflow_uuid)
# If the task is executed multiple times, the classifier set may already
# have been created. If so, log a warning then return immediately.
# have been created. If so, log it, then return immediately.
if workflow.is_complete:
msg = u"AI training workflow with UUID {} already has trained classifiers."
logger.warning(msg)
msg = u"AI training workflow with UUID {} already has trained classifiers.".format(workflow.uuid)
logger.info(msg)
else:
workflow.complete(classifier_set)
logger.info((
u"Created trained classifiers for the AI training workflow with UUID {workflow_uuid} "
u"(using algorithm ID {algorithm_id})"
).format(workflow_uuid=workflow.uuid, algorithm_id=workflow.algorithm_id))
except AITrainingWorkflow.DoesNotExist:
msg = (
u"Could not retrieve AI training workflow with UUID {}"
......
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