Commit 5378d5ae by Will Daly

Respond to PR feedback

parent 3fef491d
......@@ -13,8 +13,8 @@ from openassessment.assessment.errors import (
AIGradingRequestError, AIGradingInternalError
)
from openassessment.assessment.models import (
AITrainingWorkflow, InvalidOptionSelection, NoTrainingExamples,
Assessment, AITrainingWorkflow, AIGradingWorkflow,
InvalidOptionSelection, NoTrainingExamples,
AIClassifierSet, AI_ASSESSMENT_TYPE
)
from openassessment.assessment.worker import training as training_tasks
......@@ -46,6 +46,10 @@ def submit(submission_uuid, rubric, algorithm_id):
AIGradingRequestError
AIGradingInternalError
Example usage:
>>> submit('74a9d63e8a5fea369fd391d07befbd86ae4dc6e2', rubric, 'ease')
'10df7db776686822e501b05f452dc1e4b9141fe5'
"""
try:
workflow = AIGradingWorkflow.start_workflow(submission_uuid, rubric, algorithm_id)
......@@ -72,7 +76,7 @@ def submit(submission_uuid, rubric, algorithm_id):
try:
classifier_set_candidates = AIClassifierSet.objects.filter(
rubric=workflow.rubric, algorithm_id=algorithm_id
).order_by('-created_at')[:1]
)[:1]
# If we find classifiers for this rubric/algorithm
# then associate the classifiers with the workflow
......@@ -116,6 +120,16 @@ def get_latest_assessment(submission_uuid):
Raises:
AIGradingInternalError
Examle usage:
>>> get_latest_assessment('10df7db776686822e501b05f452dc1e4b9141fe5')
{
'points_earned': 6,
'points_possible': 12,
'scored_at': datetime.datetime(2014, 1, 29, 17, 14, 52, 649284 tzinfo=<UTC>),
'scorer': u"ease",
'feedback': u''
}
"""
try:
assessments = Assessment.objects.filter(
......@@ -156,6 +170,10 @@ def train_classifiers(rubric_dict, examples, algorithm_id):
AITrainingRequestError
AITrainingInternalError
Example usage:
>>> train_classifiers(rubric, examples, 'ease')
'10df7db776686822e501b05f452dc1e4b9141fe5'
"""
# Get or create the rubric and training examples
try:
......
......@@ -71,7 +71,7 @@ class AIClassifierSet(models.Model):
class Meta:
app_label = "assessment"
ordering = ['-created_at']
ordering = ['-created_at', '-id']
# The rubric associated with this set of classifiers
# We should have one classifier for each of the criteria in the rubric.
......
......@@ -99,12 +99,14 @@ def train_classifiers(workflow_uuid):
u"Training example format was not valid "
u"(training workflow UUID {})"
).format(workflow_uuid)
logger.exception(msg)
raise train_classifiers.retry()
except AIAlgorithmError:
msg = (
u"An error occurred while training AI classifiers "
u"(training workflow UUID {})"
).format(workflow_uuid)
logger.exception(msg)
raise train_classifiers.retry()
# Upload the classifiers
......@@ -116,6 +118,7 @@ def train_classifiers(workflow_uuid):
u"An error occurred while uploading trained classifiers "
u"(training workflow UUID {})"
).format(workflow_uuid)
logger.exception(msg)
raise train_classifiers.retry()
......
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