Skip to content

hosimesi/aws-mlops-practice

Repository files navigation

AWS MLOps Practice

This repository provides practice code to build MLOps on AWS. This service specifically focuses on Operation in MLOps. The Python application code is meant to be referenced from the following GitHub: https://github.com/nsakki55/aws-mlops-handson

Key Features

Python Development Environment

We guide you through setting up a Python development environment that ensures code quality and maintainability. This environment is carefully configured to enable efficient development practices and facilitate collaboration.

Parallel Train Pipeline and Model Versioning

This repository includes the implementation of a training pipeline. This pipeline covers the stages, including data preprocessing, model training, and evaluation. This repository also allows multiple models to be trained in parallel and finally the inference server can be updated. We can also use DynamoDB to version control your models and sanity check before model serving.

Inference Server

This repository provides an implementation of a prediction server that serves predictions based on your trained CTR prediction model. Canary release is also achieved by separating the ALB target group.

Monitoring System

We offer a comprehensive monitoring system using Grafana and Prometheus. Software metrics of the inference server, predictions, and data drift in the learning pipeline can also be detected

AWS Deployment

To showcase industry-standard practices, this repository guide you in deploying the training pipeline, inference server and dashboard on AWS.

AWS Infra Architecture

AWS Infra Architecture made by this repository.

ML Pipeline

ml_pipeline

Inference Server

inference_server

Requirements

Software Install (Mac)
pyenv brew install pyenv
Poetry curl -sSL https://install.python-poetry.org | python3 -
direnv brew install direnv
Terraform brew install terraform
Docker install via dmg
docker-buildx brew install docker-buildx
awscli curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"

Setup

Install Python Dependencies

Use pyenv to install Python 3.11.7 environment

$ pyenv install 3.11.7
$ pyenv local 3.11.7

Use poetry to install library dependencies

$ poetry install

Configure environment variable

Use direnv to configure environment variable

$ cp .env.example .env
$ direnv allow .

Set your environment variable setting

AWS_REGION=ap-northeast-1
AWS_ACCOUNT_ID=
AWS_PROFILE=mlops-practice
AWS_ALB_DNS=
USER_NAME=
S3_BUCKET=${USER_NAME}-mlops-practice

TF_VAR_aws_region=${AWS_REGION}
TF_VAR_aws_profile=${AWS_PROFILE}
TF_VAR_aws_account_id=${AWS_ACCOUNT_ID}
TF_VAR_name=${USER_NAME}

Create AWS Resources

Use terraform to create aws resources. Apply terraform

$ make init
$ make plan
$ make apply

Prepare train data

unzip train data

$ unzip data.zip

upload train data to S3

$ make upload

Code static analysis tool

Tool Usage
ruff Format code style, format import statement, and code quality check check
mypy Static type checking
pytest Test Code
tox Virtual env for develop

Usage

Build ML Pipeline

$ make build-ml

Run ML Pipeline

$ make run-ml

Build Predict API

$ make build-predictor

Run Predict API locally

$ docker compose up --build

Shutdown Predict API locally

$ docker compose down

Request Local Predict API

$ make predict

Run formatter

$ make format

Run pytest, ruff, mypy

$ tox

There are many more commands, check the Makefile.(fluentd, grafana, prometheus, canary, importer)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published