This project demonstrates the implementation of a fully functional ML-Ops pipeline. It includes a simple frontend built with HTML and JavaScript, and a backend using FastAPI, PyTorch, and Plotly. The pipeline allows users to select a publicly traded asset, such as Apple stock ('AAPL') or Bitcoin ('BTC-USD'). It then looks up the Model_DB for trained models corresponding to the selected symbol and plots the last 60 closing prices along with the model's predictions.
Users can train new models on the data and delete existing models directly from the user interface. For security, the API requests are safeguarded, and the app refreshes the plot 10 times after the last prediction click. Additionally, the maximum number of models is capped at 10 in the database.
The project is designed for easy extension. To add a new model architecture, simply create a new model class and a corresponding .yaml
file in the modelclasses
folder. A template for the model class is provided.
Using the Dockerfile
and requirements.txt
, you can create a Docker image by running:
docker build -t <img_name> .
Then, run the Docker container with:
docker run -d -p 8000:8000 <img_name>
To access the project on your local machine, go to: http://127.0.0.1:8000.
-
Log in as an IAM user:
aws configure
-
Log in to ECR:
aws ecr get-login-password --region <aws_region> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<aws_region>.amazonaws.com
-
Tag and push the Docker image to the ECR repository:
docker tag <docker_image_name>:latest <aws_account_id>.dkr.ecr.<aws_region>.amazonaws.com/<repository_name>:latest
docker push <aws_account_id>.dkr.ecr.<aws_region>.amazonaws.com/<repository_name>:latest
-
Create and launch an EC2 instance on AWS.
-
Log into the EC2 instance using SSH:
ssh -i <Name.pem> ec2-user@<ipv4_address>
-
Log in to ECR on the EC2 instance, pull the Docker image, and run it:
sudo aws ecr get-login-password --region <aws_region> | sudo docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<aws_region>.amazonaws.com
sudo docker pull <aws_account_id>.dkr.ecr.<aws_region>.amazonaws.com/<repository_name>:latest
sudo docker run -d --name <container_name> -p <port>:<port> <aws_account_id>.dkr.ecr.<aws_region>.amazonaws.com/<repository_name>:latest