solara-ui 1.45.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prefix/etc/jupyter/jupyter_notebook_config.d/solara.json +7 -0
- prefix/etc/jupyter/jupyter_server_config.d/solara.json +7 -0
- solara/__init__.py +124 -0
- solara/__main__.py +765 -0
- solara/_stores.py +297 -0
- solara/alias.py +6 -0
- solara/autorouting.py +555 -0
- solara/cache.py +305 -0
- solara/checks.html +71 -0
- solara/checks.py +227 -0
- solara/comm.py +28 -0
- solara/components/__init__.py +77 -0
- solara/components/alert.py +155 -0
- solara/components/applayout.py +397 -0
- solara/components/button.py +85 -0
- solara/components/card.py +87 -0
- solara/components/checkbox.py +50 -0
- solara/components/code_highlight_css.py +11 -0
- solara/components/code_highlight_css.vue +63 -0
- solara/components/columns.py +159 -0
- solara/components/component_vue.py +134 -0
- solara/components/cross_filter.py +335 -0
- solara/components/dataframe.py +546 -0
- solara/components/datatable.py +214 -0
- solara/components/datatable.vue +175 -0
- solara/components/details.py +56 -0
- solara/components/download.vue +35 -0
- solara/components/echarts.py +86 -0
- solara/components/echarts.vue +139 -0
- solara/components/figure_altair.py +39 -0
- solara/components/file_browser.py +181 -0
- solara/components/file_download.py +199 -0
- solara/components/file_drop.py +159 -0
- solara/components/file_drop.vue +83 -0
- solara/components/file_list_widget.vue +78 -0
- solara/components/head.py +27 -0
- solara/components/head_tag.py +49 -0
- solara/components/head_tag.vue +60 -0
- solara/components/image.py +173 -0
- solara/components/input.py +456 -0
- solara/components/input_text_area.py +86 -0
- solara/components/link.py +55 -0
- solara/components/markdown.py +441 -0
- solara/components/markdown_editor.py +33 -0
- solara/components/markdown_editor.vue +359 -0
- solara/components/matplotlib.py +74 -0
- solara/components/meta.py +47 -0
- solara/components/misc.py +333 -0
- solara/components/pivot_table.py +258 -0
- solara/components/pivot_table.vue +158 -0
- solara/components/progress.py +47 -0
- solara/components/select.py +182 -0
- solara/components/select.vue +27 -0
- solara/components/slider.py +442 -0
- solara/components/slider_date.vue +56 -0
- solara/components/spinner-solara.vue +105 -0
- solara/components/spinner.py +45 -0
- solara/components/sql_code.py +41 -0
- solara/components/sql_code.vue +125 -0
- solara/components/style.py +105 -0
- solara/components/switch.py +71 -0
- solara/components/tab_navigation.py +37 -0
- solara/components/title.py +90 -0
- solara/components/title.vue +38 -0
- solara/components/togglebuttons.py +200 -0
- solara/components/tooltip.py +61 -0
- solara/core.py +42 -0
- solara/datatypes.py +143 -0
- solara/express.py +241 -0
- solara/hooks/__init__.py +4 -0
- solara/hooks/dataframe.py +99 -0
- solara/hooks/misc.py +263 -0
- solara/hooks/use_reactive.py +151 -0
- solara/hooks/use_thread.py +129 -0
- solara/kitchensink.py +8 -0
- solara/lab/__init__.py +34 -0
- solara/lab/components/__init__.py +7 -0
- solara/lab/components/chat.py +215 -0
- solara/lab/components/confirmation_dialog.py +163 -0
- solara/lab/components/cross_filter.py +7 -0
- solara/lab/components/input_date.py +339 -0
- solara/lab/components/input_time.py +133 -0
- solara/lab/components/menu.py +181 -0
- solara/lab/components/menu.vue +38 -0
- solara/lab/components/tabs.py +274 -0
- solara/lab/components/theming.py +98 -0
- solara/lab/components/theming.vue +72 -0
- solara/lab/hooks/__init__.py +0 -0
- solara/lab/hooks/dataframe.py +2 -0
- solara/lab/toestand.py +3 -0
- solara/lab/utils/__init__.py +2 -0
- solara/lab/utils/cookies.py +5 -0
- solara/lab/utils/dataframe.py +165 -0
- solara/lab/utils/headers.py +5 -0
- solara/layout.py +44 -0
- solara/lifecycle.py +46 -0
- solara/minisettings.py +141 -0
- solara/py.typed +0 -0
- solara/reactive.py +99 -0
- solara/routing.py +268 -0
- solara/scope/__init__.py +88 -0
- solara/scope/types.py +55 -0
- solara/server/__init__.py +0 -0
- solara/server/app.py +527 -0
- solara/server/assets/custom.css +1 -0
- solara/server/assets/custom.js +1 -0
- solara/server/assets/favicon.png +0 -0
- solara/server/assets/favicon.svg +5 -0
- solara/server/assets/style.css +1681 -0
- solara/server/assets/theme-dark.css +437 -0
- solara/server/assets/theme-light.css +420 -0
- solara/server/assets/theme.js +3 -0
- solara/server/cdn_helper.py +91 -0
- solara/server/esm.py +71 -0
- solara/server/fastapi.py +5 -0
- solara/server/flask.py +297 -0
- solara/server/jupyter/__init__.py +2 -0
- solara/server/jupyter/cdn_handler.py +28 -0
- solara/server/jupyter/server_extension.py +40 -0
- solara/server/jupyter/solara.py +91 -0
- solara/server/jupytertools.py +46 -0
- solara/server/kernel.py +388 -0
- solara/server/kernel_context.py +467 -0
- solara/server/patch.py +564 -0
- solara/server/pyinstaller/__init__.py +9 -0
- solara/server/pyinstaller/hook-ipyreact.py +5 -0
- solara/server/pyinstaller/hook-ipyvuetify.py +5 -0
- solara/server/pyinstaller/hook-solara.py +9 -0
- solara/server/qt.py +113 -0
- solara/server/reload.py +251 -0
- solara/server/server.py +484 -0
- solara/server/settings.py +249 -0
- solara/server/shell.py +269 -0
- solara/server/starlette.py +770 -0
- solara/server/static/ansi.js +270 -0
- solara/server/static/highlight-dark.css +82 -0
- solara/server/static/highlight.css +43 -0
- solara/server/static/main-vuetify.js +272 -0
- solara/server/static/main.js +163 -0
- solara/server/static/solara_bootstrap.py +129 -0
- solara/server/static/sun.svg +23 -0
- solara/server/static/webworker.js +42 -0
- solara/server/telemetry.py +212 -0
- solara/server/templates/index.html.j2 +1 -0
- solara/server/templates/loader-plain.css +11 -0
- solara/server/templates/loader-plain.html +20 -0
- solara/server/templates/loader-solara.css +111 -0
- solara/server/templates/loader-solara.html +40 -0
- solara/server/templates/plain.html +82 -0
- solara/server/templates/solara.html.j2 +486 -0
- solara/server/threaded.py +84 -0
- solara/server/utils.py +44 -0
- solara/server/websocket.py +45 -0
- solara/settings.py +86 -0
- solara/tasks.py +893 -0
- solara/template/button.py +16 -0
- solara/template/markdown.py +42 -0
- solara/template/portal/.flake8 +6 -0
- solara/template/portal/.pre-commit-config.yaml +28 -0
- solara/template/portal/LICENSE +21 -0
- solara/template/portal/Procfile +7 -0
- solara/template/portal/mypy.ini +3 -0
- solara/template/portal/pyproject.toml +26 -0
- solara/template/portal/solara_portal/__init__.py +4 -0
- solara/template/portal/solara_portal/components/__init__.py +2 -0
- solara/template/portal/solara_portal/components/article.py +28 -0
- solara/template/portal/solara_portal/components/data.py +28 -0
- solara/template/portal/solara_portal/components/header.py +6 -0
- solara/template/portal/solara_portal/components/layout.py +6 -0
- solara/template/portal/solara_portal/content/articles/equis-in-vidi.md +85 -0
- solara/template/portal/solara_portal/content/articles/substiterat-vati.md +70 -0
- solara/template/portal/solara_portal/data.py +60 -0
- solara/template/portal/solara_portal/pages/__init__.py +67 -0
- solara/template/portal/solara_portal/pages/article/__init__.py +26 -0
- solara/template/portal/solara_portal/pages/tabular.py +29 -0
- solara/template/portal/solara_portal/pages/viz/__init__.py +70 -0
- solara/template/portal/solara_portal/pages/viz/overview.py +14 -0
- solara/test/__init__.py +0 -0
- solara/test/pytest_plugin.py +783 -0
- solara/toestand.py +998 -0
- solara/util.py +348 -0
- solara/validate_hooks.py +258 -0
- solara/website/__init__.py +0 -0
- solara/website/assets/custom.css +444 -0
- solara/website/assets/images/logo-small.png +0 -0
- solara/website/assets/images/logo.svg +17 -0
- solara/website/assets/images/logo_white.svg +50 -0
- solara/website/assets/theme.js +8 -0
- solara/website/components/__init__.py +5 -0
- solara/website/components/algolia.py +6 -0
- solara/website/components/algolia.vue +24 -0
- solara/website/components/algolia_api.vue +202 -0
- solara/website/components/breadcrumbs.py +28 -0
- solara/website/components/contact.py +144 -0
- solara/website/components/docs.py +143 -0
- solara/website/components/header.py +75 -0
- solara/website/components/mailchimp.py +12 -0
- solara/website/components/mailchimp.vue +47 -0
- solara/website/components/markdown.py +99 -0
- solara/website/components/markdown_nav.vue +34 -0
- solara/website/components/notebook.py +171 -0
- solara/website/components/sidebar.py +105 -0
- solara/website/pages/__init__.py +370 -0
- solara/website/pages/about/__init__.py +9 -0
- solara/website/pages/about/about.md +3 -0
- solara/website/pages/apps/__init__.py +16 -0
- solara/website/pages/apps/authorization/__init__.py +119 -0
- solara/website/pages/apps/authorization/admin.py +12 -0
- solara/website/pages/apps/authorization/users.py +12 -0
- solara/website/pages/apps/jupyter-dashboard-1.py +116 -0
- solara/website/pages/apps/layout-demo.py +40 -0
- solara/website/pages/apps/multipage/__init__.py +38 -0
- solara/website/pages/apps/multipage/page1.py +26 -0
- solara/website/pages/apps/multipage/page2.py +34 -0
- solara/website/pages/apps/scatter.py +136 -0
- solara/website/pages/apps/scrolling.py +63 -0
- solara/website/pages/apps/tutorial-streamlit.py +18 -0
- solara/website/pages/careers/__init__.py +27 -0
- solara/website/pages/changelog/__init__.py +10 -0
- solara/website/pages/changelog/changelog.md +372 -0
- solara/website/pages/contact/__init__.py +34 -0
- solara/website/pages/doc_use_download.py +85 -0
- solara/website/pages/documentation/__init__.py +90 -0
- solara/website/pages/documentation/advanced/__init__.py +9 -0
- solara/website/pages/documentation/advanced/content/00-overview.md +1 -0
- solara/website/pages/documentation/advanced/content/10-howto/00-overview.md +6 -0
- solara/website/pages/documentation/advanced/content/10-howto/10-multipage.md +196 -0
- solara/website/pages/documentation/advanced/content/10-howto/20-layout.md +125 -0
- solara/website/pages/documentation/advanced/content/10-howto/30-testing.md +417 -0
- solara/website/pages/documentation/advanced/content/10-howto/31-debugging.md +69 -0
- solara/website/pages/documentation/advanced/content/10-howto/40-embed.md +50 -0
- solara/website/pages/documentation/advanced/content/10-howto/50-ipywidget_libraries.md +124 -0
- solara/website/pages/documentation/advanced/content/15-reference/00-overview.md +3 -0
- solara/website/pages/documentation/advanced/content/15-reference/40-static_files.md +31 -0
- solara/website/pages/documentation/advanced/content/15-reference/41-asset-files.md +72 -0
- solara/website/pages/documentation/advanced/content/15-reference/60-static-site-generation.md +59 -0
- solara/website/pages/documentation/advanced/content/15-reference/70-search.md +34 -0
- solara/website/pages/documentation/advanced/content/15-reference/80-reloading.md +34 -0
- solara/website/pages/documentation/advanced/content/15-reference/90-notebook-support.md +7 -0
- solara/website/pages/documentation/advanced/content/15-reference/95-caching.md +148 -0
- solara/website/pages/documentation/advanced/content/20-understanding/00-introduction.md +10 -0
- solara/website/pages/documentation/advanced/content/20-understanding/05-ipywidgets.md +35 -0
- solara/website/pages/documentation/advanced/content/20-understanding/06-ipyvuetify.md +42 -0
- solara/website/pages/documentation/advanced/content/20-understanding/10-reacton.md +28 -0
- solara/website/pages/documentation/advanced/content/20-understanding/12-reacton-basics.md +108 -0
- solara/website/pages/documentation/advanced/content/20-understanding/15-anatomy.md +23 -0
- solara/website/pages/documentation/advanced/content/20-understanding/17-rules-of-hooks.md +192 -0
- solara/website/pages/documentation/advanced/content/20-understanding/18-containers.md +166 -0
- solara/website/pages/documentation/advanced/content/20-understanding/20-solara.md +18 -0
- solara/website/pages/documentation/advanced/content/20-understanding/40-routing.md +256 -0
- solara/website/pages/documentation/advanced/content/20-understanding/50-solara-server.md +108 -0
- solara/website/pages/documentation/advanced/content/20-understanding/60-voila.md +12 -0
- solara/website/pages/documentation/advanced/content/30-enterprise/00-overview.md +7 -0
- solara/website/pages/documentation/advanced/content/30-enterprise/10-oauth.md +187 -0
- solara/website/pages/documentation/advanced/content/40-development/00-overview.md +0 -0
- solara/website/pages/documentation/advanced/content/40-development/01-contribute.md +45 -0
- solara/website/pages/documentation/advanced/content/40-development/10-setup.md +76 -0
- solara/website/pages/documentation/api/__init__.py +19 -0
- solara/website/pages/documentation/api/cross_filter/__init__.py +9 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_dataframe.py +22 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_report.py +20 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_select.py +20 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_slider.py +20 -0
- solara/website/pages/documentation/api/hooks/__init__.py +9 -0
- solara/website/pages/documentation/api/hooks/use_cross_filter.py +23 -0
- solara/website/pages/documentation/api/hooks/use_dark_effective.py +12 -0
- solara/website/pages/documentation/api/hooks/use_effect.md +43 -0
- solara/website/pages/documentation/api/hooks/use_effect.py +9 -0
- solara/website/pages/documentation/api/hooks/use_exception.py +31 -0
- solara/website/pages/documentation/api/hooks/use_memo.md +16 -0
- solara/website/pages/documentation/api/hooks/use_memo.py +9 -0
- solara/website/pages/documentation/api/hooks/use_previous.py +30 -0
- solara/website/pages/documentation/api/hooks/use_reactive.py +16 -0
- solara/website/pages/documentation/api/hooks/use_state.py +10 -0
- solara/website/pages/documentation/api/hooks/use_state_or_update.py +66 -0
- solara/website/pages/documentation/api/hooks/use_thread.md +64 -0
- solara/website/pages/documentation/api/hooks/use_thread.py +42 -0
- solara/website/pages/documentation/api/hooks/use_trait_observe.py +12 -0
- solara/website/pages/documentation/api/routing/__init__.py +9 -0
- solara/website/pages/documentation/api/routing/generate_routes.py +10 -0
- solara/website/pages/documentation/api/routing/generate_routes_directory.py +10 -0
- solara/website/pages/documentation/api/routing/resolve_path.py +35 -0
- solara/website/pages/documentation/api/routing/route.py +29 -0
- solara/website/pages/documentation/api/routing/use_route.py +76 -0
- solara/website/pages/documentation/api/routing/use_router.py +16 -0
- solara/website/pages/documentation/api/utilities/__init__.py +9 -0
- solara/website/pages/documentation/api/utilities/component_vue.py +10 -0
- solara/website/pages/documentation/api/utilities/computed.py +16 -0
- solara/website/pages/documentation/api/utilities/display.py +16 -0
- solara/website/pages/documentation/api/utilities/get_kernel_id.py +16 -0
- solara/website/pages/documentation/api/utilities/get_session_id.py +16 -0
- solara/website/pages/documentation/api/utilities/memoize.py +35 -0
- solara/website/pages/documentation/api/utilities/on_kernel_start.py +44 -0
- solara/website/pages/documentation/api/utilities/reactive.py +16 -0
- solara/website/pages/documentation/api/utilities/widget.py +104 -0
- solara/website/pages/documentation/components/__init__.py +12 -0
- solara/website/pages/documentation/components/advanced/__init__.py +9 -0
- solara/website/pages/documentation/components/advanced/link.py +25 -0
- solara/website/pages/documentation/components/advanced/meta.py +17 -0
- solara/website/pages/documentation/components/advanced/style.py +43 -0
- solara/website/pages/documentation/components/common.py +9 -0
- solara/website/pages/documentation/components/data/__init__.py +9 -0
- solara/website/pages/documentation/components/data/dataframe.py +44 -0
- solara/website/pages/documentation/components/data/pivot_table.py +81 -0
- solara/website/pages/documentation/components/enterprise/__init__.py +9 -0
- solara/website/pages/documentation/components/enterprise/avatar.py +24 -0
- solara/website/pages/documentation/components/enterprise/avatar_menu.py +25 -0
- solara/website/pages/documentation/components/input/__init__.py +9 -0
- solara/website/pages/documentation/components/input/button.py +23 -0
- solara/website/pages/documentation/components/input/checkbox.py +10 -0
- solara/website/pages/documentation/components/input/file_browser.py +30 -0
- solara/website/pages/documentation/components/input/file_drop.py +76 -0
- solara/website/pages/documentation/components/input/input.py +43 -0
- solara/website/pages/documentation/components/input/select.py +22 -0
- solara/website/pages/documentation/components/input/slider.py +29 -0
- solara/website/pages/documentation/components/input/switch.py +10 -0
- solara/website/pages/documentation/components/input/togglebuttons.py +21 -0
- solara/website/pages/documentation/components/lab/__init__.py +9 -0
- solara/website/pages/documentation/components/lab/chat.py +109 -0
- solara/website/pages/documentation/components/lab/confirmation_dialog.py +55 -0
- solara/website/pages/documentation/components/lab/cookies_headers.py +48 -0
- solara/website/pages/documentation/components/lab/input_date.py +20 -0
- solara/website/pages/documentation/components/lab/input_time.py +15 -0
- solara/website/pages/documentation/components/lab/menu.py +22 -0
- solara/website/pages/documentation/components/lab/tab.py +25 -0
- solara/website/pages/documentation/components/lab/tabs.py +45 -0
- solara/website/pages/documentation/components/lab/task.py +11 -0
- solara/website/pages/documentation/components/lab/theming.py +74 -0
- solara/website/pages/documentation/components/lab/use_task.py +11 -0
- solara/website/pages/documentation/components/layout/__init__.py +9 -0
- solara/website/pages/documentation/components/layout/app_bar.py +16 -0
- solara/website/pages/documentation/components/layout/app_bar_title.py +16 -0
- solara/website/pages/documentation/components/layout/app_layout.py +24 -0
- solara/website/pages/documentation/components/layout/card.py +15 -0
- solara/website/pages/documentation/components/layout/card_actions.py +16 -0
- solara/website/pages/documentation/components/layout/column.py +30 -0
- solara/website/pages/documentation/components/layout/columns.py +27 -0
- solara/website/pages/documentation/components/layout/columns_responsive.py +66 -0
- solara/website/pages/documentation/components/layout/details.py +13 -0
- solara/website/pages/documentation/components/layout/griddraggable.py +62 -0
- solara/website/pages/documentation/components/layout/gridfixed.py +19 -0
- solara/website/pages/documentation/components/layout/hbox.py +18 -0
- solara/website/pages/documentation/components/layout/row.py +30 -0
- solara/website/pages/documentation/components/layout/sidebar.py +24 -0
- solara/website/pages/documentation/components/layout/vbox.py +19 -0
- solara/website/pages/documentation/components/output/__init__.py +9 -0
- solara/website/pages/documentation/components/output/file_download.py +11 -0
- solara/website/pages/documentation/components/output/html.py +19 -0
- solara/website/pages/documentation/components/output/image.py +11 -0
- solara/website/pages/documentation/components/output/markdown.py +57 -0
- solara/website/pages/documentation/components/output/markdown_editor.py +51 -0
- solara/website/pages/documentation/components/output/sql_code.py +83 -0
- solara/website/pages/documentation/components/output/tooltip.py +11 -0
- solara/website/pages/documentation/components/page/__init__.py +9 -0
- solara/website/pages/documentation/components/page/head.py +15 -0
- solara/website/pages/documentation/components/page/title.py +25 -0
- solara/website/pages/documentation/components/status/__init__.py +9 -0
- solara/website/pages/documentation/components/status/error.py +39 -0
- solara/website/pages/documentation/components/status/info.py +39 -0
- solara/website/pages/documentation/components/status/progress.py +10 -0
- solara/website/pages/documentation/components/status/spinner.py +11 -0
- solara/website/pages/documentation/components/status/success.py +40 -0
- solara/website/pages/documentation/components/status/warning.py +47 -0
- solara/website/pages/documentation/components/viz/__init__.py +9 -0
- solara/website/pages/documentation/components/viz/altair.py +42 -0
- solara/website/pages/documentation/components/viz/echarts.py +77 -0
- solara/website/pages/documentation/components/viz/matplotlib.py +30 -0
- solara/website/pages/documentation/components/viz/plotly.py +63 -0
- solara/website/pages/documentation/components/viz/plotly_express.py +41 -0
- solara/website/pages/documentation/examples/__init__.py +54 -0
- solara/website/pages/documentation/examples/ai/__init__.py +11 -0
- solara/website/pages/documentation/examples/ai/chatbot.py +113 -0
- solara/website/pages/documentation/examples/ai/tokenizer.py +107 -0
- solara/website/pages/documentation/examples/basics/__init__.py +10 -0
- solara/website/pages/documentation/examples/basics/sine.py +28 -0
- solara/website/pages/documentation/examples/fullscreen/__init__.py +10 -0
- solara/website/pages/documentation/examples/fullscreen/authorization.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/layout_demo.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/multipage.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/scatter.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/scrolling.py +3 -0
- solara/website/pages/documentation/examples/fullscreen/tutorial_streamlit.py +3 -0
- solara/website/pages/documentation/examples/general/__init__.py +10 -0
- solara/website/pages/documentation/examples/general/custom_storage.py +70 -0
- solara/website/pages/documentation/examples/general/deploy_model.py +115 -0
- solara/website/pages/documentation/examples/general/live_update.py +32 -0
- solara/website/pages/documentation/examples/general/login_oauth.py +81 -0
- solara/website/pages/documentation/examples/general/mycard.vue +58 -0
- solara/website/pages/documentation/examples/general/pokemon_search.py +51 -0
- solara/website/pages/documentation/examples/general/vue_component.py +50 -0
- solara/website/pages/documentation/examples/ipycanvas.py +49 -0
- solara/website/pages/documentation/examples/libraries/__init__.py +10 -0
- solara/website/pages/documentation/examples/libraries/altair.py +65 -0
- solara/website/pages/documentation/examples/libraries/bqplot.py +39 -0
- solara/website/pages/documentation/examples/libraries/ipyleaflet.py +33 -0
- solara/website/pages/documentation/examples/libraries/ipyleaflet_advanced.py +66 -0
- solara/website/pages/documentation/examples/utilities/__init__.py +10 -0
- solara/website/pages/documentation/examples/utilities/calculator.py +157 -0
- solara/website/pages/documentation/examples/utilities/countdown_timer.py +62 -0
- solara/website/pages/documentation/examples/utilities/todo.py +196 -0
- solara/website/pages/documentation/examples/visualization/__init__.py +6 -0
- solara/website/pages/documentation/examples/visualization/annotator.py +67 -0
- solara/website/pages/documentation/examples/visualization/linked_views.py +81 -0
- solara/website/pages/documentation/examples/visualization/plotly.py +44 -0
- solara/website/pages/documentation/faq/__init__.py +12 -0
- solara/website/pages/documentation/faq/content/99-faq.md +112 -0
- solara/website/pages/documentation/getting_started/__init__.py +9 -0
- solara/website/pages/documentation/getting_started/content/00-quickstart.md +107 -0
- solara/website/pages/documentation/getting_started/content/01-introduction.md +125 -0
- solara/website/pages/documentation/getting_started/content/02-installing.md +134 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/00-overview.md +14 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/10_data_science.py +13 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/20-web-app.md +89 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/30-ipywidgets.md +124 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/40-streamlit.md +146 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/50-dash.md +144 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/60-jupyter-dashboard-part1.py +65 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/SF_crime_sample.csv.gz +0 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/_data_science.ipynb +445 -0
- solara/website/pages/documentation/getting_started/content/04-tutorials/_jupyter_dashboard_1.ipynb +1021 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/00-overview.md +11 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/10-components.md +228 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/50-state-management.md +278 -0
- solara/website/pages/documentation/getting_started/content/07-deploying/00-overview.md +7 -0
- solara/website/pages/documentation/getting_started/content/07-deploying/10-self-hosted.md +305 -0
- solara/website/pages/documentation/getting_started/content/07-deploying/20-cloud-hosted.md +80 -0
- solara/website/pages/documentation/getting_started/content/80-what-is-lab.md +7 -0
- solara/website/pages/documentation/getting_started/content/90-troubleshoot.md +26 -0
- solara/website/pages/docutils.py +38 -0
- solara/website/pages/home.vue +1199 -0
- solara/website/pages/our_team/__init__.py +83 -0
- solara/website/pages/pricing/__init__.py +31 -0
- solara/website/pages/roadmap/__init__.py +11 -0
- solara/website/pages/roadmap/roadmap.md +47 -0
- solara/website/pages/scale_ipywidgets.py +45 -0
- solara/website/pages/showcase/__init__.py +105 -0
- solara/website/pages/showcase/domino_code_assist.py +60 -0
- solara/website/pages/showcase/planeto_tessa.py +19 -0
- solara/website/pages/showcase/solara_dev.py +54 -0
- solara/website/pages/showcase/solarathon_2023_team_2.py +22 -0
- solara/website/pages/showcase/solarathon_2023_team_4.py +22 -0
- solara/website/pages/showcase/solarathon_2023_team_5.py +23 -0
- solara/website/pages/showcase/solarathon_2023_team_6.py +34 -0
- solara/website/pages/showcase/wanderlust.py +27 -0
- solara/website/public/beach.jpeg +0 -0
- solara/website/public/logo.svg +6 -0
- solara/website/public/social/discord.svg +1 -0
- solara/website/public/social/github.svg +1 -0
- solara/website/public/social/twitter.svg +3 -0
- solara/website/public/success.html +25 -0
- solara/website/templates/index.html.j2 +117 -0
- solara/website/utils.py +51 -0
- solara/widgets/__init__.py +1 -0
- solara/widgets/vue/gridlayout.vue +107 -0
- solara/widgets/vue/html.vue +4 -0
- solara/widgets/vue/navigator.vue +134 -0
- solara/widgets/vue/vegalite.vue +130 -0
- solara/widgets/widgets.py +74 -0
- solara_ui-1.45.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json +7 -0
- solara_ui-1.45.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json +7 -0
- solara_ui-1.45.0.dist-info/METADATA +162 -0
- solara_ui-1.45.0.dist-info/RECORD +464 -0
- solara_ui-1.45.0.dist-info/WHEEL +4 -0
- solara_ui-1.45.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""# GPT-4 token encoder and decoder
|
|
2
|
+
|
|
3
|
+
This example shows how to use a language model tokenizer to encode and decode and how to search for a token
|
|
4
|
+
|
|
5
|
+
Inspired by: [Understanding GPT tokenizers by Simon Willison](https://simonwillison.net/2023/Jun/8/gpt-tokenizers/)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Note
|
|
9
|
+
|
|
10
|
+
Install pandas and tiktoken with `pip install pandas tiktoken`
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import random
|
|
15
|
+
|
|
16
|
+
import pandas as pd
|
|
17
|
+
import tiktoken
|
|
18
|
+
|
|
19
|
+
import solara
|
|
20
|
+
import solara.lab
|
|
21
|
+
|
|
22
|
+
# Get tokenizer for gpt-4
|
|
23
|
+
tokenizer = tiktoken.encoding_for_model("gpt-4")
|
|
24
|
+
|
|
25
|
+
# Create dataframe mapping token IDs and tokens
|
|
26
|
+
MAX_TOKENS = 50257
|
|
27
|
+
df = pd.DataFrame()
|
|
28
|
+
df["token ID"] = range(MAX_TOKENS)
|
|
29
|
+
df["token"] = [tokenizer.decode([i]) for i in range(MAX_TOKENS)]
|
|
30
|
+
|
|
31
|
+
sentence = solara.reactive("Example text is here")
|
|
32
|
+
tokens_ids_to_lookup = solara.reactive("")
|
|
33
|
+
tokens_filter = solara.reactive("")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@solara.component
|
|
37
|
+
def GithubAvatar(name: str, handle: str, img: str):
|
|
38
|
+
with solara.v.Html(tag="a", attributes={"href": f"https://github.com/{handle}/", "target": "_blank"}):
|
|
39
|
+
with solara.v.ListItem(class_="pa-0"):
|
|
40
|
+
with solara.v.ListItemAvatar(color="grey darken-3"):
|
|
41
|
+
solara.v.Img(
|
|
42
|
+
class_="elevation-6",
|
|
43
|
+
src=img,
|
|
44
|
+
)
|
|
45
|
+
with solara.v.ListItemContent():
|
|
46
|
+
solara.v.ListItemTitle(children=["By " + name])
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@solara.component
|
|
50
|
+
def Token(token: int):
|
|
51
|
+
# create random color dependent on the position
|
|
52
|
+
random.seed(token)
|
|
53
|
+
random_color = "".join([random.choice("0123456789ABCDEF") for k in range(6)])
|
|
54
|
+
with solara.Div(style="display: inline;"):
|
|
55
|
+
with solara.Div(
|
|
56
|
+
style={
|
|
57
|
+
"display": "inline",
|
|
58
|
+
"padding": "6px",
|
|
59
|
+
"border-right": "3px solid white",
|
|
60
|
+
"line-height": "3em",
|
|
61
|
+
"font-family": "courier",
|
|
62
|
+
"background-color": f"#{random_color}",
|
|
63
|
+
"color": "white",
|
|
64
|
+
"position": "relative",
|
|
65
|
+
},
|
|
66
|
+
):
|
|
67
|
+
solara.Text(
|
|
68
|
+
" " + str(token),
|
|
69
|
+
style={
|
|
70
|
+
"display": "inline",
|
|
71
|
+
"position": "absolute",
|
|
72
|
+
"top": "5.5ch",
|
|
73
|
+
"line-height": "1em",
|
|
74
|
+
"left": "-0.5px",
|
|
75
|
+
"font-size": "0.45em",
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
solara.Text(str(tokenizer.decode([token])))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@solara.component
|
|
82
|
+
def Page():
|
|
83
|
+
with solara.Column(margin=10):
|
|
84
|
+
solara.Markdown("# GPT-4 token encoder and decoder")
|
|
85
|
+
solara.Markdown("This is an educational tool for understanding how tokenization works.")
|
|
86
|
+
GithubAvatar(
|
|
87
|
+
"Alonso Silva Allende",
|
|
88
|
+
"alonsosilvaallende",
|
|
89
|
+
"https://avatars.githubusercontent.com/u/30263736?v=4",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
solara.InputText("Enter text to tokenize it:", value=sentence, continuous_update=True)
|
|
93
|
+
tokens = tokenizer.encode(sentence.value)
|
|
94
|
+
with solara.Div(style="display: inline;"):
|
|
95
|
+
for token in tokens:
|
|
96
|
+
Token(token)
|
|
97
|
+
|
|
98
|
+
solara.InputText("Or convert space separated tokens to text:", value=tokens_ids_to_lookup, continuous_update=True)
|
|
99
|
+
token_input = [int(span) for span in tokens_ids_to_lookup.value.split(" ") if span != ""]
|
|
100
|
+
text_output = tokenizer.decode(token_input)
|
|
101
|
+
solara.Markdown(f"{text_output}")
|
|
102
|
+
|
|
103
|
+
solara.Markdown("## Search tokens")
|
|
104
|
+
solara.InputText("Search for a token:", value=tokens_filter, continuous_update=True)
|
|
105
|
+
df_subset = df[df["token"].str.startswith(tokens_filter.value)]
|
|
106
|
+
solara.Markdown(f"{df_subset.shape[0]:,} results")
|
|
107
|
+
solara.DataFrame(df_subset, items_per_page=10)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""# Interactive sine wave
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
This example shows how to have two slider control a visualization.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import plotly.express as px
|
|
10
|
+
|
|
11
|
+
import solara
|
|
12
|
+
|
|
13
|
+
x = np.linspace(0, 2, 100)
|
|
14
|
+
|
|
15
|
+
title = "Interactive sine wave"
|
|
16
|
+
freq = solara.reactive(2.0)
|
|
17
|
+
phase = solara.reactive(0.1)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@solara.component
|
|
21
|
+
def Page():
|
|
22
|
+
y = np.sin(x * freq.value + phase.value)
|
|
23
|
+
|
|
24
|
+
solara.FloatSlider("Frequency", value=freq, min=0, max=10)
|
|
25
|
+
solara.FloatSlider("Phase", value=phase, min=0, max=np.pi, step=0.1)
|
|
26
|
+
|
|
27
|
+
fig = px.line(x=x, y=y)
|
|
28
|
+
solara.FigurePlotly(fig)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""# Custom state storage
|
|
2
|
+
|
|
3
|
+
Solara makes it easy to store state/data on the server side, scoped to a kernel, using [reactive variables](/api/reactive).
|
|
4
|
+
|
|
5
|
+
However, sometimes you want to store state yourself in an external system (i.e. not Solara), and for this you can use the
|
|
6
|
+
[get_kernel_id()](/api/get_kernel_id) function to get a unique id for each kernel.
|
|
7
|
+
|
|
8
|
+
If you want to store state/data scoped to a browser session, you can use the [get_session_id()](/api/get_session_id)
|
|
9
|
+
function to get a unique id tied to the users browser. This can be used to store state that outlives a page refresh.
|
|
10
|
+
|
|
11
|
+
In case you want to store state/data scoped to a user, you can use a similar strategy, but use a unique identifier based on the user,
|
|
12
|
+
instead of the session id. You can take a look at [Our oauth example](examples/general/login_oauth) or
|
|
13
|
+
[the authorization example](/apps/authorization) for inspiration.
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Dict
|
|
18
|
+
|
|
19
|
+
import solara
|
|
20
|
+
import solara.lab
|
|
21
|
+
|
|
22
|
+
# used only to force updating of the page
|
|
23
|
+
force_update_counter = solara.reactive(0)
|
|
24
|
+
|
|
25
|
+
# Kernel storage is scoped to the kernel, and will be cleared when the kernel is stopped.
|
|
26
|
+
kernel_storage: Dict[str, str] = {}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def store_in_kernel_storage(value):
|
|
30
|
+
kernel_storage[solara.get_kernel_id()] = value
|
|
31
|
+
force_update_counter.value += 1
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@solara.lab.on_kernel_start
|
|
35
|
+
def initialize_kernel_storage():
|
|
36
|
+
# when a kernel gets started, we initialize the dict entry
|
|
37
|
+
kernel_storage[solara.get_kernel_id()] = "This does not"
|
|
38
|
+
|
|
39
|
+
def cleanup():
|
|
40
|
+
# when a kernel gets stopped, we remove the dict entry
|
|
41
|
+
del kernel_storage[solara.get_kernel_id()]
|
|
42
|
+
|
|
43
|
+
# cleaning up kernel storage, we prevent memory leaks
|
|
44
|
+
return cleanup
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# session storage has no lifecycle management, and will only be cleared when the server is restarted.
|
|
48
|
+
session_storage: Dict[str, str] = {}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def store_in_session_storage(value):
|
|
52
|
+
session_storage[solara.get_session_id()] = value
|
|
53
|
+
force_update_counter.value += 1
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@solara.component
|
|
57
|
+
def Page():
|
|
58
|
+
solara.InputText(
|
|
59
|
+
"Stored under the kernel id key",
|
|
60
|
+
value=kernel_storage[solara.get_kernel_id()],
|
|
61
|
+
on_value=store_in_kernel_storage,
|
|
62
|
+
continuous_update=True,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
solara.InputText(
|
|
66
|
+
"Stored under the session id key",
|
|
67
|
+
value=session_storage.get(solara.get_session_id(), "This outlives a page refresh"),
|
|
68
|
+
on_value=store_in_session_storage,
|
|
69
|
+
continuous_update=True,
|
|
70
|
+
)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""# Deploy model demo
|
|
2
|
+
|
|
3
|
+
This show off a combination of [solara.lab.Menu](/documentation/components/lab/menu) and
|
|
4
|
+
[solara.lab.ConfirmationDialog](/documentation/components/lab/confirmation_dialog)
|
|
5
|
+
and [solara.use_thread](/documentation/api/hooks/use_thread) to demonstrate how to tune, fit and deploy a model.
|
|
6
|
+
The actually deployment is not real, but simulated by a thread that returns a boolean value on success and sleep for a while to
|
|
7
|
+
similate the deployment taking time.
|
|
8
|
+
|
|
9
|
+
* Right click on the plot to either fit or reset the model parameters.
|
|
10
|
+
* Clicking on the button shows a custom menu to deploy to several environments.
|
|
11
|
+
* A confirmation dialog is used before executing the deployment.
|
|
12
|
+
* If the deployment fails, a confirmation dialog is shown to retry the deployment.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import time
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
import pandas as pd
|
|
19
|
+
import plotly.express as px
|
|
20
|
+
import solara
|
|
21
|
+
import solara.lab
|
|
22
|
+
|
|
23
|
+
slope = solara.reactive(1.5)
|
|
24
|
+
intercept = solara.reactive(0.5)
|
|
25
|
+
|
|
26
|
+
x = np.arange(0, 100, 2) / 10
|
|
27
|
+
# fake data with noise
|
|
28
|
+
y_data = (slope.value * 0.8) * x + (intercept.value + 0.4) + np.random.normal(0, 0.5, len(x))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@solara.component
|
|
32
|
+
def Page():
|
|
33
|
+
deploy_environment_request = solara.use_reactive("")
|
|
34
|
+
deploy_environment = solara.use_reactive("")
|
|
35
|
+
fake_failed = solara.use_reactive(False)
|
|
36
|
+
|
|
37
|
+
def deploy_model():
|
|
38
|
+
if deploy_environment.value == "":
|
|
39
|
+
return
|
|
40
|
+
|
|
41
|
+
# 'dummy' deployment
|
|
42
|
+
time.sleep(1.5)
|
|
43
|
+
|
|
44
|
+
# fake a failure the first time
|
|
45
|
+
if not fake_failed.value:
|
|
46
|
+
fake_failed.value = True
|
|
47
|
+
return False
|
|
48
|
+
else:
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
deploy_state: solara.Result[bool] = solara.use_thread(deploy_model, dependencies=[deploy_environment.value])
|
|
52
|
+
|
|
53
|
+
x_model = x
|
|
54
|
+
y_model = (slope.value) * x_model + (intercept.value)
|
|
55
|
+
df1 = pd.DataFrame({"x": x, "y": y_data})
|
|
56
|
+
df2 = pd.DataFrame({"x": x_model, "y": y_model})
|
|
57
|
+
df = pd.concat([df1, df2], keys=["data", "model"], names=["type"]).reset_index()
|
|
58
|
+
fig = px.line(df, x="x", y="y", color="type")
|
|
59
|
+
with solara.Card("My fancy model"):
|
|
60
|
+
fig_element = solara.FigurePlotly(fig)
|
|
61
|
+
|
|
62
|
+
def reset():
|
|
63
|
+
slope.set(1.5)
|
|
64
|
+
intercept.set(0.5)
|
|
65
|
+
|
|
66
|
+
def fit():
|
|
67
|
+
slope.set(1.5 * 0.8)
|
|
68
|
+
intercept.set(0.9)
|
|
69
|
+
|
|
70
|
+
with solara.lab.ContextMenu(activator=fig_element):
|
|
71
|
+
solara.Button("Reset", text=True, icon_name="mdi-refresh", on_click=reset)
|
|
72
|
+
solara.Button("Fit", text=True, icon_name="mdi-brain", on_click=fit)
|
|
73
|
+
|
|
74
|
+
solara.FloatSlider("Slope", value=slope, min=-2, max=5, step=0.1)
|
|
75
|
+
solara.FloatSlider("Intercept", value=intercept, min=-10, max=10, step=0.1)
|
|
76
|
+
|
|
77
|
+
solara.lab.ConfirmationDialog(
|
|
78
|
+
deploy_environment_request.value != "",
|
|
79
|
+
title="Confirm deployment",
|
|
80
|
+
content=solara.Markdown(f"Are you sure you want to deploy to **{deploy_environment_request.value}**?"),
|
|
81
|
+
ok=f"Deploy to {deploy_environment_request.value}",
|
|
82
|
+
on_ok=lambda: deploy_environment.set(deploy_environment_request.value),
|
|
83
|
+
on_close=lambda: deploy_environment_request.set(""),
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
solara.lab.ConfirmationDialog(
|
|
87
|
+
deploy_state.value is False and deploy_state.state == solara.ResultState.FINISHED,
|
|
88
|
+
title="Deployment failed",
|
|
89
|
+
on_close=lambda: None,
|
|
90
|
+
on_ok=lambda: deploy_state.retry(),
|
|
91
|
+
content=solara.Error(solara.Markdown(f"Deployment to **{deploy_environment.value}** failed. Do you want to try again?")),
|
|
92
|
+
ok="Retry deployment",
|
|
93
|
+
cancel="Ignore the failure",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def request_deploy(environment):
|
|
97
|
+
deploy_environment.value = ""
|
|
98
|
+
deploy_environment_request.set(environment)
|
|
99
|
+
|
|
100
|
+
deploying = bool(deploy_environment.value and deploy_state.state == solara.ResultState.RUNNING)
|
|
101
|
+
deploy_button = solara.Button("Deploy model", color="primary", icon_name="mdi-rocket", loading=deploying)
|
|
102
|
+
with solara.lab.Menu(activator=deploy_button):
|
|
103
|
+
with solara.Column(gap="0px"):
|
|
104
|
+
solara.Button("Deploy to testing environment", text=True, icon_name="mdi-bug", on_click=lambda: request_deploy("testing"))
|
|
105
|
+
solara.Button("Deploy to staging environment", text=True, icon_name="mdi-test-tube", on_click=lambda: request_deploy("staging"))
|
|
106
|
+
solara.Button(
|
|
107
|
+
"Deploy to production",
|
|
108
|
+
text=True,
|
|
109
|
+
icon_name="mdi-rocket",
|
|
110
|
+
style={"justify-content": "left"}, # make the icon appear on the left
|
|
111
|
+
on_click=lambda: request_deploy("production"),
|
|
112
|
+
)
|
|
113
|
+
if deploy_state.value is True and deploy_state.state == solara.ResultState.FINISHED:
|
|
114
|
+
# add some margin in the y direction using my-4
|
|
115
|
+
solara.Success(solara.Markdown(f"Model deployed successfully to **{deploy_environment.value}**!"), classes=["my-4"])
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from typing import cast, Optional
|
|
2
|
+
import httpx
|
|
3
|
+
import asyncio
|
|
4
|
+
import solara
|
|
5
|
+
import solara.lab
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@solara.component
|
|
9
|
+
def Page():
|
|
10
|
+
btc = solara.use_reactive(cast(Optional[float], None))
|
|
11
|
+
|
|
12
|
+
async def fetch_btc_price():
|
|
13
|
+
while True:
|
|
14
|
+
await asyncio.sleep(1)
|
|
15
|
+
async with httpx.AsyncClient() as client:
|
|
16
|
+
url = "https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT"
|
|
17
|
+
response = await client.get(url)
|
|
18
|
+
btc.value = float(response.json()["price"])
|
|
19
|
+
print("btc.value", btc.value)
|
|
20
|
+
|
|
21
|
+
fetch_result = solara.lab.use_task(fetch_btc_price, dependencies=[])
|
|
22
|
+
# the task keeps running, so is always in the pending mode, so we combine it with the btc value being None
|
|
23
|
+
if fetch_result.pending and btc.value is None:
|
|
24
|
+
solara.Text("Fetching BTC price...")
|
|
25
|
+
else:
|
|
26
|
+
if fetch_result.error:
|
|
27
|
+
solara.Error(f"Error fetching BTC price: {fetch_result.exception}")
|
|
28
|
+
else:
|
|
29
|
+
solara.Text(f"BTC price: ${btc.value}")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Page()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import pprint
|
|
2
|
+
from types import ModuleType
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
import reacton.ipyvuetify as v
|
|
6
|
+
|
|
7
|
+
auth: Optional[ModuleType]
|
|
8
|
+
try:
|
|
9
|
+
from solara_enterprise import auth
|
|
10
|
+
except ImportError:
|
|
11
|
+
auth = None
|
|
12
|
+
import solara as sl
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@sl.component
|
|
16
|
+
def UserCard():
|
|
17
|
+
assert auth is not None
|
|
18
|
+
user = auth.user.value
|
|
19
|
+
if user:
|
|
20
|
+
user_info = user.get("userinfo")
|
|
21
|
+
if user_info:
|
|
22
|
+
# based on https://v2.vuetifyjs.com/en/components/cards/#props
|
|
23
|
+
with v.Card(width="400px"):
|
|
24
|
+
with v.ListItem(three_line=True):
|
|
25
|
+
with v.ListItemContent():
|
|
26
|
+
sl.Div("Logged in", class_="text-overline mb-4")
|
|
27
|
+
v.ListItemTitle(children=[user_info["email"]])
|
|
28
|
+
v.ListItemSubtitle(children=["You are now logged in, log out via the app bar, or the button below"])
|
|
29
|
+
with v.ListItemAvatar():
|
|
30
|
+
auth.Avatar()
|
|
31
|
+
|
|
32
|
+
with v.CardActions():
|
|
33
|
+
sl.Button("logout", icon_name="mdi-logout", href=auth.get_logout_url(), text=True)
|
|
34
|
+
else:
|
|
35
|
+
sl.Error("No user info")
|
|
36
|
+
else:
|
|
37
|
+
sl.Error("No user")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@sl.component
|
|
41
|
+
def Page():
|
|
42
|
+
assert auth is not None
|
|
43
|
+
sl.Title("Login demo using OAuth")
|
|
44
|
+
with sl.AppBar():
|
|
45
|
+
if auth.user.value:
|
|
46
|
+
auth.AvatarMenu()
|
|
47
|
+
else:
|
|
48
|
+
sl.Button(icon_name="mdi-login", href=auth.get_login_url(), icon=True)
|
|
49
|
+
|
|
50
|
+
with sl.Column():
|
|
51
|
+
if auth.user.value:
|
|
52
|
+
UserCard()
|
|
53
|
+
with sl.Details("Raw data"):
|
|
54
|
+
sl.Markdown(
|
|
55
|
+
"""
|
|
56
|
+
### Raw user data
|
|
57
|
+
|
|
58
|
+
*Note: do not share this data with anyone, it contains sensitive information.*
|
|
59
|
+
|
|
60
|
+
This is the raw user data from the auth provider.
|
|
61
|
+
|
|
62
|
+
We use the `picture` field to display an avatar in the [AppBar](/documentation/components/layout/app_bar).
|
|
63
|
+
"""
|
|
64
|
+
)
|
|
65
|
+
sl.Preformatted(pprint.pformat(auth.user.value))
|
|
66
|
+
else:
|
|
67
|
+
sl.Markdown(
|
|
68
|
+
"""
|
|
69
|
+
### Login demo
|
|
70
|
+
|
|
71
|
+
This is a demo of a login system using OAuth. You can login with your google account, github account or with a username and password.
|
|
72
|
+
We are using [Auth0](https://auth0.com/) as an OAuth provider.
|
|
73
|
+
|
|
74
|
+
"""
|
|
75
|
+
)
|
|
76
|
+
with sl.Row():
|
|
77
|
+
sl.Button("login", icon_name="mdi-login", href=auth.get_login_url())
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if auth is None:
|
|
81
|
+
del Page
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-card class="text-center" :color="color" dark>
|
|
3
|
+
<v-card-text>
|
|
4
|
+
<v-sheet color="rgba(0, 0, 0, .12)">
|
|
5
|
+
<v-sparkline :value="value" color="rgba(255, 255, 255, .7)" height="100" padding="24" stroke-linecap="round"
|
|
6
|
+
smooth>
|
|
7
|
+
<template v-slot:label="item">
|
|
8
|
+
${{ item.value }}
|
|
9
|
+
</template>
|
|
10
|
+
</v-sparkline>
|
|
11
|
+
</v-sheet>
|
|
12
|
+
</v-card-text>
|
|
13
|
+
|
|
14
|
+
<v-card-text>
|
|
15
|
+
<h1 class="solara-some-class">{{ caption }}</h1>
|
|
16
|
+
</v-card-text>
|
|
17
|
+
|
|
18
|
+
<v-divider></v-divider>
|
|
19
|
+
|
|
20
|
+
<v-card-actions class="justify-center">
|
|
21
|
+
<v-btn block text @click="goto_report">
|
|
22
|
+
Go to Report
|
|
23
|
+
</v-btn>
|
|
24
|
+
</v-card-actions>
|
|
25
|
+
</v-card>
|
|
26
|
+
</template>
|
|
27
|
+
<style id="mycard">
|
|
28
|
+
.solara-some-class {
|
|
29
|
+
font-weight: lighter;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
export default {
|
|
35
|
+
data: () => ({
|
|
36
|
+
value: [
|
|
37
|
+
423,
|
|
38
|
+
446,
|
|
39
|
+
675,
|
|
40
|
+
510,
|
|
41
|
+
590,
|
|
42
|
+
610,
|
|
43
|
+
760,
|
|
44
|
+
],
|
|
45
|
+
}),
|
|
46
|
+
mounted: () => {
|
|
47
|
+
console.log('mounted');
|
|
48
|
+
},
|
|
49
|
+
destroyed: () => {
|
|
50
|
+
console.log('destroyed');
|
|
51
|
+
},
|
|
52
|
+
watch: {
|
|
53
|
+
value: function (val) {
|
|
54
|
+
console.log('value changed to', val);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""# Pokemon search
|
|
2
|
+
|
|
3
|
+
This example shows to to dynamically fetch data and render the results in a table when done, and show an error on failure.
|
|
4
|
+
|
|
5
|
+
It also shows an optional filter to narrow down the results.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import solara
|
|
9
|
+
from solara import use_fetch
|
|
10
|
+
from solara.alias import rv
|
|
11
|
+
|
|
12
|
+
github_url = solara.util.github_url(__file__)
|
|
13
|
+
pokemon_base_url = "https://raw.githubusercontent.com/jherr/pokemon/0722479d4153b1db0d0326956b08b37f44a95a5f"
|
|
14
|
+
json_url = f"{pokemon_base_url}/index.json"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@solara.component
|
|
18
|
+
def Page():
|
|
19
|
+
data = use_fetch(json_url)
|
|
20
|
+
json = solara.use_json_load(data)
|
|
21
|
+
filter, set_filter = solara.use_state("")
|
|
22
|
+
|
|
23
|
+
with solara.Div() as main:
|
|
24
|
+
if json.error:
|
|
25
|
+
solara.Error(f"Error {json.error}")
|
|
26
|
+
solara.Button("Retry", on_click=data.retry)
|
|
27
|
+
else:
|
|
28
|
+
if json.value:
|
|
29
|
+
solara.InputText(label="Filter pokemons by name", value=filter, on_value=set_filter, continuous_update=True)
|
|
30
|
+
pokemons = json.value
|
|
31
|
+
if filter:
|
|
32
|
+
pokemons = [k for k in pokemons if filter.lower() in k["name"].lower()]
|
|
33
|
+
if len(pokemons) == 0:
|
|
34
|
+
solara.Warning("No pokemons found, try a different filter")
|
|
35
|
+
else:
|
|
36
|
+
solara.Info(f"{len(pokemons)} pokemons found")
|
|
37
|
+
else:
|
|
38
|
+
solara.Info(f"{len(pokemons)} pokemons in total")
|
|
39
|
+
with solara.GridFixed(columns=4, align_items="end", justify_items="stretch"):
|
|
40
|
+
for pokemon in pokemons[:20]:
|
|
41
|
+
with solara.Div():
|
|
42
|
+
name = pokemon["name"]
|
|
43
|
+
url = f"{pokemon_base_url}/{pokemon['image']}"
|
|
44
|
+
# TODO: how to do this with solara
|
|
45
|
+
rv.Img(src=url, contain=True, max_height="200px")
|
|
46
|
+
solara.Text(name)
|
|
47
|
+
else:
|
|
48
|
+
with solara.Div():
|
|
49
|
+
solara.Text("Loading...")
|
|
50
|
+
rv.ProgressCircular(indeterminate=True, class_="solara-progress")
|
|
51
|
+
return main
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Demonstrates how to use Vue components in Solara.
|
|
2
|
+
|
|
3
|
+
Although many components can be made from the Python side, sometimes it is easier to write components using Vue directly.
|
|
4
|
+
It can also be beneficial for performance, since instead of creating many widgets from the Python side we only send data to
|
|
5
|
+
the frontend. If event handling is also done on the frontend, this reduces latency and makes you app feel much smoother.
|
|
6
|
+
|
|
7
|
+
See [the API documentation on component_vue](/documentation/api/utilities/component_vue) for more information.
|
|
8
|
+
|
|
9
|
+
This example is based on [the vuetify docs](https://v2.vuetifyjs.com/en/components/sparklines/#custom-labels),
|
|
10
|
+
Note that the "Go to report" button does not do anything yet.
|
|
11
|
+
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from typing import Callable
|
|
15
|
+
|
|
16
|
+
import numpy as np
|
|
17
|
+
import solara
|
|
18
|
+
|
|
19
|
+
seed = solara.reactive(42)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@solara.component_vue("mycard.vue")
|
|
23
|
+
def MyCard(
|
|
24
|
+
event_goto_report: Callable[[dict], None],
|
|
25
|
+
value=[1, 10, 30, 20, 3],
|
|
26
|
+
caption="My Card",
|
|
27
|
+
color="red",
|
|
28
|
+
):
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@solara.component
|
|
33
|
+
def Page():
|
|
34
|
+
gen = np.random.RandomState(seed=seed.value)
|
|
35
|
+
sales_data = np.floor(np.cumsum(gen.random(7) - 0.5) * 100 + 100)
|
|
36
|
+
show_report = solara.use_reactive(False)
|
|
37
|
+
|
|
38
|
+
with solara.Column():
|
|
39
|
+
if show_report.value:
|
|
40
|
+
with solara.Card("Report"):
|
|
41
|
+
solara.Markdown("Lorum ipsum dolor sit amet")
|
|
42
|
+
solara.Button("Go back", on_click=lambda: show_report.set(False))
|
|
43
|
+
else:
|
|
44
|
+
|
|
45
|
+
def new_seed():
|
|
46
|
+
seed.value = np.random.randint(0, 100)
|
|
47
|
+
|
|
48
|
+
solara.Button("Generate new data", on_click=new_seed)
|
|
49
|
+
|
|
50
|
+
MyCard(value=sales_data.tolist(), color="green", caption="Sales Last 7 Days", event_goto_report=lambda data: show_report.set(True))
|