当前位置: 首页 > news >正文

superset study day01 (本地启动superset项目)

文章目录

    • 什么是superset?
      • superset文档
    • superset开发环境搭建
      • superset后端环境
        • 1. 新建数据库
        • 2. 环境配置
        • 3. 修改py文件
        • 4. 迁移数据库
        • 5. 启动项目
      • superset 前端代码打包
      • 搭建完成,效果页面

什么是superset?

Apache Superset™ 是一个开源的现代数据探索和可视化平台。

Superset是一个现代化的数据探索和数据可视化平台。Superset 可以取代或增强许多团队的专有商业智能工具。Superset与各种数据源很好地集成。

Superset 提供:

  • 用于快速构建图表的无代码界面
  • 功能强大、基于 Web 的 SQL 编辑器,用于高级查询
  • 轻量级语义层,用于快速定义自定义维度和指标
  • 开箱即用,支持几乎任何 SQL 数据库或数据引擎
  • 各种精美的可视化来展示您的数据,从简单的条形图到地理空间可视化
  • 轻量级、可配置的缓存层,有助于减轻数据库负载
  • 高度可扩展的安全角色和身份验证选项
  • 用于编程定制的 API
  • 从头开始设计的云原生架构,旨在实现规模化

superset文档

github文档:
https://github.com/apache/superset
官方操作文档
https://superset.apache.org/
文档某些步骤可能跑不通流程, 应该是版本迭代太快没有及时更新流程.

superset开发环境搭建

获取superset代码:

git clone https://github.com/apache/superset.git

superset后端环境

环境:
python 3.9.1
mysql 8.0
redis

1. 新建数据库

名称: superset_test
字符集: utf8mb4
在这里插入图片描述

2. 环境配置
# 安装 python3.9.1# virtualenv创建虚拟环境
mkvirtualenv -p python  superset_test
workon superset_test# conda创建虚拟环境
conda create -n superset_test python=3.9.1 -y
conda env list
conda activate superset_test# 两种创建虚拟环境的任选一种# install 
pip install apache-superset -i https://pypi.douban.com/simple
pip install flask_session==0.5.0 -i https://pypi.douban.com/simple
pip install pymysql==1.1.0 -i https://pypi.douban.com/simple
pip install requests==2.31.0 -i https://pypi.douban.com/simple
pip install Pillow==10.0.0 -i https://pypi.douban.com/simple
pwd pip install -e F:\zhondiao\github_superset\superset
# F:\zhondiao\github_superset\superset是当前项目路径

在这里插入图片描述

3. 修改py文件

config.py:


SECRET_KEY = "Y2Nrtdtt0nrKrMteiB2E/kgSr40OZW/z5ZiOqxGiJpsw/8RBV+lbGCqF"SUPERSET_REDIS_HOST = "127.0.0.1"
SUPERSET_REDIS_PORT = "6379"
SUPERSET_REDIS_PASSWORD = ""
SUPERSET_REDIS_DB = 10SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:123456@127.0.0.1:3306/superset_test?charset=utf8mb4'WTF_CSRF_ENABLED = False
FAB_ADD_SECURITY_API = TrueRATELIMIT_STORAGE_URI = ("redis://:"+ SUPERSET_REDIS_PASSWORD +"@"+ SUPERSET_REDIS_HOST +":"+ SUPERSET_REDIS_PORT +"/"+ str(SUPERSET_REDIS_DB)
)

superset\superset\models\ dynamic_plugins.py:

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
from flask_appbuilder import Model
from sqlalchemy import Column, Integer, Text, Stringfrom superset.models.helpers import AuditMixinNullableclass DynamicPlugin(Model, AuditMixinNullable):id = Column(Integer, primary_key=True)name = Column(String(255), unique=True, nullable=False)# key corresponds to viz_type from static pluginskey = Column(String(255), unique=True, nullable=False)bundle_url = Column(String(255), unique=True, nullable=False)def __repr__(self) -> str:return str(self.name)

superset\superset\models\ sql_lab.py

# ...latest_query_id = Column(String(11), ForeignKey("query.client_id", ondelete="SET NULL"))
#    latest_query_id = Column(
#        Integer, ForeignKey("query.client_id", ondelete="SET NULL")
#    )# ...

superset\superset\tables\ models.py

catalog = sa.Column(sa.String(50))schema = sa.Column(sa.String(50))name = sa.Column(sa.String(50))# catalog = sa.Column(sa.Text)# schema = sa.Column(sa.Text)# name = sa.Column(sa.Text)

