ACCESS_CONTROL_ALLOW_ORIGIN="http://localhost:32005"
PIPELINE="{'timeseries':'qoe_pipeline'}"
MODEL_MANAGEMENT_SERVICE_IP=localhost
-MODEL_MANAGEMENT_SERVICE_PORT=12343
\ No newline at end of file
+MODEL_MANAGEMENT_SERVICE_PORT=12343
+CONF_LOG=tests/common/conf_log.yaml
\ No newline at end of file
+# ==================================================================================
+#
+# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ==================================================================================
\ No newline at end of file
"""
This module is for loading training manager configuration.
"""
-
+import os
from os import getenv
from trainingmgr.common.tmgr_logger import TMLogger
self.__allow_control_access_origin = getenv('ACCESS_CONTROL_ALLOW_ORIGIN').rstrip() if getenv('ACCESS_CONTROL_ALLOW_ORIGIN') is not None else None
self.__pipeline = getenv('PIPELINE').rstrip() if getenv('PIPELINE') is not None else None
- self.tmgr_logger = TMLogger("common/conf_log.yaml")
+ conf_filepath = getenv("CONF_LOG", "common/conf_log.yaml")
+ self.tmgr_logger = TMLogger(conf_filepath)
self.__logger = self.tmgr_logger.logger
self.__initialized = True
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ==================================================================================
\ No newline at end of file
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ==================================================================================
+from flask import Blueprint, jsonify
+from trainingmgr.common.trainingmgr_config import TrainingMgrConfig
+from trainingmgr.service.training_job_service import delete_training_job
+
+training_job_controller = Blueprint('training_job_controller', __name__)
+LOGGER = TrainingMgrConfig().logger
+
+@training_job_controller.route('/training-jobs/<int:training_job_id>', methods=['DELETE'])
+def delete_trainingjob(training_job_id):
+ TrainingMgrConfig.logger
+ LOGGER.debug(f'delete training job : {training_job_id}')
+ try:
+ if delete_training_job(str(training_job_id)):
+ LOGGER.debug(f'training job with {training_job_id} is deleted successfully.')
+ return '', 204
+ else:
+ LOGGER.debug(f'training job with {training_job_id} does not exist.')
+ return jsonify({
+ 'message': 'training job with given id is not found'
+ }), 500
+
+ except Exception as e:
+ return jsonify({
+ 'message': str(e)
+ }), 500
\ No newline at end of file
from trainingmgr.constants.steps import Steps
from trainingmgr.constants.states import States
from sqlalchemy.sql import func
+from sqlalchemy.exc import NoResultFound
from trainingmgr.common.trainingConfig_parser import getField
except Exception as err:
raise DBException(DB_QUERY_EXEC_ERROR + \
"delete_trainingjob_version" + str(err))
+
+def delete_trainingjob_by_id(id: int):
+ """
+ This function delets the trainingjob using the id which is PK
+
+ Args:
+ id (int): Primary key ID of the trainingjob
+
+ Returns:
+ bool: True if the trainingjob was not found and dleted, false if not found.
+ """
+ try:
+ tj = db.session.query(TrainingJob).get(id)
+ if tj:
+ db.session.delete(tj)
+ db.session.commit()
+ return True
+
+ except NoResultFound:
+ return False
+ except Exception as e:
+ db.session.rollback()
+ raise DBException(f'{DB_QUERY_EXEC_ERROR} : {str(e)}' )
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ==================================================================================
\ No newline at end of file
--- /dev/null
+# ==================================================================================
+#
+# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ==================================================================================
+from trainingmgr.db.trainingjob_db import delete_trainingjob_by_id
+from trainingmgr.common.exceptions_utls import DBException
+
+def delete_training_job(training_job_id : int):
+ """
+ This function handles the service to delete the training job resource by id.
+
+ Args:
+ training_job_id (int): id of training job.
+
+ Returns:
+ bool: boolean to represent if the trainingjob is deleted.
+
+ Raises:
+ DBException: If there error during operation.
+
+ """
+ try:
+ #TODO: cancel training job from kubeflow training
+ return delete_trainingjob_by_id(id=training_job_id)
+ except Exception as err :
+ raise DBException(f"delete_trainining_job failed with exception : {str(err)}")
+
get_steps_state_db, change_field_of_latest_version, get_latest_version_trainingjob_name, get_info_of_latest_version, \
change_field_value_by_version, delete_trainingjob_version, change_in_progress_to_failed_by_latest_version, \
update_model_download_url, get_all_versions_info_by_name
+from trainingmgr.controller.trainingjob_controller import training_job_controller
from trainingmgr.common.trainingConfig_parser import validateTrainingConfig, getField
APP = Flask(__name__)
-
+TRAININGMGR_CONFIG_OBJ = TrainingMgrConfig()
from middleware.loggingMiddleware import LoggingMiddleware
APP.wsgi_app = LoggingMiddleware(APP.wsgi_app)
-TRAININGMGR_CONFIG_OBJ = None
+APP.register_blueprint(training_job_controller)
PS_DB_OBJ = None
LOGGER = None
MM_SDK = None
time.sleep(10)
if __name__ == "__main__":
- TRAININGMGR_CONFIG_OBJ = TrainingMgrConfig()
try:
if TRAININGMGR_CONFIG_OBJ.is_config_loaded_properly() is False:
raise TMException("Not all configuration loaded.")