Skip to content

Commit

Permalink
Merge pull request #272 from datmo/hotfix
Browse files Browse the repository at this point in the history
updating monitoring to track feedback
  • Loading branch information
asampat3090 committed Oct 18, 2018
2 parents 4f2ecb7 + 0e2f83c commit 75d2e2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions datmo/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ def track(self, input, prediction):

return response['body']['id']

def track_actual(self, id, actual):
def track_feedback(self, id, feedback):
"""
Track actual value (y_hat) for the prediction
Track feedback value (y) and other metrics after the prediction(y_hat)
Parameters
----------
Expand All @@ -203,10 +203,10 @@ def track_actual(self, id, actual):
bool
True if successful update
"""
if not isinstance(actual, dict):
if not isinstance(feedback, dict):
return False
updated_at = int(round(time.time() * 1000))
update_dict = {'updated_at': updated_at, 'actual': json.dumps(actual)}
update_dict = {'updated_at': updated_at, 'feedback': json.dumps(feedback)}
response = self.remote_api.update_actual(id, update_dict)
if response['body']['updated'] > 0:
return True
Expand Down Expand Up @@ -256,14 +256,14 @@ def search_metadata(self, filter):
for meta_data in body:
input = meta_data.get('input')
prediction = meta_data.get('prediction')
actual = meta_data.get('actual')
feedback = meta_data.get('feedback')
updated_at = meta_data.get('updated_at')
meta_data['input'] = json.loads(
input) if input is not None else None
meta_data['prediction'] = json.loads(
prediction) if prediction is not None else None
meta_data['actual'] = json.loads(
actual) if actual is not None else None
meta_data['feedback'] = json.loads(
feedback) if feedback is not None else None
meta_data['updated_at'] = int(
updated_at) if updated_at is not None else None
meta_data_list.append(meta_data)
Expand Down
6 changes: 3 additions & 3 deletions datmo/tests/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def test_set_track_double(self):
input=self.input_dict, prediction=self.prediction_dict)
assert data_id != self.test_data_id

def test_track_actual(self):
result = self.monitoring.track_actual(
id=self.test_data_id, actual=self.feedback_dict)
def test_track_feedback(self):
result = self.monitoring.track_feedback(
id=self.test_data_id, feedback=self.feedback_dict)
assert isinstance(result, bool)
assert result == True

Expand Down

0 comments on commit 75d2e2b

Please sign in to comment.