streambricks 0.0.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.
- streambricks/__init__.py +8 -0
- streambricks/helpers.py +48 -0
- streambricks/py.typed +0 -0
- streambricks/widgets/__init__.py +6 -0
- streambricks/widgets/model_widget.py +1123 -0
- streambricks/widgets/multi_select.py +91 -0
- streambricks-0.0.1.dist-info/METADATA +82 -0
- streambricks-0.0.1.dist-info/RECORD +10 -0
- streambricks-0.0.1.dist-info/WHEEL +4 -0
- streambricks-0.0.1.dist-info/licenses/LICENSE +22 -0
streambricks/__init__.py
ADDED
streambricks/helpers.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Utility functions for Streamlit applications."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import inspect
|
|
7
|
+
import sys
|
|
8
|
+
from typing import TYPE_CHECKING, Any, TypeVar
|
|
9
|
+
|
|
10
|
+
from streamlit import runtime
|
|
11
|
+
from streamlit.web.cli import main
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from collections.abc import Callable, Coroutine
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
T = TypeVar("T")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def run(
|
|
22
|
+
fn: Callable[..., T | Coroutine[Any, Any, T]] | Coroutine[Any, Any, T],
|
|
23
|
+
*args: Any,
|
|
24
|
+
**kwargs: Any,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Run a function or coroutine with Streamlit.
|
|
27
|
+
|
|
28
|
+
If Streamlit runtime exists, execute the function directly. Otherwise,
|
|
29
|
+
start Streamlit with the current script.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
fn: The function or coroutine to run
|
|
33
|
+
args: Positional arguments to pass to the function
|
|
34
|
+
kwargs: Keyword arguments to pass to the function
|
|
35
|
+
"""
|
|
36
|
+
if runtime.exists():
|
|
37
|
+
if inspect.iscoroutine(fn):
|
|
38
|
+
asyncio.run(fn)
|
|
39
|
+
# Handle coroutine function
|
|
40
|
+
elif inspect.iscoroutinefunction(fn):
|
|
41
|
+
coro = fn(*args, **kwargs)
|
|
42
|
+
asyncio.run(coro)
|
|
43
|
+
# Handle regular function
|
|
44
|
+
else:
|
|
45
|
+
fn(*args, **kwargs) # type: ignore
|
|
46
|
+
else:
|
|
47
|
+
sys.argv = ["streamlit", "run", sys.argv[0]]
|
|
48
|
+
sys.exit(main())
|
streambricks/py.typed
ADDED
|
File without changes
|