app.py

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.import logging
import os
from typing import Optionalfrom flask import Flaskfrom superset.initialization import SupersetAppInitializerlogger = logging.getLogger(__name__)def create_app(superset_config_module: Optional[str] = None) -> Flask:app = SupersetApp(__name__)try:# Allow user to override our config completelyconfig_module = superset_config_module or os.environ.get("SUPERSET_CONFIG", "superset.config")app.config.from_object(config_module)app_initializer = app.config.get("APP_INITIALIZER", SupersetAppInitializer)(app)app_initializer.init_app()return app# Make sure that bootstrap errors ALWAYS get loggedexcept Exception as ex:logger.exception("Failed to create app")raise exclass SupersetApp(Flask):pass# 本地测试
if __name__ == '__main__':superset_app = create_app()# print(superset_app.url_map)superset_app.run(host="0.0.0.0", port=5000, debug=True,)

superset\superset\migrations\ script.py.mako

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
"""${message}Revision ID: ${up_revision}
Revises: ${down_revision}
Create Date: ${create_date}"""# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
${imports if imports else ""}def upgrade():${upgrades if upgrades else "pass"}def downgrade():${downgrades if downgrades else "pass"}

清空superset\superset\migrations\versions文件下所有的py文件

4. 迁移数据库
superset db upgradesuperset db migratesuperset db upgradesuperset fab create-adminsuperset init 

在这里插入图片描述
在这里插入图片描述
创建admin用户:
在这里插入图片描述

5. 启动项目

本次测试先运行app.py

Python app.py
在这里插入图片描述
在此之前,要打包前端代码,才能进去系统里

superset 前端代码打包

准备:
nodejs

git pull
cd superset-frontend
npm install  --registry=https://registry.npm.taobao.org    npm run build

搭建完成,效果页面

在这里插入图片描述
在这里插入图片描述

相关文章:

  • AWS:EC2实例创建步骤
  • 文件重命名自动化:批量处理让生活更简单
  • 2024上海国际人工智能展(CSITF)“创新驱动发展·科技引领未来”
  • 【Linux】第十站:git和gdb的基本使用
  • 软件架构师
  • 吴恩达《机器学习》5-6:向量化
  • 腾讯云16核服务器配置有哪些?CPU型号处理器主频性能
  • 分享zframe_send使用过程中 的一个小问题
  • React Native自学笔记
  • 为什么大家会选择通配符SSL证书?
  • 线性表(顺序表,单链表,双链表,循环链表,静态链表)
  • Linux中命令lsattr/chattr
  • react_6
  • 全面的Docker快速入门教程
  • U盘显示无媒体怎么办?方法很简单
  • JS中 map, filter, some, every, forEach, for in, for of 用法总结
  • 2018一半小结一波
  • es6要点
  • gitlab-ci配置详解(一)
  • mongo索引构建
  • vue自定义指令实现v-tap插件
  • Zepto.js源码学习之二
  • 高度不固定时垂直居中
  • 搞机器学习要哪些技能
  • 缓存与缓冲
  • 聊聊spring cloud的LoadBalancerAutoConfiguration
  • 前端_面试
  • 入口文件开始,分析Vue源码实现
  • 入门级的git使用指北
  • 原生 js 实现移动端 Touch 滑动反弹
  • 2017年360最后一道编程题
  • Play Store发现SimBad恶意软件,1.5亿Android用户成受害者 ...
  • Spark2.4.0源码分析之WorldCount 默认shuffling并行度为200(九) ...
  • 进程与线程(三)——进程/线程间通信
  • 浅谈sql中的in与not in,exists与not exists的区别
  • ​2020 年大前端技术趋势解读
  • #HarmonyOS:Web组件的使用
  • (33)STM32——485实验笔记
  • (PyTorch)TCN和RNN/LSTM/GRU结合实现时间序列预测
  • (TOJ2804)Even? Odd?
  • (分布式缓存)Redis持久化
  • (附源码)python房屋租赁管理系统 毕业设计 745613
  • (论文阅读30/100)Convolutional Pose Machines
  • (转)fock函数详解
  • (转)JAVA中的堆栈
  • (转载)从 Java 代码到 Java 堆
  • .net core 控制台应用程序读取配置文件app.config
  • .NET Framework Client Profile - a Subset of the .NET Framework Redistribution
  • .net FrameWork简介,数组,枚举
  • .net6Api后台+uniapp导出Excel
  • .NetCore项目nginx发布
  • .net专家(张羿专栏)
  • ??如何把JavaScript脚本中的参数传到java代码段中
  • @serverendpoint注解_SpringBoot 使用WebSocket打造在线聊天室(基于注解)
  • @transaction 提交事务_【读源码】剖析TCCTransaction事务提交实现细节