Skip to content

Commit 1c58888

Browse files
committed
Adding Redis
1 parent 339ea59 commit 1c58888

File tree

9 files changed

+60
-10
lines changed

9 files changed

+60
-10
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
data
2-
**/__pycache__
2+
**/__pycache__

.env.example

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ TELEGRAF_TAG=1.13.4-alpine
1818
#Grafana
1919
GRAFANA_TAG=6.7.0
2020
GRAFANA_PORT=3000
21-
GF_INSTALL_PLUGINS=grafana-clock-panel,briangann-gauge-panel,natel-plotly-panel,grafana-simple-json-datasource
21+
GF_INSTALL_PLUGINS=grafana-clock-panel,briangann-gauge-panel,natel-plotly-panel,grafana-simple-json-datasource
22+
23+
#Redis
24+
REDIS_TAG=alpine3.11
25+
REDIS_PORT=6379

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ rm:
4040

4141
#Container commands
4242
penter:
43-
docker-compose exec python sh
43+
docker-compose run python
4444

45-
#make jrun c="echo hello world"
45+
#make prun d=ts_price_anomaly_detection s=view
4646
prun:
47-
docker-compose run python $(c)
47+
docker-compose run python python /scripts/$(d)/$(s).py

docker-compose.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ services:
66
container_name: "${PROJECT_NAME}_python"
77
hostname: python
88
stop_grace_period: 60s
9-
# build:
10-
# dockerfile: Dockerfile
11-
# context: ./python
12-
# args:
13-
# PYTHON_TAG: $PYTHON_TAG
9+
build:
10+
dockerfile: Dockerfile
11+
context: ./python
12+
args:
13+
PYTHON_TAG: $PYTHON_TAG
1414
volumes:
1515
- ./python:/scripts
1616

@@ -54,6 +54,15 @@ services:
5454
volumes:
5555
- ./data/grafana:/var/lib/grafana
5656

57+
redis:
58+
image: "redis:${REDIS_TAG}"
59+
container_name: "${PROJECT_NAME}_redis"
60+
hostname: redis
61+
stop_grace_period: 60s
62+
restart: always
63+
ports:
64+
- ${REDIS_PORT}:6379
65+
5766
networks:
5867
default:
5968
name: time_series_anomaly_detection

python/.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/data
2+
**/__pycache__

python/Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG PYTHON_TAG
2+
3+
FROM python:${PYTHON_TAG}
4+
5+
ENV PYTHON_PACKAGES="\
6+
numpy \
7+
matplotlib \
8+
scipy \
9+
scikit-learn \
10+
pandas \
11+
nltk \
12+
redis \
13+
"
14+
15+
RUN pip install --upgrade pip && pip install --no-cache-dir $PYTHON_PACKAGES
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[See https://towardsdatascience.com/time-series-of-price-anomaly-detection-13586cd5ff46](https://towardsdatascience.com/time-series-of-price-anomaly-detection-13586cd5ff46)
2+
3+
[Author: Susan Lee](https://towardsdatascience.com/@actsusanli)
4+
5+
[Jupyter notebook](https://github.com/susanli2016/Machine-Learning-with-Python/blob/master/Time%20Series%20of%20Price%20Anomaly%20Detection%20Expedia.ipynb)
6+
7+
[Data Source](https://www.kaggle.com/c/expedia-personalized-sort/data)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
3+
import redis
4+
r = redis.Redis(host='redis', port=6379, decode_responses=True)
5+
r.set('foo', 'bar')
6+
7+
res = r.get('foo')
8+
print(str(res))
9+
r.close()

0 commit comments

Comments
 (0)