Skip to content

Commit 8b552ec

Browse files
committed
deploy
1 parent cdb16dc commit 8b552ec

18 files changed

Lines changed: 294 additions & 157 deletions

File tree

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
IP=shift.python.software.fr

.github/workflows/deploy-action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
3030
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
3131
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
32-
- run: ssh -i ~/.ssh/id_rsa root@38.0.101.76 "cd /home/ubuntu/sentimental_analyses && git pull origin main && ./install.sh"
32+
- run: ssh -i ${{ secrets.SSH_PRIVATE_KEY }} debian@shift.python.software.fr "cd /home/debian && git pull origin main && ./install.sh"

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ WORKDIR /app
55
COPY requirements.txt .
66
RUN pip install -r requirements.txt
77
COPY src src/
8+
COPY templates templates/
89
COPY scripts/entrypoint.sh .
910
COPY supervisord.conf .
1011
EXPOSE 5000

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,17 @@ export TORCH_DISTRIBUTED_DEBUG=DETAIL
7373
```bash
7474
python -m torch.distributed.run --nproc_per_node=2 train.py
7575
```
76+
77+
## Tests
78+
```bash
79+
pytest src/tests
80+
```
81+
82+
## Launch a test to verify the prection from the API
83+
Go on 127.0.0.1:5000, tap your tweet and click on predict button
84+
85+
Par requête http
86+
```bash
87+
export $(cat .env | xargs)
88+
python post.py
89+
```

docker-compose.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ services:
88
volumes:
99
- ./mlruns:/app/mlruns/
1010
- ./src:/app/src/
11-
stdin_open: true
12-
tty: true
13-
entrypoint: "/bin/bash" #"./entrypoint.sh"
11+
# stdin_open: true
12+
# tty: true
13+
entrypoint: "./entrypoint.sh"
14+
env_file:
15+
- .env
1416
environment:
1517
- MLFLOW_TRACKING_URI=http://0.0.0.0:5001
1618
- HOST_DEPLOY = 0.0.0.0
@@ -42,6 +44,12 @@ services:
4244
environment:
4345
- GF_SECURITY_ADMIN_PASSWORD=admin
4446
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/dashboards/tweet_dashboard.json
47+
- GF_SMTP_ENABLED=true
48+
- GF_SMTP_HOST=smtp.gmail.com:587
49+
- GF_SMTP_USER=shift.python.software@gmail.com
50+
- GF_SMTP_PASSWORD=meph potg kjia pfah
51+
- GF_SMTP_FROM_ADDRESS=shift.python.software@gmail.com
52+
- GF_SMTP_FROM_NAME=Grafana
4553
restart: unless-stopped
4654

4755
loki:
@@ -69,16 +77,16 @@ services:
6977
depends_on:
7078
- loki
7179
restart: unless-stopped
72-
nginx:
73-
image: nginx
74-
container_name: sentimental_analyses_nginx
75-
ports:
76-
- "81:80"
77-
- '444:443'
78-
volumes:
79-
- ./nginx.conf:/etc/nginx/conf.d/default.conf
80-
depends_on:
81-
- backend
80+
# nginx:
81+
# image: nginx
82+
# container_name: sentimental_analyses_nginx
83+
# ports:
84+
# - "81:80"
85+
# - '444:443'
86+
# volumes:
87+
# - ./nginx.conf:/etc/nginx/conf.d/default.conf
88+
# depends_on:
89+
# - backend
8290

8391
volumes:
8492
grafana-storage:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: 1
2+
3+
contactPoints:
4+
- orgId: 1
5+
name: admin-email
6+
receivers:
7+
- uid: admin-email
8+
type: email
9+
settings:
10+
addresses: "shift.python.software@gmail.com"

