solara-ui 1.31.0__py2.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 +734 -0
- solara/alias.py +6 -0
- solara/autorouting.py +546 -0
- solara/cache.py +303 -0
- solara/checks.html +71 -0
- solara/checks.py +224 -0
- solara/comm.py +28 -0
- solara/components/__init__.py +59 -0
- solara/components/alert.py +155 -0
- solara/components/applayout.py +393 -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 +110 -0
- solara/components/cross_filter.py +335 -0
- solara/components/dataframe.py +546 -0
- solara/components/datatable.py +221 -0
- solara/components/datatable.vue +175 -0
- solara/components/details.py +21 -0
- solara/components/download.vue +35 -0
- solara/components/echarts.py +75 -0
- solara/components/echarts.vue +128 -0
- solara/components/figure_altair.py +39 -0
- solara/components/file_browser.py +182 -0
- solara/components/file_download.py +199 -0
- solara/components/file_drop.py +139 -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 +436 -0
- solara/components/link.py +55 -0
- solara/components/markdown.py +378 -0
- solara/components/markdown_editor.py +25 -0
- solara/components/markdown_editor.vue +362 -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 +30 -0
- solara/components/sql_code.py +33 -0
- solara/components/sql_code.vue +128 -0
- solara/components/style.py +105 -0
- solara/components/switch.py +68 -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/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 +129 -0
- solara/hooks/use_thread.py +129 -0
- solara/kitchensink.py +8 -0
- solara/lab/__init__.py +34 -0
- solara/lab/components/__init__.py +6 -0
- solara/lab/components/chat.py +203 -0
- solara/lab/components/confirmation_dialog.py +163 -0
- solara/lab/components/cross_filter.py +7 -0
- solara/lab/components/input_date.py +298 -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 +12 -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 +115 -0
- solara/lab/utils/headers.py +5 -0
- solara/layout.py +44 -0
- solara/lifecycle.py +46 -0
- solara/minisettings.py +133 -0
- solara/py.typed +0 -0
- solara/reactive.py +93 -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 +491 -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 +1665 -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 +77 -0
- solara/server/esm.py +69 -0
- solara/server/fastapi.py +5 -0
- solara/server/flask.py +286 -0
- solara/server/jupyter/__init__.py +2 -0
- solara/server/jupyter/cdn_handler.py +28 -0
- solara/server/jupyter/server_extension.py +29 -0
- solara/server/jupytertools.py +46 -0
- solara/server/kernel.py +338 -0
- solara/server/kernel_context.py +357 -0
- solara/server/patch.py +552 -0
- solara/server/reload.py +242 -0
- solara/server/server.py +456 -0
- solara/server/settings.py +215 -0
- solara/server/shell.py +251 -0
- solara/server/starlette.py +601 -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 +260 -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 +446 -0
- solara/server/threaded.py +75 -0
- solara/server/utils.py +30 -0
- solara/server/websocket.py +45 -0
- solara/settings.py +56 -0
- solara/tasks.py +837 -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 +697 -0
- solara/toestand.py +772 -0
- solara/util.py +308 -0
- solara/website/__init__.py +0 -0
- solara/website/assets/custom.css +468 -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.vue +24 -0
- solara/website/components/algolia_api.vue +187 -0
- solara/website/components/docs.py +118 -0
- solara/website/components/header.py +72 -0
- solara/website/components/hero.py +15 -0
- solara/website/components/mailchimp.py +12 -0
- solara/website/components/mailchimp.vue +47 -0
- solara/website/components/markdown.py +30 -0
- solara/website/components/notebook.py +171 -0
- solara/website/pages/__init__.py +575 -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/changelog/__init__.py +8 -0
- solara/website/pages/changelog/changelog.md +204 -0
- solara/website/pages/contact/__init__.py +8 -0
- solara/website/pages/contact/contact.md +17 -0
- solara/website/pages/doc_use_download.py +85 -0
- solara/website/pages/documentation/__init__.py +184 -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 +162 -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 +49 -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 +36 -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 +7 -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 +240 -0
- solara/website/pages/documentation/advanced/content/20-understanding/50-solara-server.md +97 -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 +1 -0
- solara/website/pages/documentation/advanced/content/30-enterprise/10-oauth.md +171 -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 +23 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_report.py +22 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_select.py +22 -0
- solara/website/pages/documentation/api/cross_filter/cross_filter_slider.py +22 -0
- solara/website/pages/documentation/api/hooks/__init__.py +9 -0
- solara/website/pages/documentation/api/hooks/use_cross_filter.py +25 -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 +33 -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 +33 -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 +69 -0
- solara/website/pages/documentation/api/hooks/use_thread.md +58 -0
- solara/website/pages/documentation/api/hooks/use_thread.py +44 -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 +31 -0
- solara/website/pages/documentation/api/routing/use_route.py +80 -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 +27 -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 +27 -0
- solara/website/pages/documentation/components/advanced/meta.py +20 -0
- solara/website/pages/documentation/components/advanced/style.py +45 -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 +32 -0
- solara/website/pages/documentation/components/input/file_drop.py +76 -0
- solara/website/pages/documentation/components/input/input.py +19 -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/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 +72 -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 +68 -0
- solara/website/pages/documentation/components/layout/griddraggable.py +62 -0
- solara/website/pages/documentation/components/layout/gridfixed.py +21 -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 +21 -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 +85 -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 +18 -0
- solara/website/pages/documentation/components/page/title.py +27 -0
- solara/website/pages/documentation/components/status/__init__.py +9 -0
- solara/website/pages/documentation/components/status/error.py +40 -0
- solara/website/pages/documentation/components/status/info.py +40 -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 +75 -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 +52 -0
- solara/website/pages/documentation/examples/ai/__init__.py +11 -0
- solara/website/pages/documentation/examples/ai/chatbot.py +95 -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 +38 -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 +64 -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 +64 -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 +69 -0
- solara/website/pages/documentation/examples/visualization/linked_views.py +84 -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 +76 -0
- solara/website/pages/documentation/getting_started/__init__.py +9 -0
- solara/website/pages/documentation/getting_started/content/00-quickstart.md +89 -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 +64 -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 +1000 -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 +223 -0
- solara/website/pages/documentation/getting_started/content/05-fundamentals/50-state-management.md +88 -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 +273 -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/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 +110 -0
- solara/widgets/vue/html.vue +4 -0
- solara/widgets/vue/navigator.vue +104 -0
- solara/widgets/vue/vegalite.vue +115 -0
- solara/widgets/widgets.py +66 -0
- solara_ui-1.31.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json +7 -0
- solara_ui-1.31.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json +7 -0
- solara_ui-1.31.0.dist-info/METADATA +158 -0
- solara_ui-1.31.0.dist-info/RECORD +439 -0
- solara_ui-1.31.0.dist-info/WHEEL +5 -0
- solara_ui-1.31.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# use_state_or_update
|
|
3
|
+
|
|
4
|
+
Like `solara.use_state`, except it will update the value if the input value changes.
|
|
5
|
+
|
|
6
|
+
This is useful to give a component state *or* allow the state to be controlled by the parent component
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import solara
|
|
12
|
+
|
|
13
|
+
title = "use_state_or_update"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@solara.component
|
|
17
|
+
def SliderWithoutState(value: int):
|
|
18
|
+
# Note that this is a very bad practice, if value is an input change and the slider
|
|
19
|
+
# can change it, this component should have a on_value callback to allow the parent
|
|
20
|
+
# component to manage its state.
|
|
21
|
+
# This component is only for demoing/understanding.
|
|
22
|
+
return solara.IntSlider("value", value=value)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@solara.component
|
|
26
|
+
def SliderWithState(value: int):
|
|
27
|
+
# effectively, because of use_state, the value prop passed in is
|
|
28
|
+
# only a default value.
|
|
29
|
+
value, set_value = solara.use_state(value)
|
|
30
|
+
return solara.IntSlider("value", value=value, on_value=set_value)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@solara.component
|
|
34
|
+
def SliderWithStateOrUpdate(value: int):
|
|
35
|
+
value, set_value = solara.use_state_or_update(value)
|
|
36
|
+
return solara.IntSlider("value", value=value, on_value=set_value)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@solara.component
|
|
40
|
+
def Page():
|
|
41
|
+
parent_value, set_parent_value = solara.use_state(4)
|
|
42
|
+
# used to force rerenders
|
|
43
|
+
rerender_counter, set_rerender_counter = solara.use_state(4)
|
|
44
|
+
with solara.VBox() as main:
|
|
45
|
+
with solara.Card("Parent value selection"):
|
|
46
|
+
solara.Info("This slider value gets passed down to the child components")
|
|
47
|
+
solara.IntSlider("parent value", value=parent_value, on_value=set_parent_value)
|
|
48
|
+
solara.Button("Force redraw", on_click=lambda: set_rerender_counter(rerender_counter + 1))
|
|
49
|
+
|
|
50
|
+
with solara.Card("Child without state"):
|
|
51
|
+
solara.Info("This child will simply render the value passed into the argument, a redraw will reset it to its parent value.")
|
|
52
|
+
SliderWithoutState(parent_value)
|
|
53
|
+
|
|
54
|
+
with solara.Card("Child with state"):
|
|
55
|
+
solara.Info("This child will not care about the value passed into the prop, it manages its own state.")
|
|
56
|
+
SliderWithState(parent_value)
|
|
57
|
+
|
|
58
|
+
with solara.Card("Child with state (or update)"):
|
|
59
|
+
solara.Info("This child will update when the passes in a new value, but a redraw will not reset it.")
|
|
60
|
+
SliderWithStateOrUpdate(parent_value)
|
|
61
|
+
|
|
62
|
+
with solara.Card("Child with state + key"):
|
|
63
|
+
solara.Info(
|
|
64
|
+
"We can also use the `.key(...)` method to force the component to forget its state, this will however cause the widget to be re-created"
|
|
65
|
+
"(a performance penalty)."
|
|
66
|
+
)
|
|
67
|
+
SliderWithState(parent_value).key(f"slider-{parent_value}")
|
|
68
|
+
|
|
69
|
+
return main
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# use_thread
|
|
2
|
+
|
|
3
|
+
```python
|
|
4
|
+
def use_thread(
|
|
5
|
+
callback=Union[
|
|
6
|
+
Callable[[threading.Event], T],
|
|
7
|
+
Iterator[Callable[[threading.Event], T]],
|
|
8
|
+
Callable[[], T],
|
|
9
|
+
Iterator[Callable[[], T]],
|
|
10
|
+
],
|
|
11
|
+
intrusive_cancel=True,
|
|
12
|
+
dependencies=[],
|
|
13
|
+
) -> Result[T]:
|
|
14
|
+
...
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`use_thread` can be used to run medium or long running jobs in a separate thread to avoid blocking the render loop.
|
|
18
|
+
|
|
19
|
+
`use_thread` takes a function as argument that takes a `threading.Event` object as argument to check whether it should stop,
|
|
20
|
+
and should return it's resulting value, or yield it multiple times (thus an iterator).
|
|
21
|
+
|
|
22
|
+
The return value of `use_thread` is a `Result[T]`, making it easy to have the UI reflect the state of the work being done.
|
|
23
|
+
|
|
24
|
+
When an iterator is passed, the state only enters the `FINISHED` state after the last element is yielded. Partial, or incremental results can be detected when the state is still in `RUNNING`, but `Result[T].value` is not None.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
From any state the `.cancel()` or `.retry()` may be called, which will stop the current thread, and start all over.
|
|
29
|
+
Note that at no time, two threads will run, since the new thread will always wait for the previous to finish.
|
|
30
|
+
|
|
31
|
+
When `intrusive_cancel=True`, a tracer is installed into the thread, which will throw a special exception to cancel the thread. This gives some runtime overhead, and a more performant way would be to set this to false and manually inspect the `threading.Event` regularly. When this is not possible (e.g. usage of an external library), this is the only way to cancel a thread while executing.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Note that `.value` and `.error` of the result object will only be set when a new result is returned. This makes is possible for a component to render the "previous" result (or previous error) while the new job is running.
|
|
35
|
+
|
|
36
|
+
## State diagram
|
|
37
|
+
|
|
38
|
+
The possible values for `Result[T].state` are stored in the dataclass `solara.ResultState`, with the possible options being
|
|
39
|
+
|
|
40
|
+
* `STARTING`
|
|
41
|
+
* `WAITING`
|
|
42
|
+
* `RUNNING`
|
|
43
|
+
* `ERROR`
|
|
44
|
+
* `FINISHED`
|
|
45
|
+
* `CANCELLED`
|
|
46
|
+
|
|
47
|
+
These states are reflected in the below state diagram
|
|
48
|
+
|
|
49
|
+
```mermaid
|
|
50
|
+
graph TD;
|
|
51
|
+
INITIAL-- "Thread.start()" -->STARTING;
|
|
52
|
+
STARTING-- "previous thread running" -->WAITING;
|
|
53
|
+
STARTING-- "no previous thread" -->RUNNING;
|
|
54
|
+
WAITING-- "thread.join()" -->RUNNING;
|
|
55
|
+
RUNNING-- "on exception" -->ERROR
|
|
56
|
+
RUNNING-- "work finished" -->FINISHED
|
|
57
|
+
RUNNING-- "cancel()" -->CANCELLED
|
|
58
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Optional, cast
|
|
4
|
+
|
|
5
|
+
import solara
|
|
6
|
+
from solara.alias import rv, rw
|
|
7
|
+
|
|
8
|
+
HERE = Path(__file__).parent
|
|
9
|
+
title = "use_thread"
|
|
10
|
+
__doc__ = open(HERE / "use_thread.md").read()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@solara.component
|
|
14
|
+
def Page():
|
|
15
|
+
number, set_number = solara.use_state(17)
|
|
16
|
+
# the number that proofs it is not a prime
|
|
17
|
+
proof, set_proof = solara.use_state(cast(Optional[int], None))
|
|
18
|
+
|
|
19
|
+
def work():
|
|
20
|
+
for i in range(3, number):
|
|
21
|
+
reminder = number % i
|
|
22
|
+
if reminder == 0:
|
|
23
|
+
set_proof(i)
|
|
24
|
+
return False
|
|
25
|
+
# make it always take ~4 seconds
|
|
26
|
+
time.sleep(4 / number)
|
|
27
|
+
return True
|
|
28
|
+
|
|
29
|
+
# work will be cancelled/restarted every time the dependency changes
|
|
30
|
+
result: solara.Result[bool] = solara.use_thread(work, dependencies=[number])
|
|
31
|
+
|
|
32
|
+
with solara.VBox() as main:
|
|
33
|
+
rw.IntText(value=number, on_value=set_number)
|
|
34
|
+
if result.state == solara.ResultState.FINISHED:
|
|
35
|
+
if result.value:
|
|
36
|
+
solara.Success(f"{number} is a prime!")
|
|
37
|
+
else:
|
|
38
|
+
solara.Error(f"{number} is not a prime, it can be divided by {proof} ")
|
|
39
|
+
elif result.state == solara.ResultState.ERROR:
|
|
40
|
+
solara.Error(f"Error occurred: {result.error}")
|
|
41
|
+
else:
|
|
42
|
+
solara.Info(f"Running... (status = {result.state})")
|
|
43
|
+
rv.ProgressLinear(indeterminate=True)
|
|
44
|
+
return main
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""# use_trait_observe"""
|
|
2
|
+
|
|
3
|
+
import solara
|
|
4
|
+
import solara.autorouting
|
|
5
|
+
import solara.lab
|
|
6
|
+
from solara.website.utils import apidoc
|
|
7
|
+
|
|
8
|
+
from . import NoPage
|
|
9
|
+
|
|
10
|
+
title = "use_trait_observe"
|
|
11
|
+
Page = NoPage
|
|
12
|
+
__doc__ += apidoc(solara.use_trait_observe) # type: ignore
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""# generate_routes"""
|
|
2
|
+
|
|
3
|
+
import solara
|
|
4
|
+
import solara.autorouting
|
|
5
|
+
from solara.website.components import NoPage
|
|
6
|
+
from solara.website.utils import apidoc
|
|
7
|
+
|
|
8
|
+
title = "generate_routes"
|
|
9
|
+
Page = NoPage
|
|
10
|
+
__doc__ += apidoc(solara.autorouting.generate_routes) # type: ignore
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""# generate_routes_directory"""
|
|
2
|
+
|
|
3
|
+
import solara
|
|
4
|
+
import solara.autorouting
|
|
5
|
+
from solara.website.components import NoPage
|
|
6
|
+
from solara.website.utils import apidoc
|
|
7
|
+
|
|
8
|
+
title = "generate_routes_directory"
|
|
9
|
+
Page = NoPage
|
|
10
|
+
__doc__ += apidoc(solara.autorouting.generate_routes_directory) # type: ignore
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""# resolve_route"""
|
|
2
|
+
|
|
3
|
+
import solara
|
|
4
|
+
from solara.website.utils import apidoc
|
|
5
|
+
|
|
6
|
+
title = "resolve_route"
|
|
7
|
+
routes = [
|
|
8
|
+
solara.Route(path="/"),
|
|
9
|
+
solara.Route(path="kiwi"),
|
|
10
|
+
solara.Route(path="banana"),
|
|
11
|
+
solara.Route(path="apple"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@solara.component
|
|
16
|
+
def Page():
|
|
17
|
+
route_current, routes = solara.use_route()
|
|
18
|
+
with solara.VBox() as main:
|
|
19
|
+
# solara.Warning("Note the address bar in the browser. It should change to the path of the link.")
|
|
20
|
+
solara.Markdown("*Click on one of the links below to change the route and see the url in your browser change, and match the text.*")
|
|
21
|
+
with solara.VBox():
|
|
22
|
+
for route in routes:
|
|
23
|
+
path = solara.resolve_path(route)
|
|
24
|
+
# we could have passed the route object directly to Link, but we want to show the path
|
|
25
|
+
# can also be used.
|
|
26
|
+
with solara.Link(path):
|
|
27
|
+
current = route_current is route
|
|
28
|
+
if current:
|
|
29
|
+
solara.Success(f"You are at {path}")
|
|
30
|
+
else:
|
|
31
|
+
solara.Info(f"{route.path} will navigate to {path}")
|
|
32
|
+
return main
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__doc__ += apidoc(solara.resolve_path) # type: ignore
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""# Route"""
|
|
2
|
+
|
|
3
|
+
import solara
|
|
4
|
+
from solara.website.utils import apidoc
|
|
5
|
+
|
|
6
|
+
routes = [
|
|
7
|
+
solara.Route(path="/"),
|
|
8
|
+
solara.Route(path="kiwi"),
|
|
9
|
+
solara.Route(path="banana"),
|
|
10
|
+
solara.Route(path="apple"),
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@solara.component
|
|
15
|
+
def Page():
|
|
16
|
+
route_current, routes = solara.use_route()
|
|
17
|
+
with solara.VBox() as main:
|
|
18
|
+
# solara.Warning("Note the address bar in the browser. It should change to the path of the link.")
|
|
19
|
+
solara.Markdown("*Click on one of the links below to change the route and see the url in your browser change, and match the route.*")
|
|
20
|
+
with solara.VBox():
|
|
21
|
+
for route in routes:
|
|
22
|
+
with solara.Link(route):
|
|
23
|
+
current = route_current is route
|
|
24
|
+
if current:
|
|
25
|
+
solara.Success(f"You are at solara.Route(path={route.path!r})")
|
|
26
|
+
else:
|
|
27
|
+
solara.Info(f"Go to solara.Route(path={route.path!r})")
|
|
28
|
+
return main
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__doc__ += apidoc(solara.Route, full=True) # type: ignore
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# use_route
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import solara
|
|
6
|
+
from solara.website.utils import apidoc
|
|
7
|
+
|
|
8
|
+
title = "use_route"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@solara.component
|
|
12
|
+
def Fruit():
|
|
13
|
+
# this gets all routes in fruit's children
|
|
14
|
+
route, routes = solara.use_route()
|
|
15
|
+
|
|
16
|
+
if route is None:
|
|
17
|
+
with solara.Link("banana") as main:
|
|
18
|
+
solara.Button("Fruit not found, go to banana")
|
|
19
|
+
return main
|
|
20
|
+
|
|
21
|
+
if route.path == "/":
|
|
22
|
+
with solara.Link("banana") as main:
|
|
23
|
+
solara.Button("Choose a fruit, I recomment banana")
|
|
24
|
+
return main
|
|
25
|
+
|
|
26
|
+
with solara.VBox() as main:
|
|
27
|
+
with solara.HBox():
|
|
28
|
+
for route_fruit in routes[1:]:
|
|
29
|
+
with solara.Link(solara.resolve_path(route_fruit)):
|
|
30
|
+
solara.Button(route_fruit.path)
|
|
31
|
+
|
|
32
|
+
with solara.Link("/documentation/api/routing/use_route/fruit/nofruit", nofollow=True):
|
|
33
|
+
solara.Button("Wrong fruit")
|
|
34
|
+
with solara.Link("/documentation/api/routing/use_route/not-routed", nofollow=True):
|
|
35
|
+
solara.Button("Wrong url")
|
|
36
|
+
solara.Success(f"You chose {route.path}")
|
|
37
|
+
return main
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@solara.component
|
|
41
|
+
def Page():
|
|
42
|
+
# this gets the top level routes, '/' and 'fruit'
|
|
43
|
+
route_current, routes_all = solara.use_route()
|
|
44
|
+
with solara.VBox() as main:
|
|
45
|
+
with solara.Card("Navigation using buttons"):
|
|
46
|
+
with solara.HBox():
|
|
47
|
+
for route in routes_all:
|
|
48
|
+
with solara.Link(route):
|
|
49
|
+
solara.Button(route.path, color="red" if route_current == route else None)
|
|
50
|
+
with solara.Card("Content decided by route:"):
|
|
51
|
+
if route_current is None:
|
|
52
|
+
solara.Error("Page does not exist")
|
|
53
|
+
with solara.Link("fruit/kiwi"):
|
|
54
|
+
solara.Button("Go to fruit/kiwi")
|
|
55
|
+
elif route_current.path == "/":
|
|
56
|
+
with solara.Link("fruit/banana"):
|
|
57
|
+
solara.Button("Go to fruit/banana")
|
|
58
|
+
elif route_current.path == "fruit":
|
|
59
|
+
Fruit()
|
|
60
|
+
else:
|
|
61
|
+
solara.Error(f"Unknown route: {route_current.path}")
|
|
62
|
+
return main
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
routes = [
|
|
66
|
+
solara.Route(path="/"),
|
|
67
|
+
solara.Route(
|
|
68
|
+
path="fruit",
|
|
69
|
+
component=Fruit,
|
|
70
|
+
children=[
|
|
71
|
+
solara.Route(path="/"),
|
|
72
|
+
solara.Route(path="kiwi"),
|
|
73
|
+
solara.Route(path="banana"),
|
|
74
|
+
solara.Route(path="apple"),
|
|
75
|
+
],
|
|
76
|
+
),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
sources = [Fruit.f, Page.f] # type: ignore
|
|
80
|
+
__doc__ += apidoc(solara.use_route) # type: ignore
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# get_kernel_id
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import solara
|
|
7
|
+
from solara.website.components import NoPage
|
|
8
|
+
from solara.website.utils import apidoc
|
|
9
|
+
|
|
10
|
+
title = "get_kernel_id"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Page = NoPage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__doc__ += apidoc(solara.get_kernel_id) # type: ignore
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# get_session_id
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import solara
|
|
7
|
+
from solara.website.components import NoPage
|
|
8
|
+
from solara.website.utils import apidoc
|
|
9
|
+
|
|
10
|
+
title = "get_session_id"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Page = NoPage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__doc__ += apidoc(solara.get_session_id) # type: ignore
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""#Memoize"""
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
|
|
5
|
+
import solara
|
|
6
|
+
import solara.lab
|
|
7
|
+
from solara.website.utils import apidoc
|
|
8
|
+
|
|
9
|
+
# make sure the cache is only created once
|
|
10
|
+
storage = solara.cache.Memory(max_items=2)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@solara.component
|
|
14
|
+
def Page():
|
|
15
|
+
x, set_x = solara.use_state(5)
|
|
16
|
+
|
|
17
|
+
@solara.memoize(storage=storage)
|
|
18
|
+
def long_running_function(x: int) -> int:
|
|
19
|
+
"""This function takes a long time to run."""
|
|
20
|
+
time.sleep(3)
|
|
21
|
+
return x**2
|
|
22
|
+
|
|
23
|
+
result = long_running_function.use_thread(x)
|
|
24
|
+
|
|
25
|
+
with solara.Card("Expensive computation") as main:
|
|
26
|
+
solara.Markdown("We cache 2 values. Each computation takes 3 seconds. If you go back to a cached value, you will see the result immediately.")
|
|
27
|
+
solara.IntSlider("x", value=x, on_value=set_x)
|
|
28
|
+
if result.state == solara.ResultState.FINISHED:
|
|
29
|
+
solara.Markdown(f"Square of {x} is {result.value}")
|
|
30
|
+
else:
|
|
31
|
+
solara.Markdown("Running...")
|
|
32
|
+
return main
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__doc__ += apidoc(solara.memoize) # type: ignore
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
# on_kernel_start
|
|
3
|
+
|
|
4
|
+
Run a function when a virtual kernel (re)starts and optionally run a cleanup function on shutdown.
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
def on_kernel_start(f: Callable[[], Optional[Callable[[], None]]]) -> Callable[[], None]:
|
|
8
|
+
...
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`f` will be called on each virtual kernel (re)start. This (usually) happens each time a browser tab connects to the server
|
|
12
|
+
[see solara server for more details](https://solara.dev/docs/understanding/solara-server).
|
|
13
|
+
The (optional) function returned by `f` will be called on kernel shutdown.
|
|
14
|
+
|
|
15
|
+
Note that the cleanup functions are called in reverse order with respect to the order in which they were registered
|
|
16
|
+
(e.g. the cleanup function of the last call to `on_kernel_start` will be called first on kernel shutdown).
|
|
17
|
+
|
|
18
|
+
The return value of on_kernel_start is a cleanup function that will remove the callback from the list of callbacks to be called on kernel start.
|
|
19
|
+
|
|
20
|
+
During hot reload, the callbacks that are added from scripts or modules that will be reloaded will be removed before the app is loaded
|
|
21
|
+
again. This can cause the order of the callbacks to be different than at first run.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from solara.website.components import NoPage
|
|
25
|
+
|
|
26
|
+
title = "on_kernel_start"
|
|
27
|
+
Page = NoPage
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
# Component.widget
|
|
4
|
+
|
|
5
|
+
Create a classic ipywidget from a component.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
def widget(self, **kwargs):
|
|
9
|
+
...
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
This will create a widget from the component. The widget will be a
|
|
14
|
+
subclass of `ipywidgets.VBox` and `ipywidgets.ValueWidget`.
|
|
15
|
+
|
|
16
|
+
Example
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import solara
|
|
20
|
+
widget = solara.FileDownload.widget(data="some text data", filename="solara-demo.txt")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This is very useful if you are migrating your application from a classic
|
|
24
|
+
ipywidget to solara. See [also the ipywidgets tutorial](/documentation/getting_started/tutorials/ipywidgets).
|
|
25
|
+
|
|
26
|
+
The `ipywidgets.ValueWidget` is used to enable the use of the widget in
|
|
27
|
+
interact, or interactive. The `ipywidgets.VBox` is used to enable
|
|
28
|
+
nesting of widgets.
|
|
29
|
+
|
|
30
|
+
All keyword arguments will be passed to the component.
|
|
31
|
+
Each argument pair of `on_<name>` and `<name>` will
|
|
32
|
+
be added as a trait in the widget.
|
|
33
|
+
|
|
34
|
+
For example,
|
|
35
|
+
|
|
36
|
+
```solara
|
|
37
|
+
import solara
|
|
38
|
+
import ipywidgets as widgets
|
|
39
|
+
import random
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
countries_demo_data = {
|
|
43
|
+
"Netherlands": ["Amsterdam", "Rotterdam", "The Hague"],
|
|
44
|
+
"Germany": ["Berlin", "Hamburg", "Munich"],
|
|
45
|
+
"France": ["Paris", "Marseille", "Lyon"],
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# this component can be used in a component three, but ...
|
|
50
|
+
@solara.component
|
|
51
|
+
def LocationSelect(value, on_value, countries=countries_demo_data):
|
|
52
|
+
country, city = value
|
|
53
|
+
cities = countries.get(country, [])
|
|
54
|
+
# reset to None if not in the list of countries
|
|
55
|
+
if city not in cities:
|
|
56
|
+
city = None
|
|
57
|
+
# update the state if we changed/reset city
|
|
58
|
+
on_value((country, city))
|
|
59
|
+
|
|
60
|
+
with solara.Card("Location"):
|
|
61
|
+
solara.Select(label="country",
|
|
62
|
+
values=list(countries),
|
|
63
|
+
value=country,
|
|
64
|
+
on_value=lambda country: on_value((country, city)),
|
|
65
|
+
)
|
|
66
|
+
solara.Select(label="city",
|
|
67
|
+
values=cities,
|
|
68
|
+
value=city,
|
|
69
|
+
on_value=lambda city: on_value((country, city)),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Using .widget(...) we can create a widget from it.
|
|
74
|
+
# For use with interact:
|
|
75
|
+
@widgets.interact(location=LocationSelect.widget(value=("Netherlands", "Amsterdam")))
|
|
76
|
+
def f(size=3.4, location=None):
|
|
77
|
+
print(size, location)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# Or to add to your VBox:
|
|
81
|
+
widgets.VBox(
|
|
82
|
+
[LocationSelect.widget(value=("Netherlands", "Amsterdam"))]
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# this is how you'd use it as a component
|
|
86
|
+
@solara.component
|
|
87
|
+
def Page():
|
|
88
|
+
value, set_value = solara.use_state(("Netherlands", "Amsterdam"))
|
|
89
|
+
def pick():
|
|
90
|
+
country = random.choice(list(countries_demo_data))
|
|
91
|
+
city = random.choice(countries_demo_data[country])
|
|
92
|
+
set_value((country, city))
|
|
93
|
+
|
|
94
|
+
LocationSelect(value=value, on_value=set_value)
|
|
95
|
+
solara.Button("Pick random place", on_click=pick)
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
from solara.website.components import NoPage
|
|
102
|
+
|
|
103
|
+
Page = NoPage
|
|
104
|
+
title = "widget"
|