Fixes for DME enabled FeatureGroup-Creation 73/13973/1
authorashishj1729 <jain.ashish@samsung.com>
Tue, 24 Dec 2024 13:57:58 +0000 (19:27 +0530)
committerashishj1729 <jain.ashish@samsung.com>
Tue, 24 Dec 2024 13:59:51 +0000 (19:29 +0530)
Change-Id: Ifdaeff8716faa82cc58dd347c8d78f96b6337b73
Signed-off-by: ashishj1729 <jain.ashish@samsung.com>
trainingmgr/common/trainingmgr_operations.py
trainingmgr/common/trainingmgr_util.py
trainingmgr/controller/featuregroup_controller.py
trainingmgr/controller/trainingjob_controller.py

index b9d8311..6aedbfe 100644 (file)
@@ -138,17 +138,20 @@ def create_dme_filtered_data_job(training_config_obj, source_name, features, fea
     """
     This function calls Non-RT RIC DME APIs for creating filter PM data jobs.
     """
+    # Converts 'a ,b,  c, d' --> ['a', 'b', 'c', 'd']
+    feature_list = [word.strip() for word in features.split(',') if word != '']
+    source_list = [word.strip() for word in source_name.split(',') if word != '']
     logger = training_config_obj.logger
     job_json = {
         "info_type_id": "PmData",
         "job_owner": "console",
         "job_definition": {
           "filter":{
-              "sourceNames":[source_name],
+              "sourceNames": source_list,
                "measObjInstIds": [],
                "measTypeSpecs": [{
                   "measuredObjClass": measured_obj_class,
-                  "measTypes":features
+                  "measTypes": feature_list
                 }],
                 "measuredEntityDns": []
           },
index f555df5..d7a8c43 100644 (file)
@@ -301,5 +301,4 @@ def check_trainingjob_name_and_version(trainingjob_name, version):
 def check_trainingjob_name_or_featuregroup_name(name):
     if re.fullmatch(PATTERN, name):
         return True
-    return False
-
+    return False    
\ No newline at end of file
index af4ace4..5ce3cad 100644 (file)
@@ -90,7 +90,6 @@ def create_feature_group():
         All exception are provided with exception message and HTTP status code."""
     
     api_response = {}
-    response_code = status.HTTP_500_INTERNAL_SERVER_ERROR
     LOGGER.debug('feature Group Create request, ' + json.dumps(request.json))
 
     try:
@@ -101,26 +100,25 @@ def create_feature_group():
         if (not check_trainingjob_name_or_featuregroup_name(feature_group_name) or
             len(feature_group_name) < 3 or len(feature_group_name) > 63):
             api_response = {"Exception": "Failed to create the feature group since feature group not valid"}
-            response_code = status.HTTP_400_BAD_REQUEST
+            return jsonify(api_response), status.HTTP_400_BAD_REQUEST
         else:
             # the features are stored in string format in the db, and has to be passed as list of feature to the dme. Hence the conversion.
             add_featuregroup(featuregroup)
             api_response = FeatureGroupSchema().dump(featuregroup)
-            response_code =status.HTTP_200_OK
+
             if featuregroup.enable_dme == True :
-                response= create_dme_filtered_data_job(TRAININGMGR_CONFIG_OBJ, featuregroup)
+                response= create_dme_filtered_data_job(TRAININGMGR_CONFIG_OBJ, featuregroup.source_name, featuregroup.feature_list, featuregroup.featuregroup_name, featuregroup.host, featuregroup.dme_port, featuregroup.measured_obj_class)
                 if response.status_code != 201:
-                    api_response={"Exception": "Cannot create dme job"}
                     delete_feature_group_by_name(featuregroup)
-                    response_code=status.HTTP_400_BAD_REQUEST
+                    return jsonify({"Exception": "Cannot create dme job"}), status.HTTP_400_BAD_REQUEST
     except ValidationError as err:
         LOGGER.error(f"Failed to create the feature Group {str(err)}")
         return {"Exception": str(err)}, 400
     except DBException as err:
         LOGGER.error(f"Failed to create the feature Group {str(err)}")
         return {"Exception": str(err)}, 400
-    except Exception as e:
-        api_response = {"Exception":str(e)}
+    except Exception as err:
+        api_response = {"Exception":str(err)}
         LOGGER.error(f"Failed to create the feature Group {str(err)}")
         jsonify(json.dumps(api_response)), 500
     
index 0761768..40e0436 100644 (file)
@@ -25,7 +25,7 @@ from trainingmgr.common.exceptions_utls import TMException
 from trainingmgr.common.trainingmgr_config import TrainingMgrConfig
 from trainingmgr.schemas.trainingjob_schema import TrainingJobSchema
 from trainingmgr.service.training_job_service import delete_training_job, create_training_job, get_training_job, get_trainingjob_by_modelId, get_trainining_jobs, \
-get_steps_state, update_trainingPipeline
+get_steps_state
 from trainingmgr.common.trainingmgr_util import check_key_in_dictionary
 from trainingmgr.common.trainingConfig_parser import validateTrainingConfig
 from trainingmgr.service.mme_service import get_modelinfo_by_modelId_service