You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marimo UI helpers for [Hotdata](https://hotdata.dev): run SQL from a notebook, browse catalog metadata, and render results as tables.
3
+
Marimo widgets for [Hotdata](https://hotdata.dev): run SQL, browse catalogs, load managed databases, and display results in notebooks.
4
4
5
-
## Features
6
-
7
-
-**Workspace-aware setup** — build a `HotdataClient` from environment variables, or use `workspace_selector_from_env()` to choose a workspace interactively when no workspace is pinned.
8
-
-**Connection health** — show a compact status callout with API, workspace, and optional sandbox context.
9
-
-**Catalog browsing** — browse Hotdata connections, schemas, tables, and columns from Marimo UI controls.
10
-
-**SQL editor widget** — run SQL against Hotdata, cache the latest successful result, and render results in downstream reactive cells.
11
-
-**Native `mo.sql` engine** — register `HotdataMarimoEngine` so Marimo SQL cells can execute through a live `HotdataClient` with `engine=client`.
12
-
-**Result display helpers** — render query results, recent results, and run history as notebook-friendly UI.
13
-
-**Managed databases** — create Hotdata-owned catalogs, declare tables, and load parquet files (replaces dataset uploads for writes).
14
-
-**Marimo UI aliases** — importing `hotdata_marimo` attaches helpers such as `mo.ui.hotdata_sql_editor` and `mo.ui.hotdata_table_browser` for discoverability.
5
+
Requires Python 3.10+, [Marimo](https://marimo.io/), and [hotdata-runtime](https://github.com/hotdata-dev/hotdata-runtime) (installed automatically).
15
6
16
7
## Install
17
8
18
9
```bash
19
-
uv pip install hotdata-marimo
20
-
# or: pip install hotdata-marimo
10
+
pip install hotdata-marimo
21
11
```
22
12
23
-
Requires Python 3.10+, **Marimo**, and [**hotdata-runtime**](https://github.com/hotdata-dev/hotdata-runtime) (Hotdata SDK + runtime/session semantics — pulled in automatically when you `pip install hotdata-marimo`).
13
+
Set `HOTDATA_API_KEY`. Optionally set `HOTDATA_WORKSPACE`, `HOTDATA_API_URL`, or `HOTDATA_SANDBOX`.
24
14
25
-
## Environment
15
+
## Connect
26
16
27
-
| Variable | Required | Description |
28
-
|----------|----------|-------------|
29
-
|`HOTDATA_API_KEY`| Yes | API key for the Hotdata API |
30
-
|`HOTDATA_API_URL`| No | API base URL (default: `https://api.hotdata.dev`) |
31
-
|`HOTDATA_WORKSPACE`| No | Workspace id; if unset, the first active workspace is used |
32
-
|`HOTDATA_SANDBOX`| No | Sandbox session id, passed through to the SDK |
17
+
```python
18
+
import hotdata_marimo as hm
33
19
34
-
## Minimal notebook
20
+
client = hm.from_env()
21
+
```
22
+
23
+
If `HOTDATA_WORKSPACE` is unset, pick a workspace interactively:
24
+
25
+
```python
26
+
ws = hm.workspace_selector_from_env()
27
+
client = ws.client
28
+
```
29
+
30
+
## SQL editor widget
31
+
32
+
Run SQL in one cell; show results in the next. Marimo only renders what you **`return`**.
Importing `hotdata_marimo` registers discoverability aliases on Marimo’s UI namespace, so you can also use `mo.ui.hotdata_sql_editor`, `mo.ui.hotdata_table_browser`, `mo.ui.hotdata_query_result`, and `mo.ui.hotdata_connection_status`.
51
+
Click **Run on Hotdata** after changing SQL. The editor caches the last successful result so downstream cells do not re-query on every refresh.
50
52
51
-
Use `hm.connection_status(client)` (or `mo.ui.hotdata_connection_status(client)`) for a small API/workspace health callout.
53
+
## Native Marimo SQL cells
52
54
53
-
## Marimo SQL Cells
55
+
Register the Hotdata engine once, then pass `engine=client` to `mo.sql`. Hotdata appears as **Hotdata** in the SQL connection picker.
54
56
55
-
Register the Hotdata SQL engine once during setup, then pass a `HotdataClient` to Marimo SQL cells:
57
+
**Setup cell**
56
58
57
59
```python
60
+
import marimo as mo
58
61
import hotdata_marimo as hm
59
62
60
63
hm.register_hotdata_sql_engine()
61
64
client = hm.from_env()
62
65
```
63
66
67
+
**SQL cell**
68
+
64
69
```python
65
70
_df = mo.sql(
66
71
"""
@@ -70,46 +75,56 @@ _df = mo.sql(
70
75
)
71
76
```
72
77
73
-
The engine also exposes Hotdata catalog metadata to Marimo's data-source UI. Hotdata connections are labeled **Hotdata** in the SQL connection picker.
78
+

79
+
80
+
## Browse tables
81
+
82
+
```python
83
+
browser = hm.table_browser(client)
84
+
return browser.ui
85
+
```
86
+
87
+
Pick a connection, schema, and table to inspect columns. Use `browser.selected_table` in downstream cells.
74
88
75
-
## Two-cell pattern
89
+
## Managed databases
76
90
77
-
Keep the editor in one cell and consume `editor.result` in another. The editor caches the last successful run so downstream cells do not re-query the API on every refresh; click **Run on Hotdata** again after you change SQL. While a query is running, a Marimo status spinner is shown.
91
+
Create a Hotdata-owned catalog and load a parquet file from the notebook:
78
92
79
-
Marimo only shows **what you `return` from a cell**. Calling `mo.vstack(...)` or `hm.query_result(...)` without returning it produces no visible output.
93
+
```python
94
+
panel = hm.databases_panel(client)
95
+
return panel
96
+
```
80
97
81
-
See `examples/demo.py` for a full runnable notebook flow.
98
+
Or use the lower-level writer API:
82
99
83
-
## Examples
100
+
```python
101
+
writer = hm.managed_database_writer(client)
102
+
return writer.ui
103
+
```
84
104
85
-
-`examples/demo.py` — tabbed explorer with workspace selection, connection health, managed databases (create + parquet load), recent results (selectable table), run history, and a native `mo.sql` cell.
105
+
## Other helpers
86
106
87
-
Run locally (single-user machine):
107
+
```python
108
+
return hm.connection_status(client) # API / workspace callout
109
+
return hm.recent_results(client).ui # past query results
110
+
return hm.run_history(client) # recent query runs
111
+
```
112
+
113
+
Importing `hotdata_marimo` also registers `mo.ui.hotdata_*` aliases (e.g. `mo.ui.hotdata_sql_editor`).
114
+
115
+
## Demo notebook
88
116
89
117
```bash
90
118
uv run marimo edit examples/demo.py --no-token
91
119
```
92
120
93
-
On a **shared or networked host**, omit `--no-token` and use the access token printed in the terminal URL. Without it, anyone who can reach the Marimo port can run queries against your Hotdata workspace.
94
-
95
-
## Layout
96
-
97
-
This repo is intentionally thin: **API client, env helpers, and result models** live in **hotdata-runtime**; **hotdata-marimo** only adds Marimo widgets (`sql_editor`, `table_browser`, `managed_database_writer`, `display` for tables/status/history, `workspace_selector`). Import `HotdataClient` / `QueryResult` / `from_env` from **`hotdata_marimo`** or directly from **`hotdata_runtime`**.
121
+
`examples/demo.py` combines workspace selection, catalog browsing, managed databases, query history, and a native `mo.sql` cell.
98
122
99
123
## Development
100
124
101
-
This package depends on [**hotdata-runtime**](https://github.com/hotdata-dev/hotdata-runtime) (PyPI name `hotdata-runtime`). Development uses **uv**; keep a sibling checkout at `../hotdata-runtime` so the lockfile resolves the runtime from disk (see `[tool.uv.sources]` in `pyproject.toml`).
102
-
103
125
```bash
104
126
uv sync --locked
105
127
uv run pytest
106
-
marimo edit examples/demo.py --no-token
107
128
```
108
129
109
-
To pin **hotdata-runtime** from Git instead of the sibling path, remove the `[tool.uv.sources]` block, set the dependency line as needed, and run `uv lock` again.
110
-
111
-
For a **publishable**`uv.lock` (CI that only clones this repo), remove `[tool.uv.sources]`, point `hotdata-runtime` at PyPI or `git+https://…`, then `uv lock`.
112
-
113
-
The **`[project] name`** in [hotdata-runtime](https://github.com/hotdata-dev/hotdata-runtime)`pyproject.toml` is **`hotdata-runtime`** and the import package is **`hotdata_runtime`**.
114
-
115
-
Use **`--no-token`** for local development so the editor does not redirect to `/auth/login` (session auth is easy to hit with a global Marimo config). For a public or shared machine, omit it and use the printed URL with an access token instead.
130
+
See [hotdata-runtime](https://github.com/hotdata-dev/hotdata-runtime) for the underlying API client.
0 commit comments