跳转到主要内容

未提供项目描述

项目描述

一个用于扩展您的Jupyter和Web应用的纯Python,React风格框架

solara logo

来和我们在Discord上聊天,提问或分享您的想法或创作吧!

Discord Shield

介绍Solara

虽然现在有很多Python Web框架,但大多数都是为小型数据应用设计的或使用未经证实的更大规模的范式。随着应用复杂性的增加,代码组织、重用性和状态往往会受到影响,导致代码变得混乱或卸载到React应用。

Solara解决了这个差距。使用类似于React的API,我们不需要担心可扩展性。React已经证明了它支持世界上最大的Web应用的能力。

Solara使用React的纯Python实现(Reacton),创建基于ipywidget的应用程序。这些应用程序可以在Jupyter Notebook内部以及作为使用FastAPI等框架的独立Web应用程序工作。这种范式使组件化代码和非常简单的状态管理成为可能。

通过在ipywidgets之上构建,我们自动利用现有的小部件生态系统,并在许多平台上运行,包括JupyterLab、Jupyter Notebook、Voilà、Google Colab、DataBricks、JetBrains Datalore等。

我们关心开发者体验。Solara将为您的热代码重载和类型提示提供更快的发展速度。

安装

运行

pip install solara

或按照安装说明获取更详细的说明。

第一个脚本

将以下Python片段放入文件中(我们建议使用sol.py),或者将其放入Jupyter notebook单元中

import solara

# Declare reactive variables at the top level. Components using these variables
# will be re-executed when their values change.
sentence = solara.reactive("Solara makes our team more productive.")
word_limit = solara.reactive(10)


@solara.component
def Page():
    # Calculate word_count within the component to ensure re-execution when reactive variables change.
    word_count = len(sentence.value.split())

    solara.SliderInt("Word limit", value=word_limit, min=2, max=20)
    solara.InputText(label="Your sentence", value=sentence, continuous_update=True)

    # Display messages based on the current word count and word limit.
    if word_count >= int(word_limit.value):
        solara.Error(f"With {word_count} words, you passed the word limit of {word_limit.value}.")
    elif word_count >= int(0.8 * word_limit.value):
        solara.Warning(f"With {word_count} words, you are close to the word limit of {word_limit.value}.")
    else:
        solara.Success("Great short writing!")


# The following line is required only when running the code in a Jupyter notebook:
Page()

在您放置文件(sol.py)的同一目录中从命令行运行

$ solara run sol.py
Solara server is starting at http://localhost:8765

或者将其复制粘贴到 Jupyter 笔记本单元格中并执行它(末尾的 Page() 表达式将导致其在笔记本中自动渲染组件)。

在此处查看此代码片段的实际运行效果:[https://solara.dev/documentation/getting_started](https://solara.dev/documentation/getting_started)

演示

以下演示应用程序可用于使用散点图探索数据集(内置或自行上传)。可以与图形交互以过滤数据集,并可以下载过滤后的数据集。

在 solara-server 中运行

Solara 服务器建立在 Starlette/FastAPI 之上,可独立运行。非常适合生产使用。

fastapi

在 Jupyter 中运行

通过在 ipywidgets 上构建,我们自动利用现有的小部件生态系统并在多个平台上运行,包括 JupyterLab、Jupyter Notebook、Voilà、Google Colab、DataBricks、JetBrains Datalore 等。这意味着我们的应用程序也可以在 Jupyter 中运行。

jupyter

资源

访问我们的主网站或直接跳转到介绍

Introduction Quickstart

请注意,solara.dev 网站是使用 Solara 创建的

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

solara_ui-1.39.0.tar.gz (1.2 MB 查看哈希值

上传时间: 源代码

构建分发

solara_ui-1.39.0-py2.py3-none-any.whl (1.3 MB 查看哈希值

上传时间: Python 2 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面