solara-ui 1.56.0__py3-none-any.whl → 1.57.1__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  """Build webapps using IPywidgets"""
2
2
 
3
- __version__ = "1.56.0"
3
+ __version__ = "1.57.1"
4
4
  github_url = "https://github.com/widgetti/solara"
5
5
  git_branch = "master"
6
6
 
@@ -25,11 +25,15 @@ def FigureAltair(
25
25
 
26
26
  with alt.renderers.enable("mimetype"):
27
27
  bundle = chart._repr_mimebundle_()[0]
28
- key4 = "application/vnd.vegalite.v4+json"
29
- key5 = "application/vnd.vegalite.v5+json"
30
- if key4 not in bundle and key5 not in bundle:
31
- raise KeyError(f"{key4} and {key5} not in mimebundle:\n\n{bundle}")
32
- spec = bundle.get(key5, bundle.get(key4))
28
+ # Find the Vega-Lite spec from the bundle (supports v4, v5, v6+)
29
+ # MIME type format varies: v4/v5 use "+json" suffix, v6 uses ".json"
30
+ spec = None
31
+ for key in bundle:
32
+ if key.startswith("application/vnd.vegalite.v"):
33
+ spec = bundle[key]
34
+ break
35
+ if spec is None:
36
+ raise KeyError(f"No Vega-Lite MIME type found in mimebundle: {list(bundle.keys())}")
33
37
  return solara.widgets.VegaLite.element(
34
38
  spec=spec, on_click=on_click, listen_to_click=on_click is not None, on_hover=on_hover, listen_to_hover=on_hover is not None
35
39
  )
@@ -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
- # Note that we do not call .resolve() before using .parent, otherwise /some/path/.. will
141
- # set the current directory to /, moving up two levels.
142
- current_dir.value = selected_private.parent.resolve()
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.56.0-py2.py3-none-any.whl", keep_going=True)
122
+ await micropip.install("/wheels/solara-1.57.1-py2.py3-none-any.whl", keep_going=True)
123
123
  import solara
124
124
 
125
125
  el = solara.Warning("lala")
@@ -1,5 +1,88 @@
1
1
  # Solara Changelog
2
2
 
3
+ ## Version 1.57.0
4
+
5
+ * Feature: Add `watch` option to `FileBrowser` for automatic file change detection. [a0c75202](https://github.com/widgetti/solara/commit/a0c75202)
6
+ * Bug Fix: Prevent `FileBrowser` from using relative paths for directory sync. [7be73e88](https://github.com/widgetti/solara/commit/7be73e88)
7
+
8
+ ## Version 1.56.0
9
+
10
+ * Feature: On disconnect and reconnect, force a page reload. [8d6fb2f1](https://github.com/widgetti/solara/commit/8d6fb2f1)
11
+ * Feature: Allow `data` function in `FileDownload` to be a coroutine. [a395f090](https://github.com/widgetti/solara/commit/a395f090)
12
+ * Breaking change: Drop Python 3.7 support. [abd9400d](https://github.com/widgetti/solara/commit/abd9400d)
13
+
14
+ ## Version 1.55.1
15
+
16
+ * Bug Fix: False positive for returns in async defs for hook use validation. [67381dc6](https://github.com/widgetti/solara/commit/67381dc6)
17
+
18
+ ## Version 1.55.0
19
+
20
+ * Feature: Allows tasks to have their own kernel context. [3a97835a](https://github.com/widgetti/solara/commit/3a97835a)
21
+ * Bug Fix: Python 3.14 compatibility - fix RuntimeError in BaseSettings iteration. [4bf31d5a](https://github.com/widgetti/solara/commit/4bf31d5a)
22
+
23
+ ## Version 1.54.0
24
+
25
+ * Feature: Use different port in `pytest-ipywidgets` for different workers in `pytest-xdist`. [7e924e21](https://github.com/widgetti/solara/commit/7e924e21)
26
+
27
+ ## Version 1.53.0
28
+
29
+ * Feature: With `--log-level=info` we can see where a reactive variable was set. [771df82f](https://github.com/widgetti/solara/commit/771df82f)
30
+ * Bug Fix: Hash and search were flipped, causing strange URLs/locations. [375fd9ba](https://github.com/widgetti/solara/commit/375fd9ba)
31
+
32
+ ## Version 1.52.0
33
+
34
+ * Feature: In Vue template, support both `event_foo` and `foo` to avoid LLM confusion. [3ba93278](https://github.com/widgetti/solara/commit/3ba93278)
35
+ * Feature: Allow custom serializers in Vue components. [cd1beabb](https://github.com/widgetti/solara/commit/cd1beabb)
36
+ * Bug Fix: Exclude breaking ipykernel releases. [9858c013](https://github.com/widgetti/solara/commit/9858c013)
37
+ * Bug Fix: Support modern versions of uvicorn. [ce2abebd](https://github.com/widgetti/solara/commit/ce2abebd)
38
+
39
+ ## Version 1.51.1
40
+
41
+ * Bug Fix: Enhance thread init patching to handle latest anyio (4.10.0) which may not populate name field properly. [93f78c6f](https://github.com/widgetti/solara/commit/93f78c6f)
42
+
43
+ ## Version 1.51.0
44
+
45
+ * Feature: Configure the initial title before the app runs/loads. [4515a8c3](https://github.com/widgetti/solara/commit/4515a8c3)
46
+ * Bug Fix: Do not crash on `use_close_menu`. [d0032943](https://github.com/widgetti/solara/commit/d0032943)
47
+
48
+ ## Version 1.50.1
49
+
50
+ * Bug Fix: `FileBrowser` could go two directories up if ".." was selected. [68e99e58](https://github.com/widgetti/solara/commit/68e99e58)
51
+ * Bug Fix: Tornado async gives no issues with event loops. [6706f6ed](https://github.com/widgetti/solara/commit/6706f6ed)
52
+
53
+ ## Version 1.50.0
54
+
55
+ * Feature: Support `Optional[str]` / optional for `InputText`. [814a8a6c](https://github.com/widgetti/solara/commit/814a8a6c)
56
+ * Feature: Give more control over the underlying Vuetify text input. [c5b47a84](https://github.com/widgetti/solara/commit/c5b47a84)
57
+ * Bug Fix: Sanitize infinite values in `/resourcez` JSON response. [6aacbff4](https://github.com/widgetti/solara/commit/6aacbff4)
58
+
59
+ ## Version 1.49.0
60
+
61
+ * Feature: Control selected file or directory externally in `FileBrowser`. [73a26dde](https://github.com/widgetti/solara/commit/73a26dde)
62
+ * Feature: Support relative paths in `FileBrowser`. [4b172244](https://github.com/widgetti/solara/commit/4b172244)
63
+
64
+ ## Version 1.48.0
65
+
66
+ * Feature: Expose `col_num` and `row_height` options for `GridLayout`. [8f40eeb5](https://github.com/widgetti/solara/commit/8f40eeb5)
67
+ * Feature: Warn if task is being called from a component. [e454b953](https://github.com/widgetti/solara/commit/e454b953)
68
+ * Bug Fix: Decrease `chunk_size` for `FileDrop` to 1MB to avoid Modal max 2MB limit. [fa65d5a1](https://github.com/widgetti/solara/commit/fa65d5a1)
69
+ * Bug Fix: Resolve logger warnings. [#1059](https://github.com/widgetti/solara/pull/1059)
70
+ * Bug Fix: A `use_task` with `dependencies=None` (user called) can have arguments. [da2f8cfe](https://github.com/widgetti/solara/commit/da2f8cfe)
71
+
72
+ ## Version 1.47.0
73
+
74
+ * Feature: Add `on_layer_updated` to `GridLayout`. [1163b89d](https://github.com/widgetti/solara/commit/1163b89d)
75
+ * Bug Fix: Classes were not applied to `ColumnsResponsive` when `wrap` was `False`. [ce879dad](https://github.com/widgetti/solara/commit/ce879dad)
76
+ * Bug Fix: Tasks did not have a stable key, causing hot reloads to miss values. [e1567f9d](https://github.com/widgetti/solara/commit/e1567f9d)
77
+ * Bug Fix: Re-run app on hot reload before running `on_kernel_start` callbacks. [cf4f5c1a](https://github.com/widgetti/solara/commit/cf4f5c1a)
78
+ * Bug Fix: Display port in runtime error when server is running. [cafe757c](https://github.com/widgetti/solara/commit/cafe757c)
79
+
80
+ ## Version 1.46.0
81
+
82
+ * Feature: When tasks fail to set results, handle it gracefully. [e6c1ce07](https://github.com/widgetti/solara/commit/e6c1ce07)
83
+ * Bug Fix: Follow ASGI spec and also check if text or bytes are `None` (Modal fix). [396c58ac](https://github.com/widgetti/solara/commit/396c58ac)
84
+ * Bug Fix: Make task threads daemon, so the Solara server can stop when tasks are running. [da346063](https://github.com/widgetti/solara/commit/da346063)
85
+
3
86
  ## Version 1.45.0
4
87
 
5
88
  * Bug Fix: Correctly handle expected websocket errors instead of logging them. [#1013](https://github.com/widgetti/solara/pull/1013)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: solara-ui
3
- Version: 1.56.0
3
+ Version: 1.57.1
4
4
  Dynamic: Summary
5
5
  Project-URL: Home, https://www.github.com/widgetti/solara
6
6
  Project-URL: Documentation, https://solara.dev
@@ -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=f3ilWC241PY1u14Y5jCFaV5jqnzXV2PMtNaMXOfpqdQ,3647
3
+ solara/__init__.py,sha256=hcpVYx1F-kVnPKV6NF2ltdrihWKdPrToiyxirziZcxs,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
@@ -42,8 +42,8 @@ solara/components/details.py,sha256=KsGATbjlLNn9X490o8n55njy_VCE8RnL3Hx08Lsu4Kk,
42
42
  solara/components/download.vue,sha256=xdh4olwVvGkQwGNRMU5eVUW1FGvcXrYrCyjddJbvH7E,1069
43
43
  solara/components/echarts.py,sha256=aAedLqKuVJnBi3FwhSdQIgAn-w55sNb_hGSmqkosfuA,3069
44
44
  solara/components/echarts.vue,sha256=7TGmxaRUmH-LeH16jHiUzyuZgebGu_JDiWsa2DBSWW4,4056
45
- solara/components/figure_altair.py,sha256=t4EEwXrdoisrbV5j2MS-HBlPc5HSFCK5r4mRXvYRH9w,1150
46
- solara/components/file_browser.py,sha256=vd9BRENagoxxL-RtH5HheQm_0zFrnBiipjtNNvJkIdU,9762
45
+ solara/components/figure_altair.py,sha256=SB9KGXdtw7m25CS9KSTEImhA3PE1eYbgLa8CN3FnYPo,1303
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=AIGeLAFLJdvpdCLUeDk9nrzWtwhv0AfwTbySQT60Zd0,3195
149
+ solara/server/static/solara_bootstrap.py,sha256=VPhkjSlIi5YEnZaElnkYs3I5qSqZkwF1QKTgkGv5xxg,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
@@ -222,7 +222,7 @@ solara/website/pages/apps/multipage/page1.py,sha256=5hK0RZ8UBBOaZcPKaplbLeb0Vvae
222
222
  solara/website/pages/apps/multipage/page2.py,sha256=uRJ8YPFyKy7GR_Ii8DJSx3akb3H15rQAJZETMt9jVEk,1422
223
223
  solara/website/pages/careers/__init__.py,sha256=_aaO9YQOvy8JE9PYkWeSNzLU4pUU-PJMAaYy07YbKsU,1479
224
224
  solara/website/pages/changelog/__init__.py,sha256=0ouQpbt5EGEY6bHmSMt6S7Gk71gAmuaIuevT5wEE2zQ,277
225
- solara/website/pages/changelog/changelog.md,sha256=rmu461GhH_EsBn4GjypFAn6grGyzpC2Y3UO-84esGuA,28065
225
+ solara/website/pages/changelog/changelog.md,sha256=6JKnQbLLlhCRv9SBSOMHXRcr1aEXj05BBHjywD8swD8,33525
226
226
  solara/website/pages/contact/__init__.py,sha256=NkjxJo258RTHLFPQ18IVZ9euS_vJciHUrM4o1fz9QJE,1259
227
227
  solara/website/pages/documentation/__init__.py,sha256=lv9cleVukKDLKRtjTYIlfBDi8Aw3bEz2iV8-IxBz3LA,5563
228
228
  solara/website/pages/documentation/advanced/__init__.py,sha256=bLLvasuqVVWJxGN89m77ChZhDivEhVavw9-_CiG3IZA,414
@@ -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.56.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
460
- solara_ui-1.56.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
461
- solara_ui-1.56.0.dist-info/METADATA,sha256=Yg1AFtRjIvEuZ6VldkmH1J1_qA2lTQ2M7Q4DsN6MJKU,7304
462
- solara_ui-1.56.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
463
- solara_ui-1.56.0.dist-info/licenses/LICENSE,sha256=fFJUz-CWzZ9nEc4QZKu44jMEoDr5fEW-SiqljKpD82E,1086
464
- solara_ui-1.56.0.dist-info/RECORD,,
459
+ solara_ui-1.57.1.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
460
+ solara_ui-1.57.1.data/data/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
461
+ solara_ui-1.57.1.dist-info/METADATA,sha256=IxcBjcFuedzmpnnebtIZAw7oQP7xL5u4hQihQbgg48E,7304
462
+ solara_ui-1.57.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
463
+ solara_ui-1.57.1.dist-info/licenses/LICENSE,sha256=fFJUz-CWzZ9nEc4QZKu44jMEoDr5fEW-SiqljKpD82E,1086
464
+ solara_ui-1.57.1.dist-info/RECORD,,