fix snippets: rewrite as marimo notebooks, disable defaults
Snippets were plain Python dicts — marimo expects actual notebook files (marimo.App with @app.cell). Rewrote all 10 as proper marimo notebooks that load_app() can parse. Disabled include_default_snippets — only our project snippets show. 10 snippets: duckdb, trino, bib, nessie, s3-obstore, chart-bar, chart-line, query-demographics, query-schema, query-pmpm. refs #75
This commit is contained in:
@@ -64,8 +64,8 @@ preset = "default"
|
|||||||
[keymap.overrides]
|
[keymap.overrides]
|
||||||
|
|
||||||
[snippets]
|
[snippets]
|
||||||
custom_paths = []
|
custom_paths = ["/home/kert/notebooks/snippets"]
|
||||||
include_default_snippets = true
|
include_default_snippets = false
|
||||||
|
|
||||||
[mcp]
|
[mcp]
|
||||||
presets = []
|
presets = []
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ custom_css = ["/home/kert/.config/marimo/loch.css"]
|
|||||||
|
|
||||||
[snippets]
|
[snippets]
|
||||||
custom_paths = ["/home/kert/notebooks/snippets"]
|
custom_paths = ["/home/kert/notebooks/snippets"]
|
||||||
|
include_default_snippets = false
|
||||||
|
|||||||
34
notebooks/snippets/bib-connect.py
Normal file
34
notebooks/snippets/bib-connect.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Bibliography: Connect to bib.Store
|
||||||
|
|
||||||
|
Open the bibliography store for browsing Zotero-synced references.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
from conf import connect
|
||||||
|
|
||||||
|
store = connect.bib()
|
||||||
|
items = store.list_items()
|
||||||
|
return connect, items, store
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
51
notebooks/snippets/chart-bar.py
Normal file
51
notebooks/snippets/chart-bar.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Chart: Horizontal bar chart
|
||||||
|
|
||||||
|
Template for a horizontal bar chart with Altair.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
from conf import connect
|
||||||
|
|
||||||
|
connect.theme()
|
||||||
|
import altair as alt
|
||||||
|
|
||||||
|
return alt, connect
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(alt):
|
||||||
|
chart = (
|
||||||
|
alt.Chart(df.to_pandas())
|
||||||
|
.mark_bar()
|
||||||
|
.encode(
|
||||||
|
x=alt.X("value:Q", title="Value"),
|
||||||
|
y=alt.Y("category:N", sort="-x", title=None),
|
||||||
|
tooltip=["category:N", "value:Q"],
|
||||||
|
)
|
||||||
|
.properties(title="Title", width=600, height=300)
|
||||||
|
)
|
||||||
|
chart
|
||||||
|
return (chart,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
42
notebooks/snippets/chart-line.py
Normal file
42
notebooks/snippets/chart-line.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Chart: Time series line chart
|
||||||
|
|
||||||
|
Template for a multi-series time series line chart with Altair.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(alt):
|
||||||
|
chart = (
|
||||||
|
alt.Chart(df.to_pandas())
|
||||||
|
.mark_line(point=True)
|
||||||
|
.encode(
|
||||||
|
x=alt.X("date:T", title="Date"),
|
||||||
|
y=alt.Y("value:Q", title="Value"),
|
||||||
|
color=alt.Color("series:N", title="Series"),
|
||||||
|
tooltip=["date:T", "series:N", "value:Q"],
|
||||||
|
)
|
||||||
|
.properties(title="Title", width=800, height=350)
|
||||||
|
)
|
||||||
|
chart
|
||||||
|
return (chart,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
# Marimo snippets — Altair chart templates with Nature theme
|
|
||||||
|
|
||||||
snippets = [
|
|
||||||
{
|
|
||||||
"title": "Chart setup — Nature theme",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
connect.theme()
|
|
||||||
|
|
||||||
import altair as alt
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Bar chart (horizontal)",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """chart = (
|
|
||||||
alt.Chart(df.to_pandas())
|
|
||||||
.mark_bar()
|
|
||||||
.encode(
|
|
||||||
x=alt.X("value:Q", title="Value"),
|
|
||||||
y=alt.Y("category:N", sort="-x", title=None),
|
|
||||||
tooltip=["category:N", "value:Q"],
|
|
||||||
)
|
|
||||||
.properties(title="Title", width=600, height=300)
|
|
||||||
)
|
|
||||||
chart
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Line chart (time series)",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """chart = (
|
|
||||||
alt.Chart(df.to_pandas())
|
|
||||||
.mark_line(point=True)
|
|
||||||
.encode(
|
|
||||||
x=alt.X("date:T", title="Date"),
|
|
||||||
y=alt.Y("value:Q", title="Value"),
|
|
||||||
color=alt.Color("series:N", title="Series"),
|
|
||||||
tooltip=["date:T", "series:N", "value:Q"],
|
|
||||||
)
|
|
||||||
.properties(title="Title", width=800, height=350)
|
|
||||||
)
|
|
||||||
chart
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Scatter plot",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """chart = (
|
|
||||||
alt.Chart(df.to_pandas())
|
|
||||||
.mark_circle(opacity=0.6)
|
|
||||||
.encode(
|
|
||||||
x=alt.X("x:Q", title="X Axis"),
|
|
||||||
y=alt.Y("y:Q", title="Y Axis"),
|
|
||||||
color=alt.Color("group:N"),
|
|
||||||
size=alt.Size("weight:Q", legend=None),
|
|
||||||
tooltip=["x:Q", "y:Q", "group:N"],
|
|
||||||
)
|
|
||||||
.properties(title="Title", width=600, height=400)
|
|
||||||
)
|
|
||||||
chart
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Donut chart",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """chart = (
|
|
||||||
alt.Chart(df.to_pandas())
|
|
||||||
.mark_arc(innerRadius=60)
|
|
||||||
.encode(
|
|
||||||
theta=alt.Theta("value:Q"),
|
|
||||||
color=alt.Color("category:N", title="Category"),
|
|
||||||
tooltip=["category:N", "value:Q"],
|
|
||||||
)
|
|
||||||
.properties(title="Title", width=350, height=350)
|
|
||||||
)
|
|
||||||
chart
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Stacked area chart",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """chart = (
|
|
||||||
alt.Chart(df.to_pandas())
|
|
||||||
.mark_area(opacity=0.7)
|
|
||||||
.encode(
|
|
||||||
x=alt.X("date:T", title="Date"),
|
|
||||||
y=alt.Y("value:Q", stack=True, title="Value"),
|
|
||||||
color=alt.Color("category:N", title="Category"),
|
|
||||||
tooltip=["date:T", "category:N", "value:Q"],
|
|
||||||
)
|
|
||||||
.properties(title="Title", width=800, height=350)
|
|
||||||
)
|
|
||||||
chart
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
# Marimo snippets — connection factories
|
|
||||||
# These appear in marimo's snippet picker (Ctrl+Space or / in code cells)
|
|
||||||
|
|
||||||
snippets = [
|
|
||||||
{
|
|
||||||
"title": "DuckDB — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
con = connect.duckdb()
|
|
||||||
|
|
||||||
def q(sql):
|
|
||||||
\"\"\"Run SQL, return Polars DataFrame.\"\"\"
|
|
||||||
return con.execute(sql).pl()
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "DuckDB — schema overview",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """schemas = q('''
|
|
||||||
SELECT table_schema AS 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="Schemas")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Trino — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
trino_con = connect.trino()
|
|
||||||
cursor = trino_con.cursor()
|
|
||||||
|
|
||||||
def tq(sql):
|
|
||||||
\"\"\"Run Trino SQL, return rows.\"\"\"
|
|
||||||
cursor.execute(sql)
|
|
||||||
return cursor.fetchall()
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Bibliography — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
store = connect.bib()
|
|
||||||
items = store.list_items()
|
|
||||||
print(f"{len(items)} bibliography items")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Nessie — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
nessie = connect.nessie()
|
|
||||||
refs = nessie.list_refs()
|
|
||||||
for r in refs:
|
|
||||||
print(f"{r['type']}: {r['name']}")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Polaris — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
polaris = connect.polaris()
|
|
||||||
catalogs = polaris.list_catalogs()
|
|
||||||
for c in catalogs:
|
|
||||||
print(c["name"])
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "S3 / RustFS — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
s3 = connect.s3()
|
|
||||||
objects = s3.list_objects(prefix="data/")
|
|
||||||
for key in objects[:10]:
|
|
||||||
print(key)
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Zotero — connect",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
zotero_con = connect.zotero()
|
|
||||||
cursor = zotero_con.cursor()
|
|
||||||
tables = cursor.execute(
|
|
||||||
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
|
|
||||||
).fetchall()
|
|
||||||
print(f"{len(tables)} tables")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "S3 / RustFS — obstore (marimo Files panel)",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """from conf import connect
|
|
||||||
|
|
||||||
# Creates an obstore S3Store that marimo auto-discovers
|
|
||||||
# in the Files sidebar → Remote Storage panel.
|
|
||||||
store = connect.obstore()
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
38
notebooks/snippets/duckdb-connect.py
Normal file
38
notebooks/snippets/duckdb-connect.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# DuckDB: Connect via conf.connect
|
||||||
|
|
||||||
|
Open the project DuckDB database and define a helper to run SQL queries.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
from conf import connect
|
||||||
|
|
||||||
|
con = connect.duckdb()
|
||||||
|
|
||||||
|
def q(sql):
|
||||||
|
"""Run SQL and return a Polars DataFrame."""
|
||||||
|
return con.execute(sql).pl()
|
||||||
|
|
||||||
|
return con, connect, q
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
34
notebooks/snippets/nessie-connect.py
Normal file
34
notebooks/snippets/nessie-connect.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Nessie: Git-for-Data client
|
||||||
|
|
||||||
|
Connect to Nessie for versioned Iceberg catalog operations.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
from conf import connect
|
||||||
|
|
||||||
|
nessie = connect.nessie()
|
||||||
|
refs = nessie.list_refs()
|
||||||
|
return connect, nessie, refs
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
# Marimo snippets — common healthcare analytics SQL queries
|
|
||||||
|
|
||||||
snippets = [
|
|
||||||
{
|
|
||||||
"title": "Query — table profile",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """table = "core.patient"
|
|
||||||
profile = q(f'''
|
|
||||||
SELECT
|
|
||||||
count(*) AS rows,
|
|
||||||
count(*) - count(person_id) AS nulls,
|
|
||||||
count(DISTINCT person_id) AS distinct_ids
|
|
||||||
FROM {table}
|
|
||||||
''')
|
|
||||||
mo.ui.table(profile, label=f"Profile: {table}")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Query — patient demographics",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """demographics = q('''
|
|
||||||
SELECT sex, race, state, count(*) AS patients,
|
|
||||||
round(avg(age), 1) AS avg_age
|
|
||||||
FROM core.patient
|
|
||||||
GROUP BY sex, race, state
|
|
||||||
ORDER BY patients DESC
|
|
||||||
''')
|
|
||||||
mo.ui.table(demographics, label="Patient Demographics")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Query — encounter summary",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """encounters = q('''
|
|
||||||
SELECT encounter_type,
|
|
||||||
count(*) AS encounters,
|
|
||||||
count(DISTINCT person_id) AS patients
|
|
||||||
FROM core.encounter
|
|
||||||
GROUP BY encounter_type
|
|
||||||
ORDER BY encounters DESC
|
|
||||||
''')
|
|
||||||
mo.ui.table(encounters, label="Encounters by Type")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Query — PMPM financial",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """pmpm = q('''
|
|
||||||
SELECT year_month,
|
|
||||||
member_months,
|
|
||||||
round(total_paid / member_months, 2) AS total_pmpm,
|
|
||||||
round(inpatient_paid / member_months, 2) AS inpatient_pmpm,
|
|
||||||
round(pharmacy_paid / member_months, 2) AS pharmacy_pmpm
|
|
||||||
FROM financial_pmpm.pmpm_payer
|
|
||||||
WHERE member_months > 50
|
|
||||||
ORDER BY year_month
|
|
||||||
''')
|
|
||||||
mo.ui.table(pmpm, label="PMPM by Month")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Query — chronic conditions top 20",
|
|
||||||
"sections": [
|
|
||||||
{
|
|
||||||
"code": """chronic = q('''
|
|
||||||
SELECT condition, count(DISTINCT person_id) AS patients
|
|
||||||
FROM chronic_conditions.cms_chronic_conditions_long
|
|
||||||
GROUP BY condition
|
|
||||||
ORDER BY patients DESC
|
|
||||||
LIMIT 20
|
|
||||||
''')
|
|
||||||
mo.ui.table(chronic, label="Top 20 Chronic Conditions")
|
|
||||||
""",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
|
||||||
38
notebooks/snippets/query-demographics.py
Normal file
38
notebooks/snippets/query-demographics.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Query: Patient demographics
|
||||||
|
|
||||||
|
Summarise patient demographics by sex, race, and state.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo, q):
|
||||||
|
demographics = q('''
|
||||||
|
SELECT sex, race, state, count(*) AS patients,
|
||||||
|
round(avg(age), 1) AS avg_age
|
||||||
|
FROM core.patient
|
||||||
|
GROUP BY sex, race, state
|
||||||
|
ORDER BY patients DESC
|
||||||
|
''')
|
||||||
|
mo.ui.table(demographics, label="Patient Demographics")
|
||||||
|
return (demographics,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
40
notebooks/snippets/query-pmpm.py
Normal file
40
notebooks/snippets/query-pmpm.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Query: PMPM financial summary
|
||||||
|
|
||||||
|
Per-member-per-month cost breakdown by service category.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo, q):
|
||||||
|
pmpm = q('''
|
||||||
|
SELECT year_month, member_months,
|
||||||
|
round(total_paid / member_months, 2) AS total_pmpm,
|
||||||
|
round(inpatient_paid / member_months, 2) AS inpatient_pmpm,
|
||||||
|
round(pharmacy_paid / member_months, 2) AS pharmacy_pmpm
|
||||||
|
FROM financial_pmpm.pmpm_payer
|
||||||
|
WHERE member_months > 50
|
||||||
|
ORDER BY year_month
|
||||||
|
''')
|
||||||
|
mo.ui.table(pmpm, label="PMPM by Month")
|
||||||
|
return (pmpm,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
38
notebooks/snippets/query-schema.py
Normal file
38
notebooks/snippets/query-schema.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Query: Schema overview
|
||||||
|
|
||||||
|
List all schemas and table counts in the database.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo, q):
|
||||||
|
schemas = q('''
|
||||||
|
SELECT table_schema AS 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="Schemas")
|
||||||
|
return (schemas,)
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
34
notebooks/snippets/s3-obstore.py
Normal file
34
notebooks/snippets/s3-obstore.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# S3: Remote Storage via obstore
|
||||||
|
|
||||||
|
Create an S3Store that marimo auto-discovers in Files -> Remote Storage.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
from conf import connect
|
||||||
|
|
||||||
|
store = connect.obstore()
|
||||||
|
# This S3Store is auto-discovered by marimo in Files -> Remote Storage
|
||||||
|
return connect, store
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
34
notebooks/snippets/trino-connect.py
Normal file
34
notebooks/snippets/trino-connect.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import marimo
|
||||||
|
|
||||||
|
__generated_with = "0.20.4"
|
||||||
|
app = marimo.App()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _(mo):
|
||||||
|
mo.md(r"""
|
||||||
|
# Trino: Connect via conf.connect
|
||||||
|
|
||||||
|
Connect to the Trino query engine for federated SQL queries.
|
||||||
|
""")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
from conf import connect
|
||||||
|
|
||||||
|
trino_con = connect.trino()
|
||||||
|
cursor = trino_con.cursor()
|
||||||
|
return connect, cursor, trino_con
|
||||||
|
|
||||||
|
|
||||||
|
@app.cell
|
||||||
|
def _():
|
||||||
|
import marimo as mo
|
||||||
|
|
||||||
|
return (mo,)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run()
|
||||||
Reference in New Issue
Block a user