def get_trainings_queue(): """ swagger_from_file: yaml/training_queue.yml """ if not qa_models_integrator.is_environment_ready(): return { "msg": "Environment resources not ready, please try again later." }, 503 response = qa_models_integrator.get_training_requests(formatted=True) return response
def get_prediction(prediction_id): """ swagger_from_file: yaml/prediction_completed.yml """ if not qa_models_integrator.is_environment_ready(): return { "msg": "Environment resources not ready, please try again later." }, 503 prediction = qa_models_integrator.get_prediction(prediction_id) if not prediction: return {"msg": "prediction request id not found"}, 404 return prediction
def get_training(training_id): """ swagger_from_file: yaml/training_completed.yml """ if not qa_models_integrator.is_environment_ready(): return { "msg": "Environment resources not ready, please try again later." }, 503 training = qa_models_integrator.get_training(training_id) if not training: return {"msg": "training request id not found"}, 404 return training
def delete_training(training_id): """ swagger_from_file: yaml/training_delete.yml """ if not qa_models_integrator.is_environment_ready(): return { "msg": "Environment resources not ready, please try again later." }, 503 result_successful = qa_models_integrator.delete_training(training_id) if result_successful is None: return {"msg": "training request id not found"}, 404 if not result_successful: return {"msg": "something went wrong deleting, try again later"}, 503 return "deleted successfully"
def test_model_dir(): """ swagger_from_file: yaml/test_resources_status.yml """ actual_models_dir_present = os.path.isdir('actual_models') bert_model_dir_present = os.path.isdir('actual_models/bert-model') to_rtn = { "environment_ready": qa_models_integrator.is_environment_ready(), "actual_models_dir": actual_models_dir_present, "bert-model": bert_model_dir_present, "root_files": os.listdir(), "actual_models_files": os.listdir('actual_models') if actual_models_dir_present else [] } return to_rtn
def do_training(): """ swagger_from_file: yaml/training_request.yml """ if not qa_models_integrator.is_environment_ready(): return { "msg": "Environment resources not ready, please try again later." }, 503 documents_param = get_param(request.json, 'data', required=True) model_types_param = get_param(request.json, 'models', required=True) missing_params = check_params([documents_param, model_types_param]) if missing_params: return {"missing_required_params": missing_params}, 400 prediction_request = qa_models_integrator.do_training( documents_param['value'], model_types_param['value']) return prediction_request