Create a FastAPI
Health Check endpoint:
- Create a conda environment for holding onn the dependencies
- Create a
main.py
file. - Add a
FastAPI
get
route for/health
which returns a string. This is the health check.
Create a FastAPI
sentiment analysis endpoint:
- Add imports for sentiment analysis model from huggingface.
- Create a sentiment analysis pipeline.
- Create a class for receiving the post request for sentiment analysis.
- Add a route to handle post requests to
sentiment
, - In the above method pass the input string through the model.
- Return the model results as the response.
Dockerize the code
- Extract all dependencies from conda into
requirements.txt
. - Create a docker file from a slim python base.
- Setup docker file to install all requirements, expose port 8000, and run uvicorn upon startup.
- Create and tag docker file.