Create notebook template with pre-wired connections, theme, and helpers #76

Closed
opened 2026-03-21 20:57:01 +00:00 by kert · 0 comments
Owner

Problem

Every new notebook starts blank. Users must manually set up imports, connections, theme, and helper functions.

Solution

Create notebooks/_template.py — a marimo notebook that serves as the starting point for new notebooks. Pre-wired with:

Cell 1: Setup

import marimo as mo
import polars as pl
import altair as alt
from conf import connect
from nature import PALETTE, altair_theme

altair_theme()
con = connect.duckdb()

def q(sql):
    return con.execute(sql).pl()

Cell 2: Schema Explorer

schemas = q('''
    SELECT table_schema, count(*) AS tables
    FROM information_schema.tables
    WHERE table_schema != 'information_schema'
    GROUP BY table_schema ORDER BY tables DESC
''')
mo.ui.table(schemas, label='Available Schemas')

Cell 3: Markdown Header

mo.md('''
# Notebook Title

Description of analysis.
''')

Marimo config:

Configure marimo to use this template for new notebooks (if supported), or document it as the copy-from source.

Files

  • notebooks/_template.py (new)
  • README or docs update
## Problem Every new notebook starts blank. Users must manually set up imports, connections, theme, and helper functions. ## Solution Create `notebooks/_template.py` — a marimo notebook that serves as the starting point for new notebooks. Pre-wired with: ### Cell 1: Setup ```python import marimo as mo import polars as pl import altair as alt from conf import connect from nature import PALETTE, altair_theme altair_theme() con = connect.duckdb() def q(sql): return con.execute(sql).pl() ``` ### Cell 2: Schema Explorer ```python schemas = q(''' SELECT table_schema, count(*) AS tables FROM information_schema.tables WHERE table_schema != 'information_schema' GROUP BY table_schema ORDER BY tables DESC ''') mo.ui.table(schemas, label='Available Schemas') ``` ### Cell 3: Markdown Header ```python mo.md(''' # Notebook Title Description of analysis. ''') ``` ### Marimo config: Configure marimo to use this template for new notebooks (if supported), or document it as the copy-from source. ## Files - `notebooks/_template.py` (new) - README or docs update
kert added this to the P14: Notebook DX — connections, snippets, templates, S3 buckets milestone 2026-03-21 20:57:01 +00:00
kert added the docs label 2026-03-21 20:57:01 +00:00
kert closed this issue 2026-03-22 00:26:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#76