Skip to content

Commit

Permalink
Update 'get_model_info' code in tm
Browse files Browse the repository at this point in the history
- update 'get_model_info' code to reflect 'modelmgmtservice' changes(AIMLFW-128)
- update test code and test input data as well

Issue-ID: AIMLFW-136

Change-Id: I7a3f8772ef94c82b8e53c594da1fd295886f47b0
Signed-off-by: gyuyoung <[email protected]>
  • Loading branch information
gyu-young-park committed Aug 26, 2024
1 parent 3574ae6 commit 249e5cc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
34 changes: 29 additions & 5 deletions tests/test_trainingmgr_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,46 @@ class Test_get_model_info:
@patch('trainingmgr.common.trainingmgr_operations.requests.get')
def test_get_model_info(self,mock_requests_get):
training_config_obj = DummyVariable()
model_name="abc"
model_name="qoe"
rapp_id = "rapp_1"
meta_info = {
"test": "test"
}

model_data = {
"model-name": model_name,
"rapp-id": rapp_id,
"meta-info": meta_info
}
mock_response=MagicMock(spec=Response)
mock_response.status_code=200
mock_response.json.return_value={'message':'{"abc":"bca"}'}
mock_response.json.return_value={'message': {"name": model_name, "data": json.dumps(model_data)}}
mock_requests_get.return_value= mock_response
model_info=trainingmgr_operations.get_model_info(training_config_obj, model_name)
expected_model_info={'abc': 'bca'}
expected_model_info={
"model-name": model_name,
"rapp-id": rapp_id,
"meta-info": meta_info
}
assert model_info==expected_model_info, "get model info failed"

@patch('trainingmgr.common.trainingmgr_operations.requests.get')
def test_negative_get_model_info(self,mock_requests_get):
training_config_obj = DummyVariable()
model_name="abc"
model_name="qoe"
rapp_id = "rapp_1"
meta_info = {
"test": "test"
}

model_data = {
"model-name": model_name,
"rapp-id": rapp_id,
"meta-info": meta_info
}
mock_response=MagicMock(spec=Response)
mock_response.status_code=500
mock_response.json.return_value={'message':'{"abc":"bca"}'}
mock_response.json.return_value={'message': {"name": model_name, "data": json.dumps(model_data)}}
mock_requests_get.return_value= mock_response
try:
model_info=trainingmgr_operations.get_model_info(training_config_obj, model_name)
Expand Down
2 changes: 1 addition & 1 deletion trainingmgr/common/trainingmgr_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_model_info(training_config_obj, model_name):
url ="http://"+str(model_management_service_ip)+":"+str(model_management_service_port)+"/getModelInfo/{}".format(model_name)
response = requests.get(url)
if(response.status_code==status.HTTP_200_OK):
model_info=json.loads(response.json()['message'])
model_info=json.loads(response.json()['message']["data"])
return model_info
else:
errMsg="model info can't be fetched, model_name: {} , err: {}".format(model_name, response.text)
Expand Down

0 comments on commit 249e5cc

Please sign in to comment.