-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotebook.py
More file actions
87 lines (63 loc) · 1.68 KB
/
notebook.py
File metadata and controls
87 lines (63 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "marimo",
# "tinydb==4.8.2",
# ]
# ///
import marimo
__generated_with = "0.14.17"
app = marimo.App(width="medium")
@app.cell
def _():
import marimo as mo
return (mo,)
@app.cell
def _(mo):
mo.md(
"""
# Hello Marimo Notebook Template World! 👋📓🌍
Welcome to the `marimo-notebook-template` repository. You can find more in the template repository [README](https://github.com/MITLibraries/marimo-notebook-template/blob/main/README.md).
"""
)
return
@app.cell
def _(mo):
import sys
mo.md(f"""Python version: `{sys.version}`""")
return
@app.cell
def _(mo):
mo.md(
"""This notebook exemplifies using [inline dependencies](https://docs.marimo.io/guides/package_management/inlining_dependencies/). The external package `tinydb` is installed as a dependency via inline dependencies at the top of this `notebook.py` file, then imported and used in the following cell..."""
)
return
@app.cell
def _(mo):
import tempfile
from tinydb import TinyDB
with tempfile.TemporaryDirectory() as tmpdir:
db = TinyDB(f"{tmpdir}/db.json")
db.insert({"name": "test"})
results = db.all()
mo.md(
f"""
TinyDB loaded: `OK`<br>
Results: `{results}`
"""
)
return
@app.cell
def _(mo):
mo.md(
"""
The following cell demonstrates a test embedded into the notebook itself. As noted in the template README, tests may also be added to the `/tests` folder.
"""
)
return
@app.cell
def test_fortytwo_addition():
assert 42 == 40 + 2
return
if __name__ == "__main__":
app.run()