I have a flask_restful api. I have divided the structure in few parts like:
app:
-api.py
-resources
--resource1.py
--resource2.py
resource1 file have structure like:
class Func(Resource):
def __init__(self):
model = some_module.from_pretrained("xyz")
model.eval()
model.to(self.device)
self.model = model
def post(self):
#taking some input to be eavaluated
output = fun1(self.model, input//) //fun1 is already defined function
return processed output
api file is like this:
#importing requirements
app = Flask(__name__)
api = Api(app)
cache.init_app(app)
api.add_resource(Func, '/output')
if __name__ == "__main__":
app.run(port='5000', debug = True)
I want to use cache for the model. I followed several articles but I'm not able to implement it correctly, so if anyone can give a solution, it will be helpful.