self.__ps_password = getenv('PS_PASSWORD').rstrip()
self.__ps_ip = getenv('PS_IP').rstrip()
self.__ps_port = getenv('PS_PORT').rstrip()
+ self.__allow_control_access_origin = getenv('ACCESS_CONTROL_ALLOW_ORIGIN').rstrip()
self.tmgr_logger = TMLogger("common/conf_log.yaml")
self.__logger = self.tmgr_logger.logger
"""
return self.__ps_port
+ @property
+ def allow_control_access_origin(self):
+ """
+ Function for getting allow_control_access_origin
+
+ Args: None
+
+ Returns:
+ string allow_control_access_origin
+
+ """
+ return self.__allow_control_access_origin
+
def is_config_loaded_properly(self):
"""
This function checks where all environment variable got value or not.
for var in [self.__kf_adapter_ip, self.__kf_adapter_port,
self.__data_extraction_ip, self.__data_extraction_port,
self.__my_port, self.__ps_ip, self.__ps_port, self.__ps_user,
- self.__ps_password, self.__my_ip, self.__logger]:
+ self.__ps_password, self.__my_ip, self.__allow_control_access_origin, self.__logger]:
if var is None:
all_present = False
return all_present
from flask import Flask, request, send_file
from flask_api import status
import requests
-from flask_cors import cross_origin
+from flask_cors import CORS
from werkzeug.utils import secure_filename
from modelmetricsdk.model_metrics_sdk import ModelMetricsSdk
from trainingmgr.common.trainingmgr_operations import data_extraction_start, training_start, data_extraction_status, create_dme_filtered_data_job, delete_dme_filtered_data_job
@APP.route('/trainingjobs/<trainingjob_name>/<version>', methods=['GET'])
-@cross_origin()
def get_trainingjob_by_name_version(trainingjob_name, version):
"""
Rest endpoint to fetch training job details by name and version
mimetype=MIMETYPE_JSON)
@APP.route('/trainingjobs/<trainingjob_name>/<version>/steps_state', methods=['GET']) # Handled in GUI
-@cross_origin()
def get_steps_state(trainingjob_name, version):
"""
Function handling rest end points to get steps_state information for
@APP.route('/trainingjobs/<trainingjob_name>/training', methods=['POST']) # Handled in GUI
-@cross_origin()
def training(trainingjob_name):
"""
Rest end point to start training job.
@APP.route('/trainingjobs/latest', methods=['GET'])
-@cross_origin()
def trainingjobs_operations():
"""
Rest endpoint to fetch overall status, latest version of all existing training jobs
mimetype=MIMETYPE_JSON)
@APP.route("/pipelines/<pipe_name>/upload", methods=['POST'])
-@cross_origin()
def upload_pipeline(pipe_name):
"""
Function handling rest endpoint to upload pipeline.
@APP.route("/pipelines/<pipeline_name>/versions", methods=['GET'])
-@cross_origin()
def get_versions_for_pipeline(pipeline_name):
"""
Function handling rest endpoint to get versions of given pipeline name.
mimetype=MIMETYPE_JSON)
@APP.route('/pipelines', methods=['GET'])
-@cross_origin()
def get_all_pipeline_names():
"""
Function handling rest endpoint to get all pipeline names.
return APP.response_class(response=json.dumps(api_response),status=response_code,mimetype=MIMETYPE_JSON)
@APP.route('/experiments', methods=['GET'])
-@cross_origin()
def get_all_experiment_names():
"""
Function handling rest endpoint to get all experiment names.
@APP.route('/trainingjobs/<trainingjob_name>', methods=['POST', 'PUT']) # Handled in GUI
-@cross_origin()
def trainingjob_operations(trainingjob_name):
"""
Rest endpoind to create or update trainingjob
mimetype=MIMETYPE_JSON)
@APP.route('/trainingjobs/retraining', methods=['POST'])
-@cross_origin()
def retraining():
"""
Function handling rest endpoint to retrain trainingjobs in request json. trainingjob's
mimetype='application/json')
@APP.route('/trainingjobs', methods=['DELETE'])
-@cross_origin()
def delete_list_of_trainingjob_version():
"""
Function handling rest endpoint to delete latest version of trainingjob_name trainingjobs which is
mimetype=MIMETYPE_JSON)
@APP.route('/featureGroup', methods=['POST'])
-@cross_origin()
def create_feature_group():
"""
Rest endpoint to create feature group
mimetype=MIMETYPE_JSON)
@APP.route('/featureGroup', methods=['GET'])
-@cross_origin()
def get_feature_group():
"""
Rest endpoint to fetch all the feature groups
mimetype=MIMETYPE_JSON)
@APP.route('/featureGroup/<featuregroup_name>', methods=['GET'])
-@cross_origin()
def get_feature_group_by_name(featuregroup_name):
"""
Rest endpoint to fetch a feature group
mimetype=MIMETYPE_JSON)
@APP.route('/featureGroup', methods=['DELETE'])
-@cross_origin()
def delete_list_of_feature_group():
"""
Function handling rest endpoint to delete featureGroup which is
DATAEXTRACTION_JOBS_CACHE = get_data_extraction_in_progress_trainingjobs(PS_DB_OBJ)
threading.Thread(target=async_feature_engineering_status, daemon=True).start()
MM_SDK = ModelMetricsSdk()
+ list_allow_control_access_origin = TRAININGMGR_CONFIG_OBJ.allow_control_access_origin.split(',')
+ CORS(APP, resources={r"/*": {"origins": list_allow_control_access_origin}})
LOGGER.debug("Starting AIML-WF training manager .....")
APP.run(debug=True, port=int(TRAININGMGR_CONFIG_OBJ.my_port), host='0.0.0.0')
except TMException as err: