Skip to content

Commit

Permalink
update demo examples
Browse files Browse the repository at this point in the history
  • Loading branch information
amancevice committed Jul 15, 2022
1 parent f703993 commit 1db8a89
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 92 deletions.
14 changes: 7 additions & 7 deletions examples/celery/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
version: '3'
services:
redis:
image: redis
restart: always
volumes:
- redis:/data
postgres:
db:
image: postgres
restart: always
environment:
Expand All @@ -14,6 +9,11 @@ services:
POSTGRES_USER: superset
volumes:
- postgres:/var/lib/postgresql/data
redis:
image: redis
restart: always
volumes:
- redis:/data
superset:
image: amancevice/superset
restart: always
Expand All @@ -30,7 +30,7 @@ services:
image: amancevice/superset
restart: always
depends_on:
- postgres
- db
- redis
environment:
MAPBOX_API_KEY: ${MAPBOX_API_KEY}
Expand Down
38 changes: 18 additions & 20 deletions examples/celery/superset/superset_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@
from cachelib import RedisCache


MAPBOX_API_KEY = os.getenv('MAPBOX_API_KEY', '')
MAPBOX_API_KEY = os.getenv("MAPBOX_API_KEY", "")
CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 300,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'redis',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 1,
'CACHE_REDIS_URL': 'redis://redis:6379/1'}
SQLALCHEMY_DATABASE_URI = \
'postgresql+psycopg2://superset:superset@postgres:5432/superset'
"CACHE_TYPE": "RedisCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_",
"CACHE_REDIS_HOST": "redis",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1,
"CACHE_REDIS_URL": "redis://redis:6379/1",
}
FILTER_STATE_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_filter_"}
EXPLORE_FORM_DATA_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_explore_form_"}
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://superset:superset@db:5432/superset"
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'thisISaSECRET_1234'
SECRET_KEY = "thisISaSECRET_1234"


class CeleryConfig(object):
BROKER_URL = 'redis://redis:6379/0'
CELERY_IMPORTS = ('superset.sql_lab', )
CELERY_RESULT_BACKEND = 'redis://redis:6379/0'
CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}}
BROKER_URL = "redis://redis:6379/0"
CELERY_IMPORTS = ("superset.sql_lab",)
CELERY_RESULT_BACKEND = "redis://redis:6379/0"
CELERY_ANNOTATIONS = {"tasks.add": {"rate_limit": "10/s"}}


CELERY_CONFIG = CeleryConfig
RESULTS_BACKEND = RedisCache(
host='redis',
port=6379,
key_prefix='superset_results'
)
RESULTS_BACKEND = RedisCache(host="redis", port=6379, key_prefix="superset_results")
29 changes: 10 additions & 19 deletions examples/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,22 @@

set -e

if [ -z $1 ]; then
echo "Usage: bash demo.sh mysql|postgres|sqlite|celery"
exit 1
elif [ "$1" != "mysql" ] && [ "$1" != "postgres" ] && [ "$1" != "sqlite" ] && [ "$1" != "celery" ]; then
echo "Usage: bash demo.sh mysql|postgres|sqlite|celery"
exit 1
fi
case $1 in
celery | mysql | postgres | sqlite) ;;
*) echo "Usage: ./demo.sh mysql|postgres|sqlite|celery" ; exit 1 ;;
esac

cd $1

# Start back end
if [ "$1" == "sqlite" ]; then
echo "Starting redis service..."
docker compose up -d redis
>| ./superset/superset.db
elif [ "$1" == "mysql" ] || [ "$1" == "postgres" ]; then
echo "Starting redis & $1 services..."
docker compose up -d redis $1
echo "Sleeping for 30s"
sleep 30
else
echo "Starting redis & postgres services..."
docker compose up -d redis postgres
echo "Sleeping for 30s"
sleep 30
echo "Starting db & redis services..."
docker compose up -d db redis
echo "Sleeping for 10s"
sleep 10
fi

# Start Superset
Expand All @@ -36,8 +27,8 @@ if [ "$1" == "celery" ]; then
echo "Starting Superset worker..."
docker compose up -d worker
fi
echo "Sleeping for 30s"
sleep 30
echo "Sleeping for 10s"
sleep 10

