Skip to content

Commit 7c23988

Browse files
committed
Basic layout
* Update notebook.py with temp CDPS dashboard layout * Update README.md to remove generic info * Update dependencies * Update pyproject.toml to ignore ruff error
1 parent 624e2e4 commit 7c23988

File tree

4 files changed

+284
-280
lines changed

4 files changed

+284
-280
lines changed

README.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,27 @@
1-
# marimo-notebook-template
2-
3-
**_NOTE: Rework this section to describe your Marimo notebook(s)._**
4-
5-
This repository is a template for a single, or multiple, Marimo notebooks that will be served and accessed via [marimo-launcher](https://github.com/MITLibraries/marimo-launcher).
6-
7-
By default, [marimo-launcher](https://github.com/MITLibraries/marimo-launcher) expects a single file called `notebook.py` at the root of the repository it clones and launches. However, `marimo-launcher` also supports a `--path` CLI arg or `NOTEBOOK_PATH` env var that allows overriding this default behavior, allowing a Marimo notebook repository like this to have multiple notebooks and/or a unique structure. This template exemplifies a default structure of a single [notebook.py](notebook.py) file at the root of the repository.
1+
# cdps-dashboard
82

93
## Developing
10-
114
The recommended approach for developing a Marimo notebook is to use the Marimo GUI editor:
125

136
```shell
147
make edit-notebook
158
```
169

17-
### Dependencies
18-
19-
There are many ways in which [dependencies can be managed](https://docs.marimo.io/guides/package_management/) for a Marimo notebook. For details on [marimo-launcher](https://github.com/MITLibraries/marimo-launcher) handles and expects dependencies, please [click here](https://github.com/MITLibraries/marimo-launcher?tab=readme-ov-file#notebook-dependencies).
20-
2110
### Testing
22-
23-
Testing is performed on the command line against inlined tests in notebook(s) ([read more here in the Marimo docs](https://docs.marimo.io/guides/testing/pytest/#testing-at-the-command-line)) and any tests discovered in `/tests`.
24-
25-
There are two primary ways to add tests:
26-
27-
1. Create a cell in a notebook and either manually in the `.py` file, or via the cell action menu, **name** the cell to start with a `test_` prefix.
28-
2. Add tests to the standalone `/tests` folder. This can be helpful for testing code that may live outside of the notebook itself.
29-
3011
To run tests:
3112

3213
```shell
3314
make test
3415
```
3516

36-
Note the use of `*.py` in the Makefile command `test`. Per this greedy test discovery approach, _any_ function that starts with `test_` will be included in the test suite. To avoid this behavior `*.py` can be replaced with more granular, specific filepaths.
37-
3817
### Linting
39-
40-
`mypy` type and `ruff` general linting are similar to other python projects, but note the relaxed rules in `pyproject.toml` for Marimo notebook files. If multiple notebooks are present, they will need to be added here.
18+
To run linting:
4119

4220
```shell
4321
make lint
4422
```
4523

4624
## Running
47-
4825
Often, notebooks are [served as an "app"](https://docs.marimo.io/guides/apps/). This is the default mode for [marimo-launcher](https://github.com/MITLibraries/marimo-launcher).
4926

5027
```shell
@@ -54,13 +31,11 @@ uv run marimo run --sandbox --headless --no-token notebook.py
5431
## Environment Variables
5532

5633
### Required
57-
5834
```shell
5935
# add required env vars here...
6036
```
6137

6238
### Optional
63-
6439
```shell
6540
# add optional env vars here...
6641
```

notebook.py

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
# requires-python = ">=3.13"
33
# dependencies = [
44
# "marimo",
5-
# "tinydb==4.8.2",
65
# ]
76
# ///
87

98
import marimo
109

11-
__generated_with = "0.14.17"
10+
__generated_with = "0.16.5"
1211
app = marimo.App(width="medium")
1312

1413

@@ -21,65 +20,40 @@ def _():
2120

2221
@app.cell
2322
def _(mo):
24-
mo.md(
25-
"""
26-
# Hello Marimo Notebook Template World! 👋📓🌍
27-
28-
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).
29-
"""
30-
)
31-
return
32-
33-
34-
@app.cell
35-
def _(mo):
36-
import sys
37-
38-
mo.md(f"""Python version: `{sys.version}`""")
39-
return
40-
41-
42-
@app.cell
43-
def _(mo):
44-
mo.md(
45-
"""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..."""
46-
)
47-
return
48-
49-
50-
@app.cell
51-
def _(mo):
52-
import tempfile
53-
54-
from tinydb import TinyDB
55-
56-
with tempfile.TemporaryDirectory() as tmpdir:
57-
db = TinyDB(f"{tmpdir}/db.json")
58-
db.insert({"name": "test"})
59-
results = db.all()
60-
61-
mo.md(
62-
f"""
63-
TinyDB loaded: `OK`<br>
64-
Results: `{results}`
65-
"""
66-
)
23+
mo.md("""# CDPS Dashboard""")
6724
return
6825

6926

7027
@app.cell
7128
def _(mo):
72-
mo.md(
73-
"""
74-
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.
75-
"""
29+
file_count = {"total": "3"}
30+
file_extensions = {"pdf": "1", "tiff": "2"}
31+
storage = {"total": "1234"}
32+
33+
data = mo.ui.dropdown(
34+
options={
35+
"File - Count": file_count,
36+
"File - Extensions": file_extensions,
37+
"Storage": storage,
38+
},
39+
label="Select a data type:",
7640
)
77-
return
41+
data
42+
return (data,)
7843

7944

8045
@app.cell
81-
def test_fortytwo_addition():
82-
assert 42 == 40 + 2
46+
def _(data, mo):
47+
import json
48+
49+
if not data.selected_key:
50+
markdown_str = ""
51+
else:
52+
markdown_str = f"""
53+
## {data.selected_key}
54+
{json.dumps(data.value)}
55+
"""
56+
mo.md(markdown_str)
8357
return
8458

8559

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ show-fixes = true
5050
[tool.ruff.lint]
5151
select = ["ALL", "PT"]
5252
ignore = [
53+
"B018",
5354
"C90",
5455
"COM812",
5556
"D100",

0 commit comments

Comments
 (0)