solara-ui 1.56.0__py3-none-any.whl → 1.57.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.
- solara/__init__.py +1 -1
- solara/components/file_browser.py +50 -3
- solara/server/static/solara_bootstrap.py +1 -1
- {solara_ui-1.56.0.dist-info → solara_ui-1.57.0.dist-info}/METADATA +1 -1
- {solara_ui-1.56.0.dist-info → solara_ui-1.57.0.dist-info}/RECORD +9 -9
- {solara_ui-1.56.0.data → solara_ui-1.57.0.data}/data/etc/jupyter/jupyter_notebook_config.d/solara.json +0 -0
- {solara_ui-1.56.0.data → solara_ui-1.57.0.data}/data/etc/jupyter/jupyter_server_config.d/solara.json +0 -0
- {solara_ui-1.56.0.dist-info → solara_ui-1.57.0.dist-info}/WHEEL +0 -0
- {solara_ui-1.56.0.dist-info → solara_ui-1.57.0.dist-info}/licenses/LICENSE +0 -0
solara/__init__.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import os
|
|
2
3
|
from os.path import isfile, join
|
|
3
4
|
from pathlib import Path
|
|
@@ -8,6 +9,11 @@ import humanize
|
|
|
8
9
|
import ipyvuetify as vy
|
|
9
10
|
import traitlets
|
|
10
11
|
|
|
12
|
+
try:
|
|
13
|
+
import watchfiles
|
|
14
|
+
except ModuleNotFoundError:
|
|
15
|
+
watchfiles = None # type: ignore
|
|
16
|
+
|
|
11
17
|
import solara
|
|
12
18
|
from solara.components import Div
|
|
13
19
|
|
|
@@ -84,6 +90,7 @@ def FileBrowser(
|
|
|
84
90
|
on_file_name: Optional[Callable[[str], None]] = None,
|
|
85
91
|
start_directory=None,
|
|
86
92
|
can_select=False,
|
|
93
|
+
watch: bool = False,
|
|
87
94
|
):
|
|
88
95
|
"""File/directory browser at the server side.
|
|
89
96
|
|
|
@@ -109,6 +116,8 @@ def FileBrowser(
|
|
|
109
116
|
* `directory_first`: If `True` directories are shown before files. Default: `False`.
|
|
110
117
|
* `on_file_name`: (deprecated) Use on_file_open instead.
|
|
111
118
|
* `start_directory`: (deprecated) Use directory instead.
|
|
119
|
+
* `watch`: If `True`, watch the current directory for file changes and automatically refresh the file list.
|
|
120
|
+
Requires the `watchfiles` package to be installed.
|
|
112
121
|
"""
|
|
113
122
|
if start_directory is not None:
|
|
114
123
|
directory = start_directory # pragma: no cover
|
|
@@ -122,6 +131,8 @@ def FileBrowser(
|
|
|
122
131
|
warning, set_warning = solara.use_state(cast(Optional[str], None))
|
|
123
132
|
scroll_pos_stack, set_scroll_pos_stack = solara.use_state(cast(List[int], []))
|
|
124
133
|
scroll_pos, set_scroll_pos = solara.use_state(0)
|
|
134
|
+
# Counter to trigger re-render when files change
|
|
135
|
+
file_change_counter, set_file_change_counter = solara.use_state(0)
|
|
125
136
|
selected_private, set_selected_private = use_reactive_or_value(
|
|
126
137
|
selected,
|
|
127
138
|
on_value=on_path_select if can_select else lambda x: None,
|
|
@@ -137,12 +148,48 @@ def FileBrowser(
|
|
|
137
148
|
# if we select a file, we need to make sure the directory is correct
|
|
138
149
|
# NOTE: although we expect a Path, abuse might make it a string
|
|
139
150
|
if isinstance(selected_private, Path):
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
|
|
151
|
+
# Only sync directory from selected if the path is absolute.
|
|
152
|
+
# Relative paths would resolve against the process CWD, not the
|
|
153
|
+
# current directory shown in the FileBrowser, leading to incorrect paths.
|
|
154
|
+
if selected_private.is_absolute():
|
|
155
|
+
# Note that we do not call .resolve() before using .parent, otherwise /some/path/.. will
|
|
156
|
+
# set the current directory to /, moving up two levels.
|
|
157
|
+
current_dir.value = selected_private.parent.resolve()
|
|
143
158
|
|
|
144
159
|
solara.use_effect(sync_directory_from_selected, [selected_private])
|
|
145
160
|
|
|
161
|
+
def watch_directory():
|
|
162
|
+
if not watch:
|
|
163
|
+
return
|
|
164
|
+
if not watchfiles:
|
|
165
|
+
logger.warning("watchfiles not installed, cannot watch directory")
|
|
166
|
+
return
|
|
167
|
+
|
|
168
|
+
# Check if there's a running event loop before creating the coroutine
|
|
169
|
+
try:
|
|
170
|
+
asyncio.get_running_loop()
|
|
171
|
+
except RuntimeError:
|
|
172
|
+
# No running event loop (e.g., in unit tests or non-server environments)
|
|
173
|
+
logger.warning("No running event loop, cannot watch directory for changes")
|
|
174
|
+
return
|
|
175
|
+
|
|
176
|
+
dir_to_watch = current_dir.value
|
|
177
|
+
|
|
178
|
+
async def watch_task():
|
|
179
|
+
try:
|
|
180
|
+
async for _ in watchfiles.awatch(dir_to_watch):
|
|
181
|
+
logger.debug("Directory %s changed, refreshing file list", dir_to_watch)
|
|
182
|
+
set_file_change_counter(lambda x: x + 1)
|
|
183
|
+
except RuntimeError:
|
|
184
|
+
pass # swallow the RuntimeError: Already borrowed errors from watchfiles
|
|
185
|
+
except Exception:
|
|
186
|
+
logger.exception("Error watching directory")
|
|
187
|
+
|
|
188
|
+
future = asyncio.create_task(watch_task())
|
|
189
|
+
return future.cancel
|
|
190
|
+
|
|
191
|
+
solara.use_effect(watch_directory, [watch, current_dir.value])
|
|
192
|
+
|
|
146
193
|
def change_dir(new_dir: Path):
|
|
147
194
|
if os.access(new_dir, os.R_OK):
|
|
148
195
|
current_dir.value = new_dir
|
|
@@ -119,7 +119,7 @@ async def main():
|
|
|
119
119
|
]
|
|
120
120
|
for dep in requirements:
|
|
121
121
|
await micropip.install(dep, keep_going=True)
|
|
122
|
-
await micropip.install("/wheels/solara-1.
|
|
122
|
+
await micropip.install("/wheels/solara-1.57.0-py2.py3-none-any.whl", keep_going=True)
|
|
123
123
|
import solara
|
|
124
124
|
|
|
125
125
|
el = solara.Warning("lala")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
prefix/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
|
|
2
2
|
prefix/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
|
|
3
|
-
solara/__init__.py,sha256=
|
|
3
|
+
solara/__init__.py,sha256=YfpMbibOxKDM1T7D6kwzffLEKo-WZeoGf_jo-bADrqw,3647
|
|
4
4
|
solara/__main__.py,sha256=J_f3D_mgiNicU_ay_I-qn08GOViSXm04Ym0mopqh2Os,24853
|
|
5
5
|
solara/_stores.py,sha256=N2Ec-61XNFXwigBx8f5QYPx7gDXenCOBdmLPXiJB45E,12320
|
|
6
6
|
solara/alias.py,sha256=9vfLzud77NP8in3OID9b5mmIO8NyrnFjN2_aE0lSb1k,216
|
|
@@ -43,7 +43,7 @@ solara/components/download.vue,sha256=xdh4olwVvGkQwGNRMU5eVUW1FGvcXrYrCyjddJbvH7
|
|
|
43
43
|
solara/components/echarts.py,sha256=aAedLqKuVJnBi3FwhSdQIgAn-w55sNb_hGSmqkosfuA,3069
|
|
44
44
|
solara/components/echarts.vue,sha256=7TGmxaRUmH-LeH16jHiUzyuZgebGu_JDiWsa2DBSWW4,4056
|
|
45
45
|
solara/components/figure_altair.py,sha256=t4EEwXrdoisrbV5j2MS-HBlPc5HSFCK5r4mRXvYRH9w,1150
|
|
46
|
-
solara/components/file_browser.py,sha256=
|
|
46
|
+
solara/components/file_browser.py,sha256=JKSjMOPulEY0zlgSP0jxyfV9Eg7rUX7bLMYN9v0TBfw,11721
|
|
47
47
|
solara/components/file_download.py,sha256=fnt6KqgGIVk1m_lwxURK82Cz3wMdxuVtTn3FOuv5p6M,7854
|
|
48
48
|
solara/components/file_drop.py,sha256=BA53EZsCzzPCS8i2ZH_S1NAkmmQlTOvNEoXAt0_1l4A,5239
|
|
49
49
|
solara/components/file_drop.vue,sha256=7V6YjHhoqOCVDMVPtObNwfHz2MdXLCFlNEqK1brl3zI,2243
|
|
@@ -146,7 +146,7 @@ solara/server/static/highlight-dark.css,sha256=xO8-vta9vG4s1OfJNHXWqiLWzx_gM03jo
|
|
|
146
146
|
solara/server/static/highlight.css,sha256=k8ZdT5iwrGQ5tXTQHAXuxvZrSUq3kwCdEpy3mlFoZjs,2637
|
|
147
147
|
solara/server/static/main-vuetify.js,sha256=R3qM4xMlstMpRUdRaul78p34z_Av2ONSTXksg2V9TqQ,9503
|
|
148
148
|
solara/server/static/main.js,sha256=mcx4JNQ4Lg4pNdUIqMoZos1mZyYFS48yd_JNFFJUqIE,5679
|
|
149
|
-
solara/server/static/solara_bootstrap.py,sha256=
|
|
149
|
+
solara/server/static/solara_bootstrap.py,sha256=oCCjKpqoeGJ7_P-pxwMZs09xnX1mKSRocfx0nUpYkMw,3195
|
|
150
150
|
solara/server/static/sun.svg,sha256=jEKBAGCr7b9zNYv0VUb7lMWKjnU2dX69_Ye_DZWGXJI,6855
|
|
151
151
|
solara/server/static/webworker.js,sha256=cjAFz7-SygStHJnYlJUlJs-gE_7YQeQ-WBDcmKYyjvo,1372
|
|
152
152
|
solara/server/templates/index.html.j2,sha256=JXQo1M-STFHLBOFetgG7509cAq8xUP0VAEtYDzz35fY,31
|
|
@@ -456,9 +456,9 @@ solara/widgets/vue/gridlayout.vue,sha256=LZk-YlqM7nv_7Y5TTq2xqfH1j2SLP1QOH5eiz7G
|
|
|
456
456
|
solara/widgets/vue/html.vue,sha256=48K5rjp0AdJDeRV6F3nOHW3J0WXPeHn55r5pGClK2fU,112
|
|
457
457
|
solara/widgets/vue/navigator.vue,sha256=3hhh2_sXpnsdM1vrs2nQ0bZHLCB10HhtQeYLS-tO85s,4790
|
|
458
458
|
solara/widgets/vue/vegalite.vue,sha256=zhocRsUCNIRQCEbD16er5sYnuHU0YThatRHnorA3P18,4596
|
|
459
|
-
solara_ui-1.
|
|
460
|
-
solara_ui-1.
|
|
461
|
-
solara_ui-1.
|
|
462
|
-
solara_ui-1.
|
|
463
|
-
solara_ui-1.
|
|
464
|
-
solara_ui-1.
|
|
459
|
+
solara_ui-1.57.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
|
|
460
|
+
solara_ui-1.57.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
|
|
461
|
+
solara_ui-1.57.0.dist-info/METADATA,sha256=xVxjY3GG79bODxOZRc8unZUpjcO5zmBpvT5zykRME_k,7304
|
|
462
|
+
solara_ui-1.57.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
463
|
+
solara_ui-1.57.0.dist-info/licenses/LICENSE,sha256=fFJUz-CWzZ9nEc4QZKu44jMEoDr5fEW-SiqljKpD82E,1086
|
|
464
|
+
solara_ui-1.57.0.dist-info/RECORD,,
|
|
File without changes
|
{solara_ui-1.56.0.data → solara_ui-1.57.0.data}/data/etc/jupyter/jupyter_server_config.d/solara.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|