This project is initially built for a technical challenge to join Junior MLOPS Postion

It is a sentiment analysis service built with FastAPI. It utilizes a machine learning model(ROBERTA) to analyze text and determine sentiment (Positive, Negative, Neutral). The service is containerized using Docker for easy deployment and scalability.
- Sentiment analysis of textual data.
- RESTful API endpoint.
- Integration with RDS(PostgreSQL) database for logging predictions.
- Docker support for easy deployment.
These instructions will get your copy of the project up and running on your local machine for development and testing purposes.
- Python 3.12+
- Docker
- PostgreSQL (For local testing or if not using AWS RDS)
-
Clone the repository:
git clone https://github.com/lillianassefa/MLopsTechnicalChallenge.git cd MLopsTechnicalChallenge/app -
Set up a virtual environment (Optional but recommended):
python -m venv venv source venv/bin/activate # On Windows usevenv\Scripts\activate -
Install Dependencies:
pip install -r requirements.txt -
Set Environment Variable
Set up the following environment variables, either in a .env file or in your environment: DB_NAME: postgres DB_USER: postgres DB_PASSWORD: Database password DB_HOST: microservicemodel.crwuq2iiy62m.us-east-1.rds.amazonaws.com DB_PORT: 5432 AWS_ACCESS_KEY_ID: AWS access key AWS_SECRET_ACCESS_KEY: AWS secret access key BUCKET_NAME: modelforpredict
-
Running the application locally
uvicorn main:app --reload
-
Build docker image
docker build -t microservicesentimentpredict -
Run docker container
docker run -d -p 8000:8000 fastapi-sentiment-app
There is one api endpoint which is /predict which is used to accept text input from user and outputs the sentiment value.
GET /ping: Health check endpoint. POST /predict: Endpoint to submit text for sentiment analysis. Request body format:
{"text": "Your sample text here"}
The application can be tested using Postman or the Swagger UI at http://localhost:8000/docs.
Please feel free to contribute to this project and give suggestions
This project is licensed under the MIT License - see the LICENSE.md file for details.