Giter VIP home page Giter VIP logo

classifieraws's Introduction

Classifier AWS Deployment

This is a minimal implementation of a pipeline that deploys a simple text classifier into the AWS cloud using the AWS Cloud Development Kit (CDK).

Installation

Create a virtual environment and install the dependencies:

python -m venv .env
source .venv/bin/activate
pip install -r requirements.txt

You can test the installation by running:

PYTHONPATH=. pytest classifier/tests

Before Deployment

  • Make sure you have a valid AWS account and installed the command line tools CDK installed
  • Create an AWS IAM user providing the credentials for creating resources.
  • Set up a CLI profile with the IAM credentials and a default region (e.g. eu-central-1)
  • Get your 12-digit IAM account id using aws sts get-caller-identity
  • Create an AWS GitHub connection which allows AWS to clone your fork of this repo. The connection has a unique id (ARN).
  • Open the file infrastructure/app.py and put the default region (e.g. eu-central-1) and account id and github connection ARN into the dictionary shared_context

Deployment

Train a valid classifier:

PYTHONPATH=. python  classifier/train.py

The model will be saved under /tmp/classifier.pkl. When you trigger the deployment the pipeline will look for the model in the S3 bucket specified in the shared_context in the file infrastructure/app.py, thus you need to upload it there first. Create a new bucket in the AWS S3 console with the name classifier-serving-model-bucket and upload the classifier to the bucket.

Go to infrastructure, create a virtual environment and install the dependencies:

cd infrastructure
python -m venv .env
source .venv/bin/activate
pip install -r requirements.txt

Synthesize and deploy the CloudFormation template:

cd infrastructure
cdk synth
cdk deploy classifier-cicd-stack classifier-networking-stack classifier-serving-stack

Once the deployment is finished you can go to the AWS console and verify that the CodePipeline build went through. Logs are under CloudWatch/insights. The classifier will is exposed to the internet via a LoadBalancer, whose DNS you can find under the EC2 service: Go to Load balancers and click on the running instance, the DNS will be displayed there. If you copy+paste the dns-address to your browser as: dns-address/classify then the input text field for the classifier should be displayed.

Make sure you destroy the resources once you don't need them anymore:

cdk destroy classifier-cicd-stack classifier-networking-stack classifier-serving-stack

classifieraws's People

Contributors

cschaefer26 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.