Commit 18582b61 by Vik Paruchuri

Add in dogstatsd hooks for machine learning

parent 1c06c0f7
...@@ -10,6 +10,9 @@ sys.path.append(one_up_path) ...@@ -10,6 +10,9 @@ sys.path.append(one_up_path)
import model_creator import model_creator
import util_functions import util_functions
from statsd import statsd
@statsd.timed('open_ended_assessment.machine_learning.creator.time')
def create(text,score,prompt_string,model_path): def create(text,score,prompt_string,model_path):
results = {'errors': [],'success' : False, 'cv_kappa' : 0, 'cv_mean_absolute_error': 0} results = {'errors': [],'success' : False, 'cv_kappa' : 0, 'cv_mean_absolute_error': 0}
...@@ -29,5 +32,9 @@ def create(text,score,prompt_string,model_path): ...@@ -29,5 +32,9 @@ def create(text,score,prompt_string,model_path):
except: except:
results['errors'].append("could not write model to: {0}".format(model_path)) results['errors'].append("could not write model to: {0}".format(model_path))
#Count number of successful/unsuccessful creations
statsd.increment("open_ended_assessment.machine_learning.creator_count",
tags=["success:{0}".format(results['success'])])
return results return results
...@@ -10,6 +10,7 @@ import pickle ...@@ -10,6 +10,7 @@ import pickle
import os import os
import numpy import numpy
import logging import logging
from statsd import statsd
base_path = os.path.dirname(__file__) base_path = os.path.dirname(__file__)
sys.path.append(base_path) sys.path.append(base_path)
...@@ -25,7 +26,7 @@ log = logging.getLogger(__name__) ...@@ -25,7 +26,7 @@ log = logging.getLogger(__name__)
TEMPORARY_WANTS_CONFIG=True TEMPORARY_WANTS_CONFIG=True
@statsd.timed('open_ended_assessment.machine_learning.grader.time')
def grade(grader_path,grader_config,submission,sandbox=None): def grade(grader_path,grader_config,submission,sandbox=None):
results = {'errors': [],'tests': [],'score': 0, 'feedback' : "", 'success' : False} results = {'errors': [],'tests': [],'score': 0, 'feedback' : "", 'success' : False}
...@@ -87,6 +88,10 @@ def grade(grader_path,grader_config,submission,sandbox=None): ...@@ -87,6 +88,10 @@ def grade(grader_path,grader_config,submission,sandbox=None):
#If error, success is False. #If error, success is False.
results['success']=False results['success']=False
#Count number of successful/unsuccessful gradings
statsd.increment("open_ended_assessment.machine_learning.grader_count",
tags=["success:{0}".format(results['success'])])
return results return results
......
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