Spaces:
Sleeping
Sleeping
File size: 4,174 Bytes
9bca988 b6ea18a 9bca988 b6ea18a 9bca988 b6ea18a 9bca988 b6ea18a 9bca988 44ac321 b6ea18a 2a73da8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | ### 1 - Deploying product
## Local work
# Build the docker file
docker build --build-arg HF_TOKEN=$HF_TOKEN -t mlops-cs3 .
# run the docker image locally
docker run -p 7860:7860 mlops-cs3
# tag the docker image to docker hub repository
docker tag mlops-cs3 venkateshroshan/mlops-cs3:latest
# push the docker image to docker hub repository
sudo docker push venkateshroshan/mlops-cs3:latest
## VM Server
# login to vm server via ssh
ssh -p 2222 group13@melnibone.wpi.edu
# pull the docker image
docker pull venkateshroshan/mlops-cs3:latest
# run the docker image
docker run -d -p 7860:7860 venkateshroshan/mlops-cs3
# access the application in localhost via ssh tunneling
ssh -L 7860:localhost:7860 -p 2222 group13@melnibone.wpi.edu
http://localhost:7860
-> explanation : Forwards local machine’s port 7860 to port 7860 on the VM and the ssh server is listening on port 2222.
### 2 - Monitoring product
# add prometheus-node-exporter in dockerfile and rebuild the docker image
RUN apt-get install -y prometheus-node-exporter
# exposing ports
# Prometheus Node Exporter metrics
EXPOSE 9100
# Prometheus Python app metrics
EXPOSE 8000
# Run both the Node Exporter and the Gradio application
CMD ["sh", "-c", "prometheus-node-exporter & python app.py"]
# run docker
docker run -d -p 25560:7860 -p 25561:9100 -p 25562:8000 venkateshroshan/mlops-cs3:latest4
# access the application in localhost via ssh tunneling
ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -p 2222 group13@melnibone.wpi.edu
Gradio application at http://localhost:25560
Prometheus monitoring at http://localhost:25561
Prometheus metrics endpoint at http://localhost:25562
### 3 - Expose your product using ngrok (or a similar service)
* Expose your service globally
# add authtoken of ngrok
ngrok authtoken YOUR_AUTH_TOKEN
# expose the port
ngrok http 25560 -> this gives public URL
ngrok http 25561
ngrok http 25562
# to run forever - use nohup
nohup ngrok http --log=log.txt http://localhost:25560 > /dev/null &
# Grafana visualization
docker pull grafana/grafana:latest
docker run -d -p 25563:3000 --name grafana grafana/grafana:latest
# created a prometheus.yml file
global:
scrape_interval: 5s # Adjust as needed
scrape_configs:
- job_name: 'node-exporter'
static_configs:
- targets: ['172.17.0.1:25561']
- job_name: 'app-metrics'
static_configs:
- targets: ['172.17.0.1:25562']
docker run -d -p 25564:9090 -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -L 25563:localhost:25563 -L 25564:localhost:25564 -p 2222 group13@melnibone.wpi.edu
# To check whether the state of the site is up or down
http://localhost:25564/targets?search=
go to grafana http://localhost:25563
create a dashboard and add prometheus with the link as http://192.168.0.230:25564
# Final RUN
docker pull venkateshroshan/mlops-cs3:latest4
docker run -d -p 25560:7860 -p 25561:9100 -p 25562:8000 --name group13_app venkateshroshan/mlops-cs3:latest4
docker pull docker pull grafana/grafana:latest
docker run -d -p 25563:3000 --name group13_grafana grafana/grafana:latest
docker pull prom/prometheus
docker run -d -p 25564:9090 -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml --name group13_prometheus prom/prometheus
ssh -L 25560:localhost:25560 -L 25561:localhost:25561 -L 25562:localhost:25562 -L 25563:localhost:25563 -L 25564:localhost:25564 -p 2222 group13@melnibone.wpi.edu
# visualize these 4 metrics
transcription_requests_total - Total transcription requests
transcription_request_duration_seconds - Duration of transcription requests in seconds
transcription_memory_usage_bytes - Memory used by the transcription function
ram_usage_percentage - Percentage of total RAM used by the transcription function
### Case study 4
docker build --build-arg HF_TOKEN=$HF_TOKEN -t mlops-cs4 .
docker tag mlops-cs4 venkateshroshan/mlops-cs4:latest
sudo docker push venkateshroshan/mlops-cs4:latest
docker pull venkateshroshan/mlops-cs4:latest
docker run -d -p 7860:7860 -p 8001:8000 -p 9100:9100 venkateshroshan/mlops-cs4:latest
|