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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moops
3
- Version: 0.3.2
3
+ Version: 0.4.0
4
4
  Summary: Write Marimo notebooks that also work as CLI scripts, with unified UI controls
5
5
  Keywords: marimo,notebooks,cli,testing
6
6
  Author: Yair Chuchem
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "moops"
7
- version = "0.3.2"
7
+ version = "0.4.0"
8
8
  description = "Write Marimo notebooks that also work as CLI scripts, with unified UI controls"
9
9
  license = "MIT"
10
10
  readme = "README.md"
@@ -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__ = ["Group", "Interface", "Presets", "__version__", "run", "run_button"]
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
- class App:
23
+ async def embed(app: _App, defs: dict[str, typing.Any] | None = None) -> typing.Any:
22
24
  """
23
- Wrap a marimo app with lean script-mode embeds.
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
- def __init__(self, app: _App) -> None:
34
- self._app = app
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": None,
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.embed.Passthrough received unexpected defs keys: {unexpected}"
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