Apache Superset二次开发环境配置

版本
node v16.13.0
Apache Superset 1.3.2
Anaconda 4.10.1
Win10

以上软件需要提前安装!!!

一、下载源码

# 下载源码
git clone https://github.com/apache/superset.git
# 切换到目标版本,按需自行修改
git checkout 1.3.2

# 为superset创建一个3.7的python虚拟环境
conda create --name py37 python=3.7
# 激活环境
conda activate py37

二、安装依赖

# 进入superset项目的根目录 
cd superset

# 设置国内pip源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# 安装superset 本地测试依赖
pip install -e .

三、初始化数据库

superset的默认数据库是SQLite,据说有很多问题,后面需要切换为Mysql

# 初始化数据库
superset db upgrade

四、创建用户

superset fab create-admin

注意:三个名字必须不不同,如果配置同一个会报权限错误!!!
Apache Superset二次开发环境配置

五、下载示例(可选)

下载需要访问国外网站,需安全上网
不下载也不影响使用

superset load_examples

Apache Superset二次开发环境配置

六、初始化

superset init

七、配置前端项目

建议安全上网,速度更快,且不报错

# 进入前端目录
cd superset-frontend
# 下载依赖
npm install

修改package-lock.json

注释代码,加新代码

      // 注释的内容
      // {
      //   test: /\.jsx?$/,
      //   // include source code for plugins, but exclude node_modules and test files within them
      //   exclude: [/superset-ui.*\/node_modules\//, /\.test.jsx?$/],
      //   include: [
      //     new RegExp(`${APP_DIR}/src`),
      //     /superset-ui.*\/src/,
      //     new RegExp(`${APP_DIR}/.storybook`),
      //     /@encodable/,
      //   ],
      //   use: [babelLoader],
      // },
      // 添加的新代码
      {
        test: /\.jsx?$/,
        // include source code for plugins, but exclude node_modules and test files within them
        exclude: [/superset-ui.*\/node_modules\//, /\.test.jsx?$/],
        include: [
          new RegExp(`${APP_DIR}/src`),
          /superset-ui.*\/src/,
          new RegExp(`${APP_DIR}/.storybook`),
          path.resolve(__dirname, 'src'), // 添加本行代码,对 windows 环境不友好
        ],
        use: [babelLoader],
      },

Apache Superset二次开发环境配置

运行前端项目

npm run dev

八、运行后端项目

新启动一个cmd

# 进入项目根目录
cd  E:\ws\py3_ws\superset
e:
# 执行启动命令,端口如果有冲突可以修改为其他端口
superset run -p 3000 --with-threads --reload --debugger

Apache Superset二次开发环境配置
可以看到存在一些示例
Apache Superset二次开发环境配置
随便点开一个
Apache Superset二次开发环境配置

参考资料

Superset Github
superset 开发环境搭建

上一篇:Superset【环境搭建 01】CentOS release 7.5 在线安装 Superset(python虚拟环境安装+多个问题解决+WEB登录验证)【避免踩坑】


下一篇:Superset 安装报错: libbz2.so.1.0: cannot open shared object file: No such file or directory