Skip to content

Commit

Permalink
Merge pull request #5 from mukeshmk/model-params
Browse files Browse the repository at this point in the history
updated API called to FMLearn to handle model parameters
  • Loading branch information
mukeshmk authored Feb 27, 2020
2 parents b5a071c + 42dcbfb commit 5a136ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion sklearn/fml/constants.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
class URI:
_SERVER = 'https://fmlearn.herokuapp.com/'
_SERVER = 'https://fmlearn.herokuapp.com'
_LOCAL = 'http://127.0.0.1:5000'

_METRIC = '/metric'
_RETRIEVE = '/retrieve'
_MAX = '/max'
_MIN = '/min'
_ALL = '/all'

def __init__(self, debug=False):
if debug:
self._SERVER = self._LOCAL

def post_metric(self):
return self._SERVER + self._METRIC

Expand Down
12 changes: 11 additions & 1 deletion sklearn/fml/fml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _post_msg(self, uri, data):
print(res.status_code)
return res.json()

def publish(self, model, metric_name, metric_value, dataset):
def publish(self, model, metric_name, metric_value, dataset, params=None):
"""
Publishes the data collected to the federated meta learning API
"""
Expand All @@ -35,6 +35,16 @@ def publish(self, model, metric_name, metric_value, dataset):
data['metric_name'] = metric_name
data['metric_value'] = metric_value
data['dataset_hash'] = dataset_hash
if params != None:
model_params = []
for key, value in params.items():
new_param = {}
new_param['param_name'] = str(key)
new_param['param_value'] = str(value)
model_params.append(new_param)
data['params'] = model_params
else:
data['params'] = ""

return self._post_msg(URI().post_metric(), data)

Expand Down

0 comments on commit 5a136ac

Please sign in to comment.