# Inititalize Demo
docker compose exec superset superset-demo
Expand Down
14 changes: 7 additions & 7 deletions examples/mysql/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
version: '3'
services:
redis:
image: redis
restart: always
volumes:
- redis:/data
mysql:
db:
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
image: mysql:5
restart: always
Expand All @@ -16,11 +11,16 @@ services:
MYSQL_USER: superset
volumes:
- mysql:/var/lib/mysql
redis:
image: redis
restart: always
volumes:
- redis:/data
superset:
image: amancevice/superset
restart: always
depends_on:
- mysql
- db
- redis
environment:
MAPBOX_API_KEY: ${MAPBOX_API_KEY}
Expand Down
24 changes: 13 additions & 11 deletions examples/mysql/superset_config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import os

MAPBOX_API_KEY = os.getenv('MAPBOX_API_KEY', '')
MAPBOX_API_KEY = os.getenv("MAPBOX_API_KEY", "")
CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 300,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'redis',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 1,
'CACHE_REDIS_URL': 'redis://redis:6379/1'}
SQLALCHEMY_DATABASE_URI = \
'mysql://superset:superset@mysql:3306/superset?charset=utf8mb4'
"CACHE_TYPE": "RedisCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_",
"CACHE_REDIS_HOST": "redis",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1,
"CACHE_REDIS_URL": "redis://redis:6379/1",
}
FILTER_STATE_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_filter_"}
EXPLORE_FORM_DATA_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_explore_form_"}
SQLALCHEMY_DATABASE_URI = "mysql://superset:superset@db:3306/superset?charset=utf8mb4"
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'thisISaSECRET_1234'
SECRET_KEY = "thisISaSECRET_1234"
14 changes: 7 additions & 7 deletions examples/postgres/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
version: '3'
services:
redis:
image: redis
restart: always
volumes:
- redis:/data
postgres:
db:
image: postgres
restart: always
environment:
Expand All @@ -14,11 +9,16 @@ services:
POSTGRES_USER: superset
volumes:
- postgres:/var/lib/postgresql/data
redis:
image: redis
restart: always
volumes:
- redis:/data
superset:
image: amancevice/superset
restart: always
depends_on:
- postgres
- db
- redis
environment:
MAPBOX_API_KEY: ${MAPBOX_API_KEY}
Expand Down
24 changes: 13 additions & 11 deletions examples/postgres/superset_config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import os

MAPBOX_API_KEY = os.getenv('MAPBOX_API_KEY', '')
MAPBOX_API_KEY = os.getenv("MAPBOX_API_KEY", "")
CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 300,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'redis',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 1,
'CACHE_REDIS_URL': 'redis://redis:6379/1'}
SQLALCHEMY_DATABASE_URI = \
'postgresql+psycopg2://superset:superset@postgres:5432/superset'
"CACHE_TYPE": "RedisCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_",
"CACHE_REDIS_HOST": "redis",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1,
"CACHE_REDIS_URL": "redis://redis:6379/1",
}
FILTER_STATE_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_filter_"}
EXPLORE_FORM_DATA_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_explore_form_"}
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://superset:superset@db:5432/superset"
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'thisISaSECRET_1234'
SECRET_KEY = "thisISaSECRET_1234"
23 changes: 13 additions & 10 deletions examples/sqlite/superset_config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import os

MAPBOX_API_KEY = os.getenv('MAPBOX_API_KEY', '')
MAPBOX_API_KEY = os.getenv("MAPBOX_API_KEY", "")
CACHE_CONFIG = {
'CACHE_TYPE': 'redis',
'CACHE_DEFAULT_TIMEOUT': 300,
'CACHE_KEY_PREFIX': 'superset_',
'CACHE_REDIS_HOST': 'redis',
'CACHE_REDIS_PORT': 6379,
'CACHE_REDIS_DB': 1,
'CACHE_REDIS_URL': 'redis://redis:6379/1'}
SQLALCHEMY_DATABASE_URI = 'sqlite:////var/lib/superset/superset.db'
"CACHE_TYPE": "RedisCache",
"CACHE_DEFAULT_TIMEOUT": 300,
"CACHE_KEY_PREFIX": "superset_",
"CACHE_REDIS_HOST": "redis",
"CACHE_REDIS_PORT": 6379,
"CACHE_REDIS_DB": 1,
"CACHE_REDIS_URL": "redis://redis:6379/1",
}
FILTER_STATE_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_filter_"}
EXPLORE_FORM_DATA_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_explore_form_"}
SQLALCHEMY_DATABASE_URI = "sqlite:////var/lib/superset/superset.db"
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'thisISaSECRET_1234'
SECRET_KEY = "thisISaSECRET_1234"

0 comments on commit 1db8a89

Please sign in to comment.