Skip to content

Commit f9a4e5b

Browse files
author
Sunil Thaha
authored
Merge pull request #411 from sunya-ch/server-api-rebase-patch-1
chore: change spec to machine_spec in server /model
2 parents 9567ebe + f902773 commit f9a4e5b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/kepler_model/estimate/model_server_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def make_model_request(power_request, machine_spec=None):
2323
"filter": power_request.filter,
2424
"trainer_name": power_request.trainer_name}
2525
if machine_spec is not None:
26-
model_request["spec"] = machine_spec
26+
model_request["machine_spec"] = machine_spec
2727
return model_request
2828

2929

src/kepler_model/server/model_server.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454

5555
class ModelRequest:
56-
def __init__(self, metrics, output_type, source="rapl-sysfs", node_type=-1, weight=False, trainer_name="", filter="", pipeline_name="", spec=None, loose_node_type=True):
56+
def __init__(self, metrics, output_type, source="rapl-sysfs", node_type=-1, weight=False, trainer_name="", filter="", pipeline_name="", machine_spec=None, loose_node_type=True):
5757
# target source of power metric to be predicted (e.g., rapl-sysfs, acpi)
5858
self.source = convert_enery_source(source)
5959
# type of node to select a model learned from similar nodes (default: -1, applied universal model learned by all node_type (TODO))
@@ -71,9 +71,9 @@ def __init__(self, metrics, output_type, source="rapl-sysfs", node_type=-1, weig
7171
# specific pipeline (default: empty, selecting default pipeline)
7272
self.pipeline_name = pipeline_name
7373
# spec of requesting node to determine node_type
74-
self.spec = NodeTypeSpec()
75-
if spec is not None:
76-
self.spec = NodeTypeSpec(**spec)
74+
self.machine_spec = NodeTypeSpec()
75+
if machine_spec is not None:
76+
self.machine_spec = NodeTypeSpec(**machine_spec)
7777
self.loose_node_type = loose_node_type
7878

7979
# ModelListParams defines parameters for /best-models API
@@ -194,13 +194,13 @@ def get_model():
194194
pipeline_name = pipelineName[energy_source]
195195
valid_group_path = get_model_group_path(model_toppath, output_type, fg, energy_source, pipeline_name=pipelineName[energy_source])
196196
node_type = req.node_type
197-
if req.node_type == any_node_type and req.spec is not None and not req.spec.is_none() and pipeline_name in nodeCollection:
198-
node_type, uncertainty, looseness = nodeCollection[pipeline_name].get_node_type(req.spec, loose_search=True)
197+
if req.node_type == any_node_type and req.machine_spec is not None and not req.machine_spec.is_none() and pipeline_name in nodeCollection:
198+
node_type, uncertainty, looseness = nodeCollection[pipeline_name].get_node_type(req.machine_spec, loose_search=True)
199199
else:
200200
uncertainty = 0
201201
looseness = 0
202202
if os.path.exists(valid_group_path):
203-
best_candidate, response = select_best_model(req.spec, valid_group_path, filters, energy_source, req.pipeline_name, req.trainer_name, node_type, req.weight, loose_node_type=req.loose_node_type)
203+
best_candidate, response = select_best_model(req.machine_spec, valid_group_path, filters, energy_source, req.pipeline_name, req.trainer_name, node_type, req.weight, loose_node_type=req.loose_node_type)
204204
if best_candidate is None:
205205
continue
206206
if node_type != any_node_type and best_model is not None and get_node_type_from_name(best_model['model_name']) == node_type:

tests/model_select_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_node_types(energy_source):
3131
def make_request_with_spec(metrics, output_type, node_type=-1, trainer_name="", energy_source='rapl-sysfs', spec=None):
3232
weight = False
3333
model_request = get_model_request_json(metrics, output_type, node_type, weight, trainer_name, energy_source)
34-
model_request["spec"] = spec
34+
model_request["machine_spec"] = spec
3535
response = requests.post(f'http://localhost:{MODEL_SERVER_PORT}/model', json=model_request)
3636
assert response.status_code == 200, response.text
3737
output_path = os.path.join(download_path, output_type.name)

0 commit comments

Comments
 (0)