"""
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": []
},
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:
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
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