GithubHelp home page GithubHelp logo

sudkul / nd9991-p4 Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 225 KB

Solution to ND9991 P4 Project: Operationalize a Machine Learning Microservice API

License: MIT License

Dockerfile 7.84% Makefile 21.12% Python 35.65% Shell 35.39%

nd9991-p4's Introduction

CircleCI

Project Overview

In this project, you will apply the skills you have acquired in this course to operationalize a Machine Learning Microservice API.

You are given a pre-trained, sklearn model that has been trained to predict housing prices in Boston according to several features, such as average rooms in a home and data about highway access, teacher-to-pupil ratios, and so on. You can read more about the data, which was initially taken from Kaggle, on the data source site. This project tests your ability to operationalize a Python flask app—in a provided file, app.py—that serves out predictions (inference) about housing prices through API calls. This project could be extended to any pre-trained machine learning model, such as those for image recognition and data labeling.

Files present in thiis repo are:

.
├── .circleci
│   └── config.yml      # Project TODO
├── Dockerfile          # Project TODO
├── LICENSE
├── Makefile       
├── README.md           # Project TODO
├── app.py              # Project TODO
├── make_prediction.sh  
├── model_data
│   ├── boston_housing_prediction.joblib
│   └── housing.csv
├── output_txt_files    # Project TODO
│   ├── docker_out.txt
│   └── kubernetes_out.txt
├── requirements.txt
├── run_docker.sh       # Project TODO
├── run_kubernetes.sh   # Project TODO
└── upload_docker.sh    # Project TODO

Project Tasks

Your project goal is to operationalize this working, machine learning microservice using kubernetes, which is an open-source system for automating the management of containerized applications. In this project you will:

  • Test your project code using linting
  • Complete a Dockerfile to containerize this application
  • Deploy your containerized application using Docker and make a prediction
  • Improve the log statements in the source code for this application
  • Configure Kubernetes and create a Kubernetes cluster
  • Deploy a container using Kubernetes and make a prediction
  • Upload a complete Github repo with CircleCI to indicate that your code has been tested

You can find a detailed project rubric, here.

The final implementation of the project will showcase your abilities to operationalize production microservices.


Setup the Environment

  • Create a virtualenv and activate it.
python3 -m pip install --user virtualenv
# You should have Python 3.7 available in your host. 
# Check the Python path using `which python3`
# Use a command similar to this one:
python3 -m virtualenv --python=<path-to-Python3.7> .devops
source .devops/bin/activate

Project Steps

Task 0: Test the App Locally

# Check/Update the requirements.txt
# Install the necessary dependencies
make install
python app.py

Task 1: Complete the Dockerfile

# Update the Dockerfile
make lint

Task 2: Run a Container & Make a Prediction

# Update the run_docker.sh
chmod +x run_docker.sh
./run_docker.sh
docker exec -it [container-name] bash
# Check the ports in the make_prediction.sh file
chmod +x make_prediction.sh
./make_prediction.sh

Task 3: Improve Logging & Save Output

Save the output to the nd9991-p4/output_txt_files/docker_out.txt file.

Task 4: Upload the Docker Image

# Complete the upload_docker.sh file
# Create a repo in Docker hub
docker login
./upload_docker.sh

[Optional] Task 5: Configure Kubernetes to Run Locally

Task 6: Deploy with Kubernetes and Save Output Logs

# Start k8s in Docker Desktop > Preferences
kubectl get nodes
kubectl delete pods --all
# Finish the run_kuberenets.sh file
./run_kuberenets.sh
# Open another terminal tab
./make_prediction.sh
# Copy the result of the ./run_kuberenets.sh to the nd9991-p4/output_txt_files/kubernetes_out.txt file

Task 7: [Important] Delete Cluster

kubectl delete pods --all
# You can also reset the k8s cluster from the Docker Desktop preferences

Task 8: CircleCI Integration

# Create nd9991-p4/.circleci/config.yml file
# Use the content from https://github.com/udacity/DevOps_Microservices/blob/master/Lesson-2-Docker-format-containers/class-demos/.circleci/config.yml file
# Add the project repo in the CircleCI portal
# Push the code
# Check the badge

nd9991-p4's People

Contributors

sudkul avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

buklawz

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.