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

news2024/10/5 15:52:02

文章目录

    • 什么是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 = 10


SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:123456@127.0.0.1:3306/superset_test?charset=utf8mb4'

WTF_CSRF_ENABLED = False
FAB_ADD_SECURITY_API = True

RATELIMIT_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, String

from superset.models.helpers import AuditMixinNullable


class DynamicPlugin(Model, AuditMixinNullable):
    id = Column(Integer, primary_key=True)
    name = Column(String(255), unique=True, nullable=False)
    # key corresponds to viz_type from static plugins
    key = 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 Optional

from flask import Flask

from superset.initialization import SupersetAppInitializer

logger = logging.getLogger(__name__)


def create_app(superset_config_module: Optional[str] = None) -> Flask:
    app = SupersetApp(__name__)

    try:
        # Allow user to override our config completely
        config_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 logged
    except Exception as ex:
        logger.exception("Failed to create app")
        raise ex


class 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 upgrade

superset db migrate

superset db upgrade

superset fab create-admin

superset 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

搭建完成,效果页面

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1178669.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

CBAM:Convolutional Block Attention Module

CBAM(Convolutional Block Attention Module)是一种深度学习领域的注意力机制,旨在增强卷积神经网络对图像特征的建模和表示能力。CBAM引入了通道和空间两种不同的注意力机制,使模型能够动态调整特征图的权重,以适应不…

Python 文件处理指南:打开、读取、写入、追加、创建和删除文件

文件处理是任何Web应用程序的重要部分。Python有多个用于创建、读取、更新和删除文件的函数。 文件处理 在Python中处理文件的关键函数是open()函数。open()函数接受两个参数:文件名和模式。 有四种不同的方法(模式)可以打开文件&#xff…

[直播自学]-[汇川easy320]搞起来(2)看文档

2023.11.06.NIGHT 一 、读 《Easy320可编程逻辑控制器用户手册-CN-A02.PDF》 21:30 好现在看文档 里面提到 I/O滤波可设置: I/O支持短路保护,I/O指示灯程序控制 热量是向上走的,而PLC是大脑,所以放到最下面&am…

Qt 继承QAbstractTableModel实现自定义TableModel

1.简介 QAbstractTableModel为将数据表示为二维项数组的模型提供了一个标准接口。它不直接使用,但必须进行子类化。 由于该模型提供了比QAbstractItemModel更专业的接口,因此它不适合与树视图一起使用,尽管它可以用于向QListView提供数据。…

Ansible playbook自动化运维工具详解

Ansible playbook自动化运维工具详解 一、playbook的相关知识1.1、playbook 的简介1.2、playbook的 各部分组成 二、基础的playbook剧本编写实例三、 playbook的定义、引用变量3.1、基础变量的定义与引用3.2、引用fact信息中的变量 四、playbook中的when条件判断和变量循环使用…

Swin Transformer V2:扩展容量和分辨率

目标检测是计算机视觉的一个任务,它将指定的输入图像或视频帧转换为对象识别、定位和分类的结果。它非常类似于分类,但添加了定位的元素,它可以确定图像中的特定对象所在的位置。主要用于物体识别、跟踪和车牌识别。 Swin Transformer V2 ✅…

想入行单片机开发的学生们的忠告

想入行单片机开发的学生们的忠告 做嵌入式单片机开发十来年。想给那些想入行单片机开发的同学一些建议。 1.想做这行,做好坚持学习的准备。最近很多小伙伴找我,说想要一些单片机的资料,然后我根据自己从业十年经验,熬夜搞了几个通…

SPSS协方差分析

前言: 本专栏参考教材为《SPSS22.0从入门到精通》,由于软件版本原因,部分内容有所改变,为适应软件版本的变化,特此创作此专栏便于大家学习。本专栏使用软件为:SPSS25.0 本专栏所有的数据文件请点击此链接下…

【C++】构造函数和析构函数第三部分(各种构造函数调用规则、多个对象的构造和析构、初始化列表)--- 2023.11.6

