From: rajdeep11 Date: Wed, 27 Nov 2024 06:33:00 +0000 (+0530) Subject: chnages to fix the flow X-Git-Tag: 3.0.0~26 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=97ae14e8f7159824f76ebad817d627f67dafb77f;p=aiml-fw%2Fawmf%2Ftm.git chnages to fix the flow Change-Id: Id5642d722c874072faa2a9196042e80b67dbdead Signed-off-by: rajdeep11 --- diff --git a/trainingmgr/controller/trainingjob_controller.py b/trainingmgr/controller/trainingjob_controller.py index a7399b1..8f2cf1e 100644 --- a/trainingmgr/controller/trainingjob_controller.py +++ b/trainingmgr/controller/trainingjob_controller.py @@ -94,7 +94,7 @@ def create_trainingjob(): def get_trainingjobs(): LOGGER.debug(f'get the trainingjobs') try: - resp = get_trainining_jobs() + resp = trainingjob_schema.dump(get_trainining_jobs()) return jsonify(resp), 200 except TMException as err: return jsonify({ @@ -109,7 +109,7 @@ def get_trainingjobs(): def get_trainingjob(training_job_id): LOGGER.debug(f'get the trainingjob correspoinding to id: {training_job_id}') try: - return jsonify(get_training_job(training_job_id)), 200 + return jsonify(trainingjob_schema.dump(get_training_job(training_job_id))), 200 except TMException as err: return jsonify({ 'message': str(err) @@ -127,5 +127,5 @@ def get_trainingjob_status(training_job_id): return jsonify(json.loads(status)), 200 except Exception as err: return jsonify({ - 'message': str(e) + 'message': str(err) }), 500 \ No newline at end of file diff --git a/trainingmgr/db/trainingjob_db.py b/trainingmgr/db/trainingjob_db.py index a39ff55..fbf42cf 100644 --- a/trainingmgr/db/trainingjob_db.py +++ b/trainingmgr/db/trainingjob_db.py @@ -369,4 +369,14 @@ def get_trainingjob_by_modelId_db(model_id): except NoResultFound: return None except Exception as e: - raise DBException(f'{DB_QUERY_EXEC_ERROR} in the get_trainingjob_by_modelId_db : {str(e)}') \ No newline at end of file + raise DBException(f'{DB_QUERY_EXEC_ERROR} in the get_trainingjob_by_modelId_db : {str(e)}') + +def change_steps_state(trainingjob, step: Steps, state:States): + try: + steps_state = json.loads(trainingjob.steps_state.states) + steps_state[step] = state + trainingjob.steps_state.states=json.dumps(steps_state) + db.session.add(trainingjob) + db.session.commit() + except Exception as e: + raise DBException(f'{DB_QUERY_EXEC_ERROR} in the change_steps_state : {str(e)}') \ No newline at end of file diff --git a/trainingmgr/service/training_job_service.py b/trainingmgr/service/training_job_service.py index 5594f4f..8c7dcfd 100644 --- a/trainingmgr/service/training_job_service.py +++ b/trainingmgr/service/training_job_service.py @@ -25,15 +25,14 @@ trainingJobsSchema = TrainingJobSchema(many=True) def get_training_job(training_job_id: int): try: tj =get_trainingjob(training_job_id) - return trainingJobSchema.dump(tj) + return tj except DBException as err: raise TMException(f"get_training_job by id failed with exception : {str(err)}") def get_trainining_jobs(): try: tjs = get_trainingjob() - result = trainingJobsSchema.dump(tjs) - return result + return tjs except DBException as err: raise TMException(f"get_training_jobs failed with exception : {str(err)}")