def get(self, project_id): logger.debug("Training model " + str(project_id)) logger.debug("Validating project ID " + str(project_id)) result = self.ValidateData.validate_data(project_id) if result != '': logger.debug("Validation failed for the project ") return {"status": "Error", "message": result} # Set Project Status as "Training" so that all users can see model is under training # Clear redis cache r.delete("all_projects") ProjectsModel.set_project_mode(mode="Training", project_id=project_id) result = Export.call_main(project_id) logger.debug(result) # Start Training for the model task_obj = trainer_app.send_task('tasks.train_model', kwargs={'project_id': project_id}) logger.debug("Task ID " + str(task_obj.id)) # get status status = trainer_app.AsyncResult(task_obj.id, app=trainer_app) logger.debug("Status of the task " + str(status.state)) return { "status": "Success", "message": str(status.state), "task_id": str(task_obj.id) }
def get(self, task_id): result = trainer_app.AsyncResult(task_id).result if result['Status'] == "Success": # Update the model path to Projects collection ProjectsModel.update_trained_model(result['Message']) ProjectsModel.set_project_mode(mode="Done", project_id=result['project_id']) # Clear redis cache r.delete("all_projects") return {"Status": result['Status'], "Message": result['Message']}