supertest搭建
supertest 搭建
介绍
Superset 是一款由 Airbnb 开源的“现代化的企业级 BI(商业智能) Web 应用程序”,其通过创建和分享 dashboard,为数据分析提供了轻量级的数据查询和可视化方案。
Superset 的前端主要用到了 React 和 NVD3/D3,而后端则基于 Python 的 Flask 框架和 Pandas、SQLAlchemy 等依赖库,主要提供了这几方面的功能:
- 集成数据查询功能,支持多种数据库,包括 MySQL、PostgresSQL、Oracle、SQL Server、SQLite、SparkSQL 等,并深度支持 Druid。
- 通过 NVD3/D3 预定义了多种可视化图表,满足大部分的数据展示功能。如果还有其他需求,也可以自开发更多的图表类型,或者嵌入其他的 JavaScript 图表库(如 HighCharts、ECharts)。
- 提供细粒度安全模型,可以在功能层面和数据层面进行访问控制。支持多种鉴权方式(如数据库、OpenID、LDAP、OAuth、REMOTE_USER 等)。
官网
Welcome | Superset (apache.org)
安装部署(docker方式安装)
环境
Linux CentOS Linux release 7.9.2009 (Core)
docker安装
Install Docker Engine on CentOS | Docker Documentation
pull镜像并启动
docker run -d -p 8080:8088 --name superset apache/superset
设置本地账户
docker exec -it superset superset fab create-admin \
--username admin \
--firstname Superset \
--lastname Admin \
--email admin@superset.com \
--password admin
将本地数据库加载到最新版本
docker exec -it superset superset db upgrade
加载示例
此步骤由于网络问题会出错,解决方法看排错部分
docker exec -it superset superset load_examples
执行完成后设置角色
docker exec -it superset superset init
登录访问:
http://xxx.xxx.xxx.xxx:8080 账号密码admin/admin
问题排查
问题1
加载示例报错
Creating a World's Health Bank dashboard
Loading [Birth names]
Traceback (most recent call last):
File "/usr/local/bin/superset", line 33, in <module>
sys.exit(load_entry_point('apache-superset', 'console_scripts', 'superset')())
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/flask/cli.py", line 586, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/flask/cli.py", line 426, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/app/superset/cli.py", line 193, in load_examples
load_examples_run(load_test_data, load_big_data, only_metadata, force)
File "/app/superset/cli.py", line 137, in load_examples_run
examples.load_birth_names(only_metadata, force)
File "/app/superset/examples/birth_names.py", line 112, in load_birth_names
load_data(tbl_name, database, sample=sample)
File "/app/superset/examples/birth_names.py", line 68, in load_data
pdf = pd.read_json(get_example_data("birth_names2.json.gz"))
File "/app/superset/examples/helpers.py", line 72, in get_example_data
content = request.urlopen( # pylint: disable=consider-using-with
File "/usr/local/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/usr/local/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/usr/local/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.8/urllib/request.py", line 1397, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/usr/local/lib/python3.8/urllib/request.py", line 1358, in do_open
r = h.getresponse()
File "/usr/local/lib/python3.8/http/client.py", line 1348, in getresponse
response.begin()
File "/usr/local/lib/python3.8/http/client.py", line 316, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.8/http/client.py", line 285, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
解决方法:
网络问题,可下载到本地然后修改相关配置文件进行本地加载
1 下载示例
https://gitcode.net/mirrors/apache-superset/examples-data?utm_source=csdn_github_accelerator
或
https://github.com/apache-superset/examples-data
2 解压数据
unzip examples-data-master.zip
3 使用python起一个http服务
$ cd examples-data-master
$ python3 -m http.server 7887
Serving HTTP on 0.0.0.0 port 7887 (http://0.0.0.0:7887/) ...
4 进入superset_init服务
docker exec -it superset_init /bin/bash
使用sed命令替换部分配置文件的访问地址。假设主机iP是192.168.47.202,修改命令如下
sed -i 's/BASE_URL = .*"/BASE_URL = "http:\/\/192.168.47.202:7887\/"/g' superset/examples/helpers.py
sed -i 's/https:\/\/github.com\/apache-superset\/examples-data\/raw\/master\//http:\/\/192.168.47.202:7887\//g' superset/examples/configs/datasets/examples/*.yaml
sed -i 's/http:\/\/192.168.3.20:7887\//http:\/\/192.168.47.202:7887\//g' superset/examples/configs/datasets/examples/*.yaml
sed -i 's/https:\/\/raw.githubusercontent.com\/apache-superset\/examples-data\/master\//http:\/\/192.168.47.202:7887\//g' superset/examples/configs/datasets/examples/*.yaml
sed -i 's/https:\/\/raw.githubusercontent.com\/apache-superset\/examples-data\/lowercase_columns_examples\/datasets\/examples\//http:\/\/192.168.47.202:7887\/datasets\/examples/\//g' superset/examples/configs/datasets/examples/*.yaml
exit
5 重启superset_init 服务
$ docker restart superset_init
6 重新执行等待加载示例结束
docker exec -it superset superset load_examples
问题2
上传csv文件提示
ERROR: No database is allowed for your csv upload
解决方法
数据库没有开放相关权限,开放相关权限即可
点击 【Data】——》【Databases】——》【Edit】
ity】
点击 【ADVANCED】——》【Security】
勾选【Allow data upload】点击保存
参考
apache/superset - Docker Image |码头工人中心
ERROR: No database is allowed for your csv upload · Issue #10304 · apache/superset · GitHub