From: rajdeep11 Date: Fri, 8 Dec 2023 11:14:28 +0000 (+0530) Subject: upload trained model to mme X-Git-Tag: 1.2.0~5 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=8980dc60e1719446fc903c947e51399d6aa801d0;p=aiml-fw%2Fawmf%2Ftm.git upload trained model to mme Issue-Id: AIMLFW-65 Change-Id: Ib0acf11be847e8f2b2b9ac5897f74511fad40f5e Signed-off-by: rajdeep11 --- diff --git a/tests/test_tm_apis.py b/tests/test_tm_apis.py index 77944b0..ed7733c 100644 --- a/tests/test_tm_apis.py +++ b/tests/test_tm_apis.py @@ -139,13 +139,18 @@ class Test_pipeline_notification: message1="Pipeline notification success." code1=status.HTTP_200_OK response_tuple1=({"result": message1}, code1) + db_result = [('usecase1', 'uc1', '*', 'qoe Pipeline lat v2', 'Default', '{"arguments": {"epochs": "1", "trainingjob_name": "usecase1"}}', + '', datetime.datetime(2022, 10, 12, 10, 0, 59, 923588), '51948a12-aee9-42e5-93a0-b8f4a15bca33', + '{"DATA_EXTRACTION": "FINISHED", "DATA_EXTRACTION_AND_TRAINING": "FINISHED", "TRAINING": "FINISHED", "TRAINING_AND_TRAINED_MODEL": "FINISHED", "TRAINED_MODEL": "FAILED"}', + datetime.datetime(2022, 10, 12, 10, 2, 31, 888830), 1, False, '3', '{"datalake_source": {"InfluxSource": {}}}', 'No data available.', '', 'liveCell', 'UEData', False, False, "","")] @patch('trainingmgr.trainingmgr_main.MM_SDK', return_value = mocked_mm_sdk) @patch('trainingmgr.trainingmgr_main.TRAININGMGR_CONFIG_OBJ', return_value = mocked_TRAININGMGR_CONFIG_OBJ) @patch('trainingmgr.trainingmgr_main.change_steps_state_of_latest_version') @patch('trainingmgr.trainingmgr_main.update_model_download_url') + @patch('trainingmgr.trainingmgr_main.get_trainingjob_info_by_name', return_value=db_result) @patch('trainingmgr.trainingmgr_main.get_latest_version_trainingjob_name', return_value = "usecase1") @patch('trainingmgr.trainingmgr_main.response_for_training', return_value = response_tuple1) - def test_pipeline_notification(self,mock1, mock2, mock3, mock4, mock5, mock6): + def test_pipeline_notification(self,mock1, mock2, mock3, mock4, mock5, mock6, mock7): trainingmgr_main.LOGGER.debug("******* test_pipeline_notification post *******") trainingjob_req = { "trainingjob_name":"usecase1", diff --git a/trainingmgr/trainingmgr_main.py b/trainingmgr/trainingmgr_main.py index 1d0bbd0..2668c3a 100644 --- a/trainingmgr/trainingmgr_main.py +++ b/trainingmgr/trainingmgr_main.py @@ -536,6 +536,22 @@ def pipeline_notification(): change_steps_state_of_latest_version(trainingjob_name, PS_DB_OBJ, Steps.TRAINED_MODEL.name, States.FINISHED.name) + # upload to the mme + trainingjob_info=get_trainingjob_info_by_name(trainingjob_name, PS_DB_OBJ) + + is_mme= trainingjob_info[0][20] + if is_mme: + model_name=trainingjob_info[0][21] #model_name + file=MM_SDK.get_model_zip(trainingjob_name, str(version)) + url ="http://"+str(TRAININGMGR_CONFIG_OBJ.model_management_service_ip)+":"+str(TRAININGMGR_CONFIG_OBJ.model_management_service_port)+"/uploadModel/{}".format(model_name) + LOGGER.debug("url for upload is: ", url) + resp2=requests.post(url=url, files={"file":('Model.zip', file, 'application/zip')}) + if resp2.status_code != status.HTTP_200_OK : + errMsg= "Upload to mme failed" + LOGGER.error(errMsg + trainingjob_name) + raise TMException(errMsg + trainingjob_name) + + LOGGER.debug("Model uploaded to the MME") else: errMsg = "Trained model is not available " LOGGER.error(errMsg + trainingjob_name)