Skip to content

Commit 5a136ac

Browse files
authored
Merge pull request #5 from mukeshmk/model-params
updated API called to FMLearn to handle model parameters
2 parents b5a071c + 42dcbfb commit 5a136ac

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

sklearn/fml/constants.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
class URI:
2-
_SERVER = 'https://fmlearn.herokuapp.com/'
2+
_SERVER = 'https://fmlearn.herokuapp.com'
3+
_LOCAL = 'http://127.0.0.1:5000'
34

45
_METRIC = '/metric'
56
_RETRIEVE = '/retrieve'
67
_MAX = '/max'
78
_MIN = '/min'
89
_ALL = '/all'
910

11+
def __init__(self, debug=False):
12+
if debug:
13+
self._SERVER = self._LOCAL
14+
1015
def post_metric(self):
1116
return self._SERVER + self._METRIC
1217

sklearn/fml/fml_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _post_msg(self, uri, data):
2222
print(res.status_code)
2323
return res.json()
2424

25-
def publish(self, model, metric_name, metric_value, dataset):
25+
def publish(self, model, metric_name, metric_value, dataset, params=None):
2626
"""
2727
Publishes the data collected to the federated meta learning API
2828
"""
@@ -35,6 +35,16 @@ def publish(self, model, metric_name, metric_value, dataset):
3535
data['metric_name'] = metric_name
3636
data['metric_value'] = metric_value
3737
data['dataset_hash'] = dataset_hash
38+
if params != None:
39+
model_params = []
40+
for key, value in params.items():
41+
new_param = {}
42+
new_param['param_name'] = str(key)
43+
new_param['param_value'] = str(value)
44+
model_params.append(new_param)
45+
data['params'] = model_params
46+
else:
47+
data['params'] = ""
3848

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

0 commit comments

Comments
 (0)