moops 0.3.2__tar.gz → 0.4.0__tar.gz
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.
- {moops-0.3.2 → moops-0.4.0}/PKG-INFO +1 -1
- {moops-0.3.2 → moops-0.4.0}/pyproject.toml +1 -1
- {moops-0.3.2 → moops-0.4.0}/src/moops/__init__.py +11 -1
- moops-0.3.2/src/moops/embed.py → moops-0.4.0/src/moops/_embed.py +11 -15
- {moops-0.3.2 → moops-0.4.0}/src/moops/group.py +1 -5
- {moops-0.3.2 → moops-0.4.0}/README.md +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_input_map.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_markdown.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_naming.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_options.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_parse.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_query_params.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_run.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/_run_button.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/interface.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/presets.py +0 -0
- {moops-0.3.2 → moops-0.4.0}/src/moops/testing.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from importlib.metadata import version
|
|
2
2
|
|
|
3
|
+
from ._embed import Passthrough, embed
|
|
3
4
|
from ._run import run
|
|
4
5
|
from ._run_button import run_button
|
|
5
6
|
from .group import Group
|
|
@@ -8,4 +9,13 @@ from .presets import Presets
|
|
|
8
9
|
|
|
9
10
|
__version__ = version("moops")
|
|
10
11
|
|
|
11
|
-
__all__ = [
|
|
12
|
+
__all__ = [
|
|
13
|
+
"Group",
|
|
14
|
+
"Interface",
|
|
15
|
+
"Passthrough",
|
|
16
|
+
"Presets",
|
|
17
|
+
"__version__",
|
|
18
|
+
"embed",
|
|
19
|
+
"run",
|
|
20
|
+
"run_button",
|
|
21
|
+
]
|
|
@@ -3,6 +3,8 @@ import typing
|
|
|
3
3
|
|
|
4
4
|
import marimo as mo
|
|
5
5
|
|
|
6
|
+
from . import interface
|
|
7
|
+
|
|
6
8
|
|
|
7
9
|
class _Embed(typing.Protocol):
|
|
8
10
|
defs: typing.Mapping[str, typing.Any]
|
|
@@ -18,9 +20,9 @@ class _App(typing.Protocol):
|
|
|
18
20
|
) -> tuple[typing.Iterable[typing.Any], typing.Mapping[str, object]]: ...
|
|
19
21
|
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
async def embed(app: _App, defs: dict[str, typing.Any] | None = None) -> typing.Any:
|
|
22
24
|
"""
|
|
23
|
-
|
|
25
|
+
Embed a marimo app, with lean script-mode embeds.
|
|
24
26
|
|
|
25
27
|
In script mode, only the embedded notebook's ``result`` definition is
|
|
26
28
|
retained, so intermediate definitions and rendered outputs can be released
|
|
@@ -29,17 +31,9 @@ class App:
|
|
|
29
31
|
This also works around marimo nested embed failures in script mode,
|
|
30
32
|
see https://github.com/marimo-team/marimo/issues/9572
|
|
31
33
|
"""
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def clone(self) -> "App":
|
|
37
|
-
return App(self._app.clone())
|
|
38
|
-
|
|
39
|
-
async def embed(self, defs: dict[str, typing.Any] | None = None) -> typing.Any:
|
|
40
|
-
if mo.running_in_notebook():
|
|
41
|
-
return await self._app.embed(defs=defs)
|
|
42
|
-
return await asyncio.to_thread(_embed_in_script, self._app, defs or {})
|
|
34
|
+
if mo.running_in_notebook():
|
|
35
|
+
return await app.embed(defs=defs)
|
|
36
|
+
return await asyncio.to_thread(_embed_in_script, app, defs or {})
|
|
43
37
|
|
|
44
38
|
|
|
45
39
|
class Passthrough:
|
|
@@ -50,7 +44,9 @@ class Passthrough:
|
|
|
50
44
|
def __init__(self, source: _Embed | dict[str, typing.Any]) -> None:
|
|
51
45
|
self.defs = {
|
|
52
46
|
"result": (source if isinstance(source, dict) else source.defs)["result"],
|
|
53
|
-
"interface":
|
|
47
|
+
"interface": interface.Interface(
|
|
48
|
+
controls=typing.cast(tuple[typing.Any], ())
|
|
49
|
+
),
|
|
54
50
|
}
|
|
55
51
|
self.output = None
|
|
56
52
|
|
|
@@ -58,7 +54,7 @@ class Passthrough:
|
|
|
58
54
|
unexpected = defs.keys() - {"args"}
|
|
59
55
|
if unexpected:
|
|
60
56
|
raise ValueError(
|
|
61
|
-
f"moops.
|
|
57
|
+
f"moops.Passthrough received unexpected defs keys: {unexpected}"
|
|
62
58
|
)
|
|
63
59
|
return self
|
|
64
60
|
|
|
@@ -79,11 +79,7 @@ class Group:
|
|
|
79
79
|
raise ValueError("markdown_heading_offset must be non-negative")
|
|
80
80
|
_frame = inspect.currentframe()
|
|
81
81
|
_caller = _frame.f_back if _frame else None
|
|
82
|
-
if (
|
|
83
|
-
_caller is not None
|
|
84
|
-
and mo.running_in_notebook()
|
|
85
|
-
and bool(_caller.f_code.co_flags & inspect.CO_COROUTINE)
|
|
86
|
-
):
|
|
82
|
+
if _caller is not None and bool(_caller.f_code.co_flags & inspect.CO_COROUTINE):
|
|
87
83
|
warnings.warn(
|
|
88
84
|
f"args.subgroup('{prefix}') called inside an async cell, "
|
|
89
85
|
"likely the cell making the embed it is used for. "
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|