From: rajdeep11 Date: Wed, 30 Oct 2024 08:48:34 +0000 (+0530) Subject: changes in get_metadata and async_feature_engineering_status X-Git-Tag: 3.0.0~49 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=8a07f0b0ca01bbb1a3b7b6fc8609ea73033caaf3;p=aiml-fw%2Fawmf%2Ftm.git changes in get_metadata and async_feature_engineering_status Change-Id: I820f5515f903dc6b3fe2e4a237b37c6df539a47b Signed-off-by: rajdeep11 --- diff --git a/trainingmgr/common/trainingmgr_util.py b/trainingmgr/common/trainingmgr_util.py index 2c36759..c203d48 100644 --- a/trainingmgr/common/trainingmgr_util.py +++ b/trainingmgr/common/trainingmgr_util.py @@ -311,14 +311,14 @@ def get_metrics(trainingjob_name, version, mm_sdk): def handle_async_feature_engineering_status_exception_case(lock, dataextraction_job_cache, code, message, logger, is_success, - trainingjob_name, ps_db_obj, mm_sdk): + trainingjob_name, mm_sdk): """ This function changes IN_PROGRESS state to FAILED state and calls response_for_training function and remove trainingjob_name from dataextraction_job_cache. """ try: - change_in_progress_to_failed_by_latest_version(trainingjob_name, ps_db_obj) - response_for_training(code, message, logger, is_success, trainingjob_name, ps_db_obj, mm_sdk) + change_in_progress_to_failed_by_latest_version(trainingjob_name) + response_for_training(code, message, logger, is_success, trainingjob_name, mm_sdk) except Exception as err: logger.error("Failed in handle_async_feature_engineering_status_exception_case" + str(err)) finally: diff --git a/trainingmgr/trainingmgr_main.py b/trainingmgr/trainingmgr_main.py index 8c5a067..2dcbd03 100644 --- a/trainingmgr/trainingmgr_main.py +++ b/trainingmgr/trainingmgr_main.py @@ -1302,12 +1302,12 @@ def get_metadata(trainingjob_name): LOGGER.debug("Request metadata for trainingjob(name of trainingjob is %s) ", trainingjob_name) try: - results = get_all_versions_info_by_name(trainingjob_name, PS_DB_OBJ) + results = get_all_versions_info_by_name(trainingjob_name) if results: info_list = [] for trainingjob_info in results: - if (get_one_word_status(json.loads(trainingjob_info[9])) == States.FINISHED.name and - not trainingjob_info[19]): + if (get_one_word_status(json.loads(trainingjob_info.steps_state)) == States.FINISHED.name and + not trainingjob_info.deletion_in_progress): LOGGER.debug("Downloading metric for " +trainingjob_name ) data = get_metrics(trainingjob_name, trainingjob_info[11], MM_SDK) url = "http://" + str(TRAININGMGR_CONFIG_OBJ.my_ip) + ":" + \ @@ -1315,7 +1315,7 @@ def get_metadata(trainingjob_name): trainingjob_name + "/" + str(trainingjob_info[11]) + "/Model.zip" dict_data = { "accuracy": data, - "version": trainingjob_info[11], + "version": trainingjob_info.version, "url": url } info_list.append(dict_data) @@ -1671,12 +1671,13 @@ def async_feature_engineering_status(): trainingjob_name + " " + json.dumps(response)) if response["task_status"] == "Completed": - change_steps_state_of_latest_version(trainingjob_name, PS_DB_OBJ, - Steps.DATA_EXTRACTION.name, - States.FINISHED.name) - change_steps_state_of_latest_version(trainingjob_name, PS_DB_OBJ, - Steps.DATA_EXTRACTION_AND_TRAINING.name, - States.IN_PROGRESS.name) + with APP.app_context(): + change_steps_state_of_latest_version(trainingjob_name, + Steps.DATA_EXTRACTION.name, + States.FINISHED.name) + change_steps_state_of_latest_version(trainingjob_name, + Steps.DATA_EXTRACTION_AND_TRAINING.name, + States.IN_PROGRESS.name) kf_response = requests.post(url_pipeline_run, data=json.dumps({"trainingjob_name": trainingjob_name}), headers={ @@ -1700,8 +1701,7 @@ def async_feature_engineering_status(): DATAEXTRACTION_JOBS_CACHE, status.HTTP_500_INTERNAL_SERVER_ERROR, str(err) + "(trainingjob name is " + trainingjob_name + ")", - LOGGER, False, trainingjob_name, - PS_DB_OBJ, MM_SDK) + LOGGER, False, trainingjob_name, MM_SDK) #Wait and fetch latest list of trainingjobs time.sleep(10)