MCPcopy
hub / github.com/marimo-team/marimo / _export_session_for_notebook

Function _export_session_for_notebook

marimo/_cli/export/session.py:166–200  ·  view source on GitHub ↗
(
    notebook: MarimoPath,
    *,
    force_overwrite: bool,
    notebook_args: tuple[str, ...],
    sandbox_pool: SandboxVenvPool | None,
)

Source from the content-addressed store, hash-verified

164
165
166async def _export_session_for_notebook(
167 notebook: MarimoPath,
168 *,
169 force_overwrite: bool,
170 notebook_args: tuple[str, ...],
171 sandbox_pool: SandboxVenvPool | None,
172) -> None:
173 output = get_session_cache_file(notebook.path)
174 if _maybe_skip_fresh_snapshot(notebook, force_overwrite=force_overwrite):
175 return
176
177 echo(f"Running {notebook.short_name}...")
178 venv_python = (
179 sandbox_pool.get_python(str(notebook.path))
180 if sandbox_pool is not None
181 else None
182 )
183
184 session_snapshot, did_error = await _export_session_snapshot(
185 notebook,
186 notebook_args=notebook_args,
187 venv_python=venv_python,
188 )
189
190 output = write_session_snapshot(
191 notebook_path=notebook.path,
192 snapshot=session_snapshot,
193 )
194
195 if did_error:
196 raise click.ClickException(
197 "Session export succeeded, but some cells failed to execute."
198 )
199
200 echo(green("ok") + f": {output}")
201
202
203def _maybe_skip_fresh_snapshot(

Callers 1

_export_sessionsFunction · 0.85

Calls 7

get_session_cache_fileFunction · 0.90
echoFunction · 0.90
write_session_snapshotFunction · 0.90
greenFunction · 0.90
_export_session_snapshotFunction · 0.85
get_pythonMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…