Skip to content

Commit 155f587

Browse files
committed
Use runtime summaries in Marimo display views.
Replace direct SDK-shape handling with runtime list and metadata helpers, and add a guardrail test to keep package imports on the root runtime contract surface.
1 parent c1b6ef1 commit 155f587

2 files changed

Lines changed: 42 additions & 20 deletions

File tree

hotdata_marimo/display.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ def query_result(
3838
)
3939
else:
4040
trunc = None
41+
meta = result.metadata_dict()
4142
meta_bits = []
42-
if result.result_id:
43-
meta_bits.append(f"**result_id** `{result.result_id}`")
44-
if result.query_run_id:
45-
meta_bits.append(f"**query_run_id** `{result.query_run_id}`")
46-
if result.execution_time_ms is not None:
47-
meta_bits.append(f"**execution_time_ms** {result.execution_time_ms}")
48-
if result.warning:
49-
meta_bits.append(f"**warning** {result.warning}")
50-
if result.error_message:
51-
meta_bits.append(f"**error** {result.error_message}")
43+
if meta["result_id"]:
44+
meta_bits.append(f"**result_id** `{meta['result_id']}`")
45+
if meta["query_run_id"]:
46+
meta_bits.append(f"**query_run_id** `{meta['query_run_id']}`")
47+
if meta["execution_time_ms"] is not None:
48+
meta_bits.append(f"**execution_time_ms** {meta['execution_time_ms']}")
49+
if meta["warning"]:
50+
meta_bits.append(f"**warning** {meta['warning']}")
51+
if meta["error_message"]:
52+
meta_bits.append(f"**error** {meta['error_message']}")
5253
header = mo.md(" · ".join(meta_bits) if meta_bits else "_No metadata._")
5354
df = result.to_pandas()
5455
tbl = mo.ui.table(
@@ -70,10 +71,9 @@ def query_result(
7071
class RecentResults:
7172
def __init__(self, client: HotdataClient, *, limit: int = 50) -> None:
7273
self._client = client
73-
listing = client.results().list_results(limit=limit, offset=0)
74-
self._results = listing.results
74+
self._results = client.list_recent_results(limit=limit, offset=0)
7575
option_pairs = [
76-
(f"{r.created_at} · {r.status} · {r.id}", r.id)
76+
(f"{r.created_at} · {r.status} · {r.result_id}", r.result_id)
7777
for r in self._results
7878
]
7979
options = _option_map_with_unique_labels(option_pairs)
@@ -110,20 +110,19 @@ def run_history(
110110
limit: int = 20,
111111
label: str = "Run history",
112112
):
113-
runs = client.query_runs().list_query_runs(limit=limit).query_runs
113+
runs = client.list_run_history(limit=limit)
114114
if not runs:
115115
return mo.md("_No query runs returned._")
116116

117117
rows: list[dict[str, object]] = []
118118
for r in runs:
119119
rows.append(
120120
{
121-
"created_at": getattr(r, "created_at", None),
122-
"status": getattr(r, "status", None),
123-
"execution_time_ms": getattr(r, "execution_time_ms", None),
124-
"result_id": getattr(r, "result_id", None),
125-
"query_run_id": getattr(r, "id", None)
126-
or getattr(r, "query_run_id", None),
121+
"created_at": r.created_at,
122+
"status": r.status,
123+
"execution_time_ms": r.execution_time_ms,
124+
"result_id": r.result_id,
125+
"query_run_id": r.query_run_id,
127126
}
128127
)
129128

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from __future__ import annotations
2+
3+
import re
4+
from pathlib import Path
5+
6+
7+
REPO_ROOT = Path(__file__).resolve().parents[1]
8+
SOURCE_ROOT = REPO_ROOT / "hotdata_marimo"
9+
10+
11+
def test_source_uses_hotdata_runtime_root_imports() -> None:
12+
violations: list[str] = []
13+
pattern = re.compile(r"(?m)^\s*from\s+hotdata_runtime\.(client|env|result|health)\s+import")
14+
15+
for path in SOURCE_ROOT.rglob("*.py"):
16+
text = path.read_text(encoding="utf-8")
17+
if pattern.search(text):
18+
violations.append(str(path.relative_to(REPO_ROOT)))
19+
20+
assert not violations, (
21+
"Use `from hotdata_runtime import ...` in package source; "
22+
f"found submodule imports in: {', '.join(violations)}"
23+
)

0 commit comments

Comments
 (0)