Miscellaneous¶
marimo.running_in_notebook
¶
Returns True if running in a marimo notebook, False otherwise
marimo.defs
¶
Get the definitions of the currently executing cell.
RETURNS | DESCRIPTION |
---|---|
tuple[str, ...]
|
tuple[str, ...]: A tuple of the currently executing cell's defs. |
marimo.refs
¶
Get the references of the currently executing cell.
RETURNS | DESCRIPTION |
---|---|
tuple[str, ...]
|
tuple[str, ...]: A tuple of the currently executing cell's refs. |
marimo.notebook_dir
¶
Get the directory of the currently executing notebook.
RETURNS | DESCRIPTION |
---|---|
Path | None
|
pathlib.Path | None: A pathlib.Path object representing the directory of the current notebook, or None if the notebook's directory cannot be determined. |
Examples:
marimo.notebook_location
¶
Get the location of the currently executing notebook.
In WASM, this is the URL of webpage, for example, https://my-site.com
.
For nested paths, this is the URL including the origin and pathname.
https://<my-org>.github.io/<my-repo>/folder
.
In non-WASM, this is the directory of the notebook, which is the same as
mo.notebook_dir()
.
Examples:
In order to access data both locally and when a notebook runs via WebAssembly (e.g. hosted on GitHub Pages), you can use this approach to fetch data from the notebook's location.
import polars as pl
data_path = mo.notebook_location() / "public" / "data.csv"
df = pl.read_csv(data_path)
df.head()
RETURNS | DESCRIPTION |
---|---|
Path | None
|
pathlib.Path | None: A pathlib.Path object representing the URL or directory of the current notebook, or None if the notebook's directory cannot be determined. |