Commit 5378d5ae by Will Daly

Respond to PR feedback

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