grafana/alerting/rules.json

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,37 @@
33
"groups": [
44
{
55
"orgId": 1,
6-
"name": "job alert",
6+
"name": "test",
77
"folder": "bert",
88
"interval": "1m",
99
"rules": [
1010
{
11-
"uid": "dej6cljqgxekge",
12-
"title": "Alert max jobs",
11+
"uid": "aejwyv8iivmyoa",
12+
"title": "Alert max jobs (copy)",
1313
"condition": "C",
1414
"data": [
1515
{
1616
"refId": "A",
17+
"queryType": "range",
1718
"relativeTimeRange": {
1819
"from": 600,
1920
"to": 0
2021
},
21-
"datasourceUid": "cej41rlo2r11cd",
22+
"datasourceUid": "ds_loki",
2223
"model": {
23-
"disableTextWrap": false,
24+
"datasource": {
25+
"type": "loki",
26+
"uid": "ds_loki"
27+
},
28+
"direction": "backward",
2429
"editorMode": "builder",
25-
"expr": "prediction_status{model=\"bert\"}",
26-
"fullMetaSearch": false,
27-
"includeNullMetadata": true,
30+
"expr": "count_over_time(\n {app=\"tweet-analyzer\"}\n | json\n | __error__=\"\"\n | confidence < 0.6\n [5m]\n)",
2831
"instant": true,
2932
"intervalMs": 1000,
30-
"legendFormat": "__auto",
33+
"legendFormat": "",
3134
"maxDataPoints": 43200,
32-
"range": false,
33-
"refId": "A",
34-
"useBackend": false
35+
"queryType": "range",
36+
"refId": "A"
3537
}
3638
},
3739
{
@@ -46,7 +48,7 @@
4648
{
4749
"evaluator": {
4850
"params": [
49-
5
51+
1
5052
],
5153
"type": "gt"
5254
},
@@ -69,12 +71,58 @@
6971
"type": "__expr__",
7072
"uid": "__expr__"
7173
},
72-
"expression": "A",
74+
"expression": "B",
7375
"intervalMs": 1000,
7476
"maxDataPoints": 43200,
7577
"refId": "C",
7678
"type": "threshold"
7779
}
80+
},
81+
{
82+
"refId": "B",
83+
"relativeTimeRange": {
84+
"from": 0,
85+
"to": 0
86+
},
87+
"datasourceUid": "__expr__",
88+
"model": {
89+
"conditions": [
90+
{
91+
"evaluator": {
92+
"params": [
93+
0,
94+
0
95+
],
96+
"type": "gt"
97+
},
98+
"operator": {
99+
"type": "and"
100+
},
101+
"query": {
102+
"params": []
103+
},
104+
"reducer": {
105+
"params": [],
106+
"type": "avg"
107+
},
108+
"type": "query"
109+
}
110+
],
111+
"datasource": {
112+
"name": "Expression",
113+
"type": "__expr__",
114+
"uid": "__expr__"
115+
},
116+
"expression": "A",
117+
"intervalMs": 1000,
118+
"maxDataPoints": 43200,
119+
"reducer": "count",
120+
"refId": "B",
121+
"settings": {
122+
"mode": ""
123+
},
124+
"type": "reduce"
125+
}
78126
}
79127
],
80128
"noDataState": "NoData",
@@ -84,6 +132,7 @@
84132
"description": "Task is up to 5 jobs",
85133
"summary": "Alert Sentiment analysis"
86134
},
135+
"labels": {},
87136
"isPaused": false,
88137
"notification_settings": {
89138
"receiver": "admin-email"

grafana/alertings.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

grafana/dashboards/tweet_dashboard.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"__inputs": [
33
{
4-
"name": "DS_LOKI",
4+
"name": "ds_loki",
55
"label": "loki",
66
"description": "",
77
"type": "datasource",
88
"pluginId": "loki",
99
"pluginName": "Loki"
1010
},
1111
{
12-
"name": "DS_TWEET_SENTIMENT SERVER METRICS",
12+
"name": "ds_prometheus",
1313
"label": "Tweet sentiment server metrics",
1414
"description": "",
1515
"type": "datasource",
@@ -76,7 +76,7 @@
7676
{
7777
"datasource": {
7878
"type": "loki",
79-
"uid": "${DS_LOKI}"
79+
"uid": "ds_loki"
8080
},
8181
"gridPos": {
8282
"h": 7,
@@ -101,7 +101,7 @@
101101
{
102102
"datasource": {
103103
"type": "loki",
104-
"uid": "${DS_LOKI}"
104+
"uid": "ds_loki"
105105
},
106106
"direction": "backward",
107107
"editorMode": "code",
@@ -116,7 +116,7 @@
116116
{
117117
"datasource": {
118118
"type": "prometheus",
119-
"uid": "${DS_TWEET_SENTIMENT SERVER METRICS}"
119+
"uid": "ds_prometheus"
120120
},
121121
"fieldConfig": {
122122
"defaults": {
@@ -213,7 +213,7 @@
213213
{
214214
"datasource": {
215215
"type": "prometheus",
216-
"uid": "${DS_TWEET_SENTIMENT SERVER METRICS}"
216+
"uid": "ds_prometheus"
217217
},
218218
"disableTextWrap": true,
219219
"editorMode": "builder",
@@ -229,7 +229,7 @@
229229
{
230230
"datasource": {
231231
"type": "prometheus",
232-
"uid": "${DS_TWEET_SENTIMENT SERVER METRICS}"
232+
"uid": "ds_prometheus"
233233
},
234234
"disableTextWrap": false,
235235
"editorMode": "builder",
@@ -246,7 +246,7 @@
246246
{
247247
"datasource": {
248248
"type": "prometheus",
249-
"uid": "${DS_TWEET_SENTIMENT SERVER METRICS}"
249+
"uid": "ds_prometheus"
250250
},
251251
"disableTextWrap": true,
252252
"editorMode": "builder",
@@ -263,7 +263,7 @@
263263
{
264264
"datasource": {
265265
"type": "prometheus",
266-
"uid": "${DS_TWEET_SENTIMENT SERVER METRICS}"
266+
"uid": "ds_prometheus"
267267
},
268268
"disableTextWrap": false,
269269
"editorMode": "builder",
@@ -280,7 +280,7 @@
280280
{
281281
"datasource": {
282282
"type": "prometheus",
283-
"uid": "${DS_TWEET_SENTIMENT SERVER METRICS}"
283+
"uid": "ds_prometheus"
284284
},
285285
"disableTextWrap": false,
286286
"editorMode": "builder",

grafana/datasources/datasources.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: 1
33
datasources:
44
- name: Prometheus
55
type: prometheus
6-
uid: DS_TWEET_SENTIMENT SERVER METRICS
6+
uid: ds_prometheus
77
access: proxy
88
orgId: 1
99
url: http://prometheus:9090
@@ -12,7 +12,7 @@ datasources:
1212

1313
- name: Loki
1414
type: loki
15-
uid: DS_LOKI
15+
uid: ds_loki
1616
access: proxy
1717
orgId: 1
1818
url: http://loki:3100

0 commit comments

Comments
 (0)