Skip to content

Code and slides for the Event Driven Machine Learning talk at PyData London 2023

Notifications You must be signed in to change notification settings

NatanMish/event_driven_ml_demo

Repository files navigation

Event Driven Machine Learning Demo

This is a demo of an event driven machine learning application. The application allows a user to simulate data based on a linear regression model, send the data to a Kafka topic, and then use the data to train a linear regression model with the River package.

Video is now available on YouTube

drawing

Getting Started

Prerequisites

  • Python 3.8 or higher
  • Poetry
  • Docker
  • Minikube
  • Kubectl

Installing

  1. Clone the repository
  2. Install dependencies
poetry install
  1. Start minikube
minikube start --driver=docker
  1. Deploy Zookeeper
kubectl apply -f kafka_kubernetes/namespace.yaml
kubectl apply -f kafka_kubernetes/zookeeper.yaml
  1. Once the zookeeper pods are running, update the kafka_kubernetes/kafka.yaml file with the IP address of the zookeeper pods. Then deploy the kafka pods.
kubectl get pods -A -o wide | grep 'zookeeper'
# Update the kafka.yaml file with the IP address of the zookeeper pods
kubectl apply -f kafka_kubernetes/kafka.yaml
  1. Port forward the Kafka pod to the local machine (keep the terminal open)
kubectl port-forward <YOUR-KAFKA-BROKER-POD-NAME-HERE> 9092:9092 -n kafka
  1. Mount the minikube virtual machine to the local file system (keep the terminal open)
minikube mount /Users:/Users
  1. Build and push the FastAPI image to your docker registry
docker build -t <your_docker_registry>/online_learner:latest .
docker push <your_docker_registry>/online_learner:latest
  1. Update the FastAPI deployment file with the new image tag
  2. Deploy the FastAPI application
kubectl apply -f online_learner_app/deployment.yaml
  1. Use minikube to run the fastapi service(keep the terminal open)
minikube service fast-api-service
  1. In the streamlit_app.py file, update the IP address of the fastapi service
  2. Run the streamlit application(keep the terminal open)
streamlit run streamlit_app.py

About

Code and slides for the Event Driven Machine Learning talk at PyData London 2023

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published