目录 各种构造函数的调用规则对象以值的方式给函数参数用一个已有的对象去初始化另一个对象函数的局部对象以值的方式从函数返回调用规则1调用规则2 多个对象的构造和析构初始化列表结束语 各种构造函数的调用规则 对象以值的方式给函数参数 实例: class Maker {…

思维模型 布里丹毛驴效应

本系列文章 主要是 分享 思维模型,涉及各个领域,重在提升认知。犹豫不决是病,得治~ 1 布里丹毛驴效应的应用 1.1 犹豫不决的产品“施乐 914” 20 世纪 60 年代,美国一家名为施乐(Xerox)的公司…

如何在CPU上进行高效大语言模型推理

大语言模型(LLMs)已经在广泛的任务中展示出了令人瞩目的表现和巨大的发展潜力。然而,由于这些模型的参数量异常庞大,使得它们的部署变得相当具有挑战性,这不仅需要有足够大的内存空间,还需要有高速的内存传…

5+单细胞+铜死亡+实验,干湿结合生信思路,有条件做实验的可模仿

今天给同学们分享一篇生信文章“Single-cell transcriptomics reveals immune infiltrate in sepsis”,这篇文章发表在Front Pharmacol期刊上,影响因子为5.6。 结果解读 作者研究的流程图 作者首先制定了这项研究的总体技术路线,如图1所示。…

UVM源码--uvm_component 浅析(一)

目录 1. uvm_object 2. uvm_component 3. 为什么在uvm_component 例化是需要指定一个parent? 4.uvm_component 的树形结构是如何组织起来的? 5. 静态函数与非静态函数的区别: 6. uvm_root 的单实例实现思路: 7. run_test 的…

动态头:用注意力统一目标检测头

目标检测是回答计算机视觉应用中“哪些目标位于哪里”的问题。在深度学习时代,几乎所有现代目标检测器共享相同的范式——特征提取的主干和定位和分类任务的头部。如何提高目标检测头的性能已经成为现有目标检测工作中的一个关键问题。检测头应该是尺度感知&#xf…

modelscope适配昇腾NPU

注意 我只做了raner,raner-50cls,corom这三个模型的适配,不能保证其他模型同样好使。 我的环境信息 NPU: Atlas 300I Pro Modelsope: 1.9.4(最好要使用这个版本呀,因为后面要改一下源码) python: 3.8 torch: 2.0.1 内核以…

深度学习之基于YoloV5交通信号标志识别系统

欢迎大家点赞、收藏、关注、评论啦 ,由于篇幅有限,只展示了部分核心代码。 文章目录 一项目简介 二、功能三、系统四. 总结 一项目简介 基于YoloV5交通信号标志识别系统介绍 基于YoloV5的交通信号标志识别系统是一种深度学习应用,旨在通过使…

《国产服务器操作系统发展报告(2023)》重磅发布

11月1日,《国产服务器操作系统发展报告(2023)》(以下简称“报告”)在 2023 云栖大会上正式发布,开放原子开源基金会理事长孙文龙、中国信息通信研究院副总工程师石友康、阿里云基础软件部副总裁马涛、浪潮信…

明御安全网关任意文件上传漏洞复现

简介 安恒信息明御安全网关(NGFW) 秉持安全可视、简单有效的理念,以资产为视角的全流程防御的下一代安全防护体系,并融合传统防火墙、入侵防御系统、防病毒网关、上网行为管控、VPN网关、威胁情报等安全模块于一体的智慧化安全网关。 较低版本的系统存…

享搭低代码平台:快速构建符合需求的会议室管理系统应用

本文介绍了享搭低代码平台如何赋予用户快速构建会议室管理系统应用的能力。通过在应用商店安装费用会议室管理模板,并通过拖拽方式对模板进行自定义扩充,用户可以快速搭建符合自身需求的会议室管理系统,从而提高会议室预订和管理的效率。 介绍…

华为eNSP实验-三层交换机的不同网段通信(通过OSPF路由方式)

1.拓扑图 2.过程如下 2.1 首先PC1和PC2配置好IP地址 2.2 在SW1上配置虚拟网关及VLAN <Huawei>system-view [Huawei]sysname SW1 [SW1]undo info-center enable [SW1] [SW1]vlan batch 10 20 [SW1]interface GigabitEthernet 0/0/1 [SW1-GigabitEthernet0/0/1]port li…