def __init__(self):
     self.DomainModel = DomainsModel()
     self.IntentsModel = IntentsModel()
     self.StoryModel = StoryModel()
     self.ResponseModel = ResponseModel()
     self.EntityModel = EntityModel()
     self.CustomActionsModel = CustomActionsModel()
     self.ValidateData = ValidateData()
     self.project_home = ''
     #self.project_base_path = '../vol_chatbot_data/temp/trainer-sessions/'
     self.project_base_path = ''
     self.session_id = ''
     self.master_nlu = {"rasa_nlu_data": {"common_examples": []}}
     self.master_stories = ""
     self.master_domain_intents = ""
     self.master_domain_actions = ""
     self.master_domain_templates = ""
     self.master_domain_entities = ""
class TrainModel(Resource):
    def __init__(self):
        self.ValidateData = ValidateData()

    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 __init__(self):
     self.ValidateData = ValidateData()