solara-ui 1.47.0__py3-none-any.whl → 1.48.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_drop.vue +1 -1
- solara/server/app.py +1 -1
- solara/server/static/solara_bootstrap.py +1 -1
- solara/tasks.py +80 -12
- solara/toestand.py +1 -0
- solara/widgets/vue/gridlayout.vue +2 -2
- solara/widgets/widgets.py +2 -0
- {solara_ui-1.47.0.dist-info → solara_ui-1.48.0.dist-info}/METADATA +1 -1
- {solara_ui-1.47.0.dist-info → solara_ui-1.48.0.dist-info}/RECORD +14 -14
- {solara_ui-1.47.0.data → solara_ui-1.48.0.data}/data/etc/jupyter/jupyter_notebook_config.d/solara.json +0 -0
- {solara_ui-1.47.0.data → solara_ui-1.48.0.data}/data/etc/jupyter/jupyter_server_config.d/solara.json +0 -0
- {solara_ui-1.47.0.dist-info → solara_ui-1.48.0.dist-info}/WHEEL +0 -0
- {solara_ui-1.47.0.dist-info → solara_ui-1.48.0.dist-info}/licenses/LICENSE +0 -0
solara/__init__.py
CHANGED
solara/components/file_drop.vue
CHANGED
solara/server/app.py
CHANGED
|
@@ -136,7 +136,7 @@ class AppScript:
|
|
|
136
136
|
routes = solara.generate_routes_directory(self.path)
|
|
137
137
|
|
|
138
138
|
if any(name for name in sys.modules.keys() if name.startswith(self.name)):
|
|
139
|
-
logger.
|
|
139
|
+
logger.warning(
|
|
140
140
|
f"Directory {self.name} is also used as a package. This can cause modules to be loaded twice, and might "
|
|
141
141
|
"cause unexpected behavior. If you run solara from a different directory (e.g. the parent directory) you "
|
|
142
142
|
"can avoid this ambiguity."
|
|
@@ -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.48.0-py2.py3-none-any.whl", keep_going=True)
|
|
123
123
|
import solara
|
|
124
124
|
|
|
125
125
|
el = solara.Warning("lala")
|
solara/tasks.py
CHANGED
|
@@ -6,6 +6,7 @@ import functools
|
|
|
6
6
|
import inspect
|
|
7
7
|
import logging
|
|
8
8
|
import threading
|
|
9
|
+
import warnings
|
|
9
10
|
from enum import Enum
|
|
10
11
|
import typing
|
|
11
12
|
from typing import (
|
|
@@ -536,6 +537,7 @@ def task(
|
|
|
536
537
|
f: None = None,
|
|
537
538
|
*,
|
|
538
539
|
prefer_threaded: bool = ...,
|
|
540
|
+
check_for_render_context: bool = ...,
|
|
539
541
|
) -> Callable[[Callable[P, R]], Task[P, R]]: ...
|
|
540
542
|
|
|
541
543
|
|
|
@@ -544,6 +546,7 @@ def task(
|
|
|
544
546
|
f: Callable[P, Union[Coroutine[Any, Any, R], R]],
|
|
545
547
|
*,
|
|
546
548
|
prefer_threaded: bool = ...,
|
|
549
|
+
check_for_render_context: bool = ...,
|
|
547
550
|
) -> Task[P, R]: ...
|
|
548
551
|
|
|
549
552
|
|
|
@@ -551,6 +554,7 @@ def task(
|
|
|
551
554
|
f: Union[None, Callable[P, Union[Coroutine[Any, Any, R], R]]] = None,
|
|
552
555
|
*,
|
|
553
556
|
prefer_threaded: bool = True,
|
|
557
|
+
check_for_render_context: bool = True,
|
|
554
558
|
) -> Union[Callable[[Callable[P, R]], Task[P, R]], Task[P, R]]:
|
|
555
559
|
"""Decorator to turn a function or coroutine function into a task.
|
|
556
560
|
|
|
@@ -764,12 +768,76 @@ def task(
|
|
|
764
768
|
This ensures that even when a coroutine functions calls a blocking function the UI is still responsive.
|
|
765
769
|
On platform where threads are not supported (like Pyodide / WASM / Emscripten / PyScript), a coroutine
|
|
766
770
|
function will always run in the current event loop.
|
|
771
|
+
- `check_for_render_context` - bool: If true, we will check if we are in a render context, and if so, we will
|
|
772
|
+
warn you that you should probably be using `use_task` instead of `task`.
|
|
767
773
|
|
|
768
774
|
```
|
|
769
775
|
|
|
770
776
|
"""
|
|
771
777
|
|
|
778
|
+
def check_if_we_should_use_use_task():
|
|
779
|
+
import reacton.core
|
|
780
|
+
|
|
781
|
+
in_reacton_context = reacton.core.get_render_context(required=False) is not None
|
|
782
|
+
if not in_reacton_context:
|
|
783
|
+
# We are not in a reacton context, so we should not (and cannot) use use_task
|
|
784
|
+
return
|
|
785
|
+
from .toestand import _find_outside_solara_frame
|
|
786
|
+
|
|
787
|
+
frame = _find_outside_solara_frame()
|
|
788
|
+
if frame is None:
|
|
789
|
+
# We cannot determine which frame we are in, just skip this check
|
|
790
|
+
return
|
|
791
|
+
import inspect
|
|
792
|
+
|
|
793
|
+
tb = inspect.getframeinfo(frame)
|
|
794
|
+
msg = """You are calling task(...) from a component, while you should probably be using use_task.
|
|
795
|
+
|
|
796
|
+
Reason:
|
|
797
|
+
- task(...) creates a new task object on every render, and should only be used outside of a component.
|
|
798
|
+
- use_task(...) returns the same task object on every render, and should be used inside a component.
|
|
799
|
+
|
|
800
|
+
Example:
|
|
801
|
+
@solara.component
|
|
802
|
+
def Page():
|
|
803
|
+
@task # This is wrong, this creates a new task object on every render
|
|
804
|
+
def my_task():
|
|
805
|
+
...
|
|
806
|
+
|
|
807
|
+
Instead, you should do:
|
|
808
|
+
@solara.component
|
|
809
|
+
def Page():
|
|
810
|
+
@use_task
|
|
811
|
+
def my_task():
|
|
812
|
+
...
|
|
813
|
+
|
|
814
|
+
"""
|
|
815
|
+
if tb:
|
|
816
|
+
if tb.code_context:
|
|
817
|
+
code = tb.code_context[0]
|
|
818
|
+
else:
|
|
819
|
+
code = "<No code context available>"
|
|
820
|
+
msg += f"This warning was triggered from:\n{tb.filename}:{tb.lineno}\n{code.strip()}"
|
|
821
|
+
|
|
822
|
+
# Check if the call is within a use_memo context by inspecting the call stack
|
|
823
|
+
if frame:
|
|
824
|
+
caller_frame = frame.f_back
|
|
825
|
+
# Check a few frames up the stack (e.g., up to 5) for 'use_memo'
|
|
826
|
+
for _ in range(5):
|
|
827
|
+
if caller_frame is None:
|
|
828
|
+
break
|
|
829
|
+
func_name = caller_frame.f_code.co_name
|
|
830
|
+
module_name = caller_frame.f_globals.get("__name__", "")
|
|
831
|
+
if func_name == "use_memo" and (module_name.startswith("solara.") or module_name.startswith("reacton.")):
|
|
832
|
+
# We are in a use_memo (or a context that should not trigger the warning)
|
|
833
|
+
return
|
|
834
|
+
caller_frame = caller_frame.f_back
|
|
835
|
+
|
|
836
|
+
warnings.warn(msg)
|
|
837
|
+
|
|
772
838
|
def wrapper(f: Union[None, Callable[P, Union[Coroutine[Any, Any, R], R]]]) -> Task[P, R]:
|
|
839
|
+
if check_for_render_context:
|
|
840
|
+
check_if_we_should_use_use_task()
|
|
773
841
|
# we use wraps to make the key of the reactive variable more unique
|
|
774
842
|
# and less likely to mixup during hot reloads
|
|
775
843
|
assert f is not None
|
|
@@ -800,46 +868,46 @@ def use_task(
|
|
|
800
868
|
dependencies: Literal[None] = ...,
|
|
801
869
|
raise_error=...,
|
|
802
870
|
prefer_threaded=...,
|
|
803
|
-
) -> Callable[[Callable[
|
|
871
|
+
) -> Callable[[Callable[P, R]], "Task[P, R]"]: ...
|
|
804
872
|
|
|
805
873
|
|
|
806
874
|
@overload
|
|
807
875
|
def use_task(
|
|
808
|
-
f:
|
|
876
|
+
f: None = None,
|
|
809
877
|
*,
|
|
810
|
-
dependencies:
|
|
878
|
+
dependencies: List = ...,
|
|
811
879
|
raise_error=...,
|
|
812
880
|
prefer_threaded=...,
|
|
813
|
-
) -> "Task[[], R]": ...
|
|
881
|
+
) -> Callable[[Callable[[], R]], "Task[[], R]"]: ...
|
|
814
882
|
|
|
815
883
|
|
|
816
884
|
@overload
|
|
817
885
|
def use_task(
|
|
818
|
-
f:
|
|
886
|
+
f: Callable[[], R],
|
|
819
887
|
*,
|
|
820
888
|
dependencies: List = ...,
|
|
821
889
|
raise_error=...,
|
|
822
890
|
prefer_threaded=...,
|
|
823
|
-
) ->
|
|
891
|
+
) -> "Task[[], R]": ...
|
|
824
892
|
|
|
825
893
|
|
|
826
894
|
@overload
|
|
827
895
|
def use_task(
|
|
828
|
-
f: Callable[
|
|
896
|
+
f: Callable[P, R],
|
|
829
897
|
*,
|
|
830
|
-
dependencies:
|
|
898
|
+
dependencies: Literal[None] = ...,
|
|
831
899
|
raise_error=...,
|
|
832
900
|
prefer_threaded=...,
|
|
833
|
-
) -> "Task[
|
|
901
|
+
) -> "Task[P, R]": ...
|
|
834
902
|
|
|
835
903
|
|
|
836
904
|
def use_task(
|
|
837
|
-
f: Union[None, Callable[
|
|
905
|
+
f: Union[None, Callable[P, R]] = None,
|
|
838
906
|
*,
|
|
839
907
|
dependencies: Union[None, List] = [],
|
|
840
908
|
raise_error=True,
|
|
841
909
|
prefer_threaded=True,
|
|
842
|
-
) -> Union[Callable[[Callable[
|
|
910
|
+
) -> Union[Callable[[Callable[P, R]], "Task[P, R]"], "Task[P, R]"]:
|
|
843
911
|
"""A hook that runs a function or coroutine function as a task and returns the result.
|
|
844
912
|
|
|
845
913
|
Allows you to run code in the background, with the UI available to the user. This is useful for long running tasks,
|
|
@@ -919,7 +987,7 @@ def use_task(
|
|
|
919
987
|
|
|
920
988
|
def wrapper(f):
|
|
921
989
|
def create_task() -> "Task[[], R]":
|
|
922
|
-
return task(f, prefer_threaded=prefer_threaded)
|
|
990
|
+
return task(f, prefer_threaded=prefer_threaded, check_for_render_context=False)
|
|
923
991
|
|
|
924
992
|
task_instance = solara.use_memo(create_task, dependencies=[])
|
|
925
993
|
# we always update the function so we do not have stale data in the function
|
solara/toestand.py
CHANGED
|
@@ -343,6 +343,7 @@ def _is_internal_module(file_name: str):
|
|
|
343
343
|
return (
|
|
344
344
|
file_name_parts[-2:] == ["solara", "toestand.py"]
|
|
345
345
|
or file_name_parts[-2:] == ["solara", "reactive.py"]
|
|
346
|
+
or file_name_parts[-2:] == ["solara", "tasks.py"]
|
|
346
347
|
or file_name_parts[-2:] == ["solara", "_stores.py"]
|
|
347
348
|
or file_name_parts[-3:] == ["solara", "hooks", "use_reactive.py"]
|
|
348
349
|
or file_name_parts[-2:] == ["reacton", "core.py"]
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<div v-if="gridlayout_loaded" style="padding: 0px; width: 100%;">
|
|
4
4
|
<grid-layout
|
|
5
5
|
:layout.sync="grid_layout"
|
|
6
|
-
:col-num="
|
|
7
|
-
:row-height="
|
|
6
|
+
:col-num="col_num"
|
|
7
|
+
:row-height="row_height"
|
|
8
8
|
:is-draggable="draggable"
|
|
9
9
|
:is-resizable="resizable"
|
|
10
10
|
:is-mirrored="false"
|
solara/widgets/widgets.py
CHANGED
|
@@ -53,6 +53,8 @@ class GridLayout(v.VuetifyTemplate):
|
|
|
53
53
|
resizable = traitlets.CBool(True).tag(sync=True)
|
|
54
54
|
cdn = traitlets.Unicode(None, allow_none=True).tag(sync=True)
|
|
55
55
|
on_layout_updated = traitlets.traitlets.Callable(None, allow_none=True)
|
|
56
|
+
col_num = traitlets.Int(12).tag(sync=True)
|
|
57
|
+
row_height = traitlets.Int(30).tag(sync=True)
|
|
56
58
|
|
|
57
59
|
def vue_layout_updated(self, *args):
|
|
58
60
|
if self.on_layout_updated is not None:
|
|
@@ -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=8GsgAErkS5dA1fa2M7LKzN6p6qy9IyZYYBcU0mS8yuo,3647
|
|
4
4
|
solara/__main__.py,sha256=pm79jfba-0ZapLR0PtwZfMeiTHrLz8kEt79EygRyXxQ,24828
|
|
5
5
|
solara/_stores.py,sha256=N2Ec-61XNFXwigBx8f5QYPx7gDXenCOBdmLPXiJB45E,12320
|
|
6
6
|
solara/alias.py,sha256=9vfLzud77NP8in3OID9b5mmIO8NyrnFjN2_aE0lSb1k,216
|
|
@@ -20,8 +20,8 @@ solara/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
20
20
|
solara/reactive.py,sha256=KN0PJl-ivxjgQj008zyPGnORo5bTNaY77uASsSW0mFQ,3430
|
|
21
21
|
solara/routing.py,sha256=G_iZKozdVoUuD-qSMyuPV6jeN4qBqujAUvekw036f88,9143
|
|
22
22
|
solara/settings.py,sha256=FED5SYfw1W88U8SPk9iXSgSSvMHgPkU1auONSdk5cNs,2688
|
|
23
|
-
solara/tasks.py,sha256=
|
|
24
|
-
solara/toestand.py,sha256
|
|
23
|
+
solara/tasks.py,sha256=uaauVf5zuVROWlU5KD_uoBEjy81YcpUtJhxcxX_Rs88,37197
|
|
24
|
+
solara/toestand.py,sha256=-ddVhZGmFR4qia_skg4f15xAdNaiB_9drpS-qxrQDaQ,33497
|
|
25
25
|
solara/util.py,sha256=UUO3BfhXb3tGP-uj8UuTYMx6kuph6PiDp4XXm-f6uyg,9697
|
|
26
26
|
solara/validate_hooks.py,sha256=F0CYDOVF_23O1apJBIk9lZMq11JmkoE3BrVVT8QvZWI,9999
|
|
27
27
|
solara/components/__init__.py,sha256=j5Tv0tyzs80Bsl5hvTIF_x-RQyAvr3ooqIXnABamW44,3214
|
|
@@ -46,7 +46,7 @@ solara/components/figure_altair.py,sha256=t4EEwXrdoisrbV5j2MS-HBlPc5HSFCK5r4mRXv
|
|
|
46
46
|
solara/components/file_browser.py,sha256=701vg4_c0au9va206sx3pQDX6NL1VFqs7ewQ0RAbn6k,7331
|
|
47
47
|
solara/components/file_download.py,sha256=Lil0qyiozU_Pxyb_HgnJXOumrxMeDwwavEmZZw6kAs8,7475
|
|
48
48
|
solara/components/file_drop.py,sha256=BA53EZsCzzPCS8i2ZH_S1NAkmmQlTOvNEoXAt0_1l4A,5239
|
|
49
|
-
solara/components/file_drop.vue,sha256=
|
|
49
|
+
solara/components/file_drop.vue,sha256=7V6YjHhoqOCVDMVPtObNwfHz2MdXLCFlNEqK1brl3zI,2243
|
|
50
50
|
solara/components/file_list_widget.vue,sha256=atp-FO9tBjvyCQ_32NqeB9Rcehg03vPLD1eIROgBDDU,1860
|
|
51
51
|
solara/components/head.py,sha256=QZRTbwaUH0trfce3ntEcOqmLjw74CbSHpuMt9gGj7oA,648
|
|
52
52
|
solara/components/head_tag.py,sha256=xPj_ug0TUAZF4yN6ypKlmLcsHORIHU8zfIZgEDNi4PQ,1591
|
|
@@ -106,7 +106,7 @@ solara/lab/utils/headers.py,sha256=RMo8JUdztRePrdNfYCX1QEhrfyF6ktodr4v6tIREKbs,2
|
|
|
106
106
|
solara/scope/__init__.py,sha256=0sP3B6L4Aai0b6nadPtEETb8XqdGmSFKvQusNH0-yvY,2987
|
|
107
107
|
solara/scope/types.py,sha256=HTf_wnkpkhhtGaeFsB690KBP623CUuqiMssd72-u9yg,1540
|
|
108
108
|
solara/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
109
|
-
solara/server/app.py,sha256=
|
|
109
|
+
solara/server/app.py,sha256=vYUyqucwz2KZwH5RCCJtQDGPJdSLYqB5dAULudSqm74,22137
|
|
110
110
|
solara/server/cdn_helper.py,sha256=mjdDWL1jVed40rEagP9L5CfZwFB77yUKqcFg--u2eds,3250
|
|
111
111
|
solara/server/esm.py,sha256=dX9pzTJQ6kd6qNHQgzC938O5LTowLhuATXO0Q1paz44,2951
|
|
112
112
|
solara/server/fastapi.py,sha256=qVIHn0_Kxr6zWqcBWySu5nnJ6pNTSDqb4EHIh-cqH_8,93
|
|
@@ -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=Vsr4ZZQFyG6LDNyYOGEK84uIlP3-_eYF6IDcFv36-gE,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
|
|
@@ -451,14 +451,14 @@ solara/website/public/social/github.svg,sha256=XGlfnNccpMHYjfji25r5UW9FvS9pYPR1H
|
|
|
451
451
|
solara/website/public/social/twitter.svg,sha256=3Ub5a29H_NM2g7ed3689rKHU-K66PA8r3hWExpzGmdQ,430
|
|
452
452
|
solara/website/templates/index.html.j2,sha256=NYBuEHmKeSju-b3apY0h3FEJ-tnGDhrnkY-0cZ92Rro,4358
|
|
453
453
|
solara/widgets/__init__.py,sha256=D3RfEez9dllmst64_nyzzII-NZXoNMEPDnEog4ov3VE,43
|
|
454
|
-
solara/widgets/widgets.py,sha256=
|
|
455
|
-
solara/widgets/vue/gridlayout.vue,sha256=
|
|
454
|
+
solara/widgets/widgets.py,sha256=pog0XbqRxyWxLdjsthvM3G_6mIPTUaT6ZErb1POQXJg,2756
|
|
455
|
+
solara/widgets/vue/gridlayout.vue,sha256=LZk-YlqM7nv_7Y5TTq2xqfH1j2SLP1QOH5eiz7G0ayo,3584
|
|
456
456
|
solara/widgets/vue/html.vue,sha256=48K5rjp0AdJDeRV6F3nOHW3J0WXPeHn55r5pGClK2fU,112
|
|
457
457
|
solara/widgets/vue/navigator.vue,sha256=7fkX-4_YSnnMIPUMKMvQVVEzrmhY9BFAYvHMqZqTXpI,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.48.0.data/data/etc/jupyter/jupyter_notebook_config.d/solara.json,sha256=3UhTBQi6z7F7pPjmqXxfddv79c8VGR9H7zStDLp6AwY,115
|
|
460
|
+
solara_ui-1.48.0.data/data/etc/jupyter/jupyter_server_config.d/solara.json,sha256=D9J-rYxAzyD5GOqWvuPjacGUVFHsYtTfZ4FUbRzRvIA,113
|
|
461
|
+
solara_ui-1.48.0.dist-info/METADATA,sha256=89gyWKym-70PtLtlRfc7Wre6bWfW5He78idYwUoM1hM,7459
|
|
462
|
+
solara_ui-1.48.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
463
|
+
solara_ui-1.48.0.dist-info/licenses/LICENSE,sha256=fFJUz-CWzZ9nEc4QZKu44jMEoDr5fEW-SiqljKpD82E,1086
|
|
464
|
+
solara_ui-1.48.0.dist-info/RECORD,,
|
|
File without changes
|
{solara_ui-1.47.0.data → solara_ui-1.48.0.data}/data/etc/jupyter/jupyter_server_config.d/solara.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|