import validators
from trainingmgr.common.exceptions_utls import TMException
from flask_api import status
+from trainingmgr.db.trainingjob_db import get_steps_state_db
MIMETYPE_JSON = "application/json"
errMsg="model info can't be fetched, model_name: {} , err: {}".format(model_name, response.text)
logger.error(errMsg)
raise TMException(errMsg)
+
+def notification_rapp(trainingjob, training_config_obj):
+ steps_state = get_steps_state_db(trainingjob.trainingjob_name)
+ response = requests.post(trainingjob.notification_url,
+ data=json.dumps(steps_state),
+ headers={
+ 'content-type': MIMETYPE_JSON,
+ 'Accept-Charset': 'UTF-8'
+ })
+ if response.status_code != 200:
+ raise TMException("Notification failed: "+response.text)
\ No newline at end of file
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, \
- get_model_info
+ get_model_info, notification_rapp
from trainingmgr.common.trainingmgr_config import TrainingMgrConfig
from trainingmgr.common.trainingmgr_util import get_one_word_status, check_trainingjob_data, \
check_key_in_dictionary, get_one_key, \
States.IN_PROGRESS.name)
change_field_of_latest_version(trainingjob_name,
"run_id", json_data["run_id"])
+ notification_rapp(trainingjob, TRAININGMGR_CONFIG_OBJ)
else:
raise TMException("KF Adapter- run_status in not scheduled")
except requests.exceptions.ConnectionError as err:
run_status = request.json["run_status"]
if run_status == 'SUCCEEDED':
+
+ trainingjob_info=get_trainingjob_info_by_name(trainingjob_name)
change_steps_state_of_latest_version(trainingjob_name,
Steps.TRAINING.name,
States.FINISHED.name)
change_steps_state_of_latest_version(trainingjob_name,
Steps.TRAINING_AND_TRAINED_MODEL.name,
States.IN_PROGRESS.name)
-
+ notification_rapp(trainingjob_info, TRAININGMGR_CONFIG_OBJ)
+
version = get_latest_version_trainingjob_name(trainingjob_name)
+
change_steps_state_of_latest_version(trainingjob_name,
Steps.TRAINING_AND_TRAINED_MODEL.name,
States.FINISHED.name)
change_steps_state_of_latest_version(trainingjob_name,
Steps.TRAINED_MODEL.name,
States.IN_PROGRESS.name)
-
+ notification_rapp(trainingjob_info, TRAININGMGR_CONFIG_OBJ)
+
if MM_SDK.check_object(trainingjob_name, version, "Model.zip"):
model_url = "http://" + str(TRAININGMGR_CONFIG_OBJ.my_ip) + ":" + \
str(TRAININGMGR_CONFIG_OBJ.my_port) + "/model/" + \
change_steps_state_of_latest_version(trainingjob_name,
Steps.TRAINED_MODEL.name,
States.FINISHED.name)
+ notification_rapp(trainingjob_info, TRAININGMGR_CONFIG_OBJ)
# upload to the mme
- trainingjob_info=get_trainingjob_info_by_name(trainingjob_name)
-
- is_mme = getField(trainingjob_info.training_config, "is_mme")
+ is_mme= trainingjob_info.is_mme
if is_mme:
model_name=trainingjob_info.model_name #model_name
file=MM_SDK.get_model_zip(trainingjob_name, str(version))