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.
@@ -0,0 +1,8 @@
1
+ __version__ = "0.0.1"
2
+
3
+
4
+ from streambricks.widgets.model_widget import render_model_form
5
+ from streambricks.widgets.multi_select import multiselect
6
+ from streambricks.helpers import run
7
+
8
+ __all__ = ["multiselect", "render_model_form", "run"]
@@ -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
@@ -0,0 +1,6 @@
1
+ """Streamlit widgets."""
2
+
3
+ from streambricks.widgets.model_widget import render_model_form
4
+ from streambricks.widgets.multi_select import multiselect
5
+
6
+ __all__ = ["multiselect", "render_model_form"]