chnages to fix the flow 85/13785/1
authorrajdeep11 <rajdeep.sin@samsung.com>
Wed, 27 Nov 2024 06:33:00 +0000 (12:03 +0530)
committerrajdeep11 <rajdeep.sin@samsung.com>
Wed, 27 Nov 2024 06:33:00 +0000 (12:03 +0530)
Change-Id: Id5642d722c874072faa2a9196042e80b67dbdead
Signed-off-by: rajdeep11 <rajdeep.sin@samsung.com>
trainingmgr/controller/trainingjob_controller.py
trainingmgr/db/trainingjob_db.py
trainingmgr/service/training_job_service.py

index a7399b1..8f2cf1e 100644 (file)
@@ -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
index a39ff55..fbf42cf 100644 (file)
@@ -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
index 5594f4f..8c7dcfd 100644 (file)
@@ -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)}")