数据分析-incubator-superset开源可视化项目二

搭建superset本地开发环境
使用多语言和配置匿名访问
PyCharm create project from git
或者git clone https://github.com/apache/incubator-superset.git

后端python环境

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
$ python --version
Python 3.6.1 :: Anaconda 4.4.0 (x86_64)

vi setup.py
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
]

$ python setup.py develop
...
Finished processing dependencies for superset==0.19.1

$ fabmanager create-admin --app superset
$ superset db upgrade
$ superset init
$ superset load_examples

$ superset runserver -d
no manifest file found at /Users/shaozhipeng/2017/python/incubator-superset/superset/static/assets/dist/manifest.json
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Starting Superset server in DEBUG mode
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

2017-09-05 15:56:49,123:INFO:werkzeug: * Running on http://0.0.0.0:8088/ (Press CTRL+C to quit)
2017-09-05 15:56:49,128:INFO:werkzeug: * Restarting with stat
no manifest file found at /Users/shaozhipeng/2017/python/incubator-superset/superset/static/assets/dist/manifest.json
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Starting Superset server in DEBUG mode
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

2017-09-05 15:56:54,616:WARNING:werkzeug: * Debugger is active!
2017-09-05 15:56:54,644:INFO:werkzeug: * Debugger PIN: 814-645-045

样式不正常

image
image

前端node-npm-js环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ node --version
v7.9.0

$ npm --version
4.2.0

$ cd superset/assets/
$ yarn --version
0.27.5

$ yarn
$ npm run sync-backend

$ npm run prod
$ npm run dev

样式正常了
可以ctl+c结束npm run dev

image

单元测试环境

1
2
3
4
5
6
$ pip --version
pip 9.0.1 from /anaconda/lib/python3.6/site-packages (python 3.6)

$ pip install -r dev-reqs.txt

OSError: mysql_config not found

如果没有mysql,就安装mysql;系统已经有mysql了

1
2
3
4
5
6
7
$ export PATH=$PATH:/usr/local/mysql/bin
$ mysql --version
mysql Ver 14.14 Distrib 5.6.21, for osx10.8 (x86_64) using EditLine wrapper
$ mysql_config --version
5.6.21

$ ./run_tests.sh

前端测试

1
2
3
$ cd /superset/superset/assets/javascripts
$ npm i
$ npm run test

生成API文档

1
$ cd docs && ./build.sh

CSS样式

https://bootswatch.com/

1
$ cd assets/stylesheets/less/

多语言

http://babel.pocoo.org/en/latest/
添加配置文件和多语言配置 superset/translations/zh/LC_MESSAGES
superset/config.py

1
2
3
4
5
LANGUAGES = {
'en': {'flag': 'us', 'name': 'English'},
'fr': {'flag': 'fr', 'name': 'French'},
'zh': {'flag': 'cn', 'name': 'Chinese'},
}

进一步汉化 superset/static/assets/javascripts/explore/stores
controls.jsx
visTypes.js
将上面两个文件中的一些label的英文替换为中文

1
2
$ ls
controls.jsx store.js visTypes.js

匿名访问

superset/config.py

1
PUBLIC_ROLE_LIKE_GAMMA = True

复制config.py 重命名为 superset_config.py

image
image
image
image
image

邵志鹏 wechat
扫一扫上面的二维码关注我的公众号
0%