py/facett_demo/panes/offline_pane.py
"""The korp tabs WITHOUT the korp extra — the same components, on the gallery's data.
``facett-demo`` runs without a korp-server and without the korp wire installed: the
``[korp]`` extra (``grpcio`` + ``protobuf``) is optional. When it is missing, each live
korp tab (Graph, Map, Population) mounts the SAME facett components it would have fed
with live data, on the gallery's generated/fixture payloads (``demo_payloads.json``,
held against the real registry by ``xtask/tests/gallery_covers_the_manifest.rs``), and
says so first, in words, with the install line. Nothing here pretends to be live.
There is no drawing code in this file: it chooses names and payloads; the wasm draws.
"""
from __future__ import annotations
import streamlit as st
from .. import client as _client
from ..demo_payloads import payload_for
from ..facet_host import facett_component, is_data_driven
def render(title: str, components: list[str], *, key: str, height: int = 560) -> None:
"""Mount ``components`` with their gallery payloads, under an honest banner."""
st.subheader(title)
st.info(
"Live korp data needs the korp wire, which is not installed "
f"(`{_client.KORP_IMPORT_ERROR}`). Install it with `{_client.KORP_EXTRA_HINT}` and point "
"`$KORP_SERVER` at a korp-server. Until then this tab shows the gallery's "
"generated/fixture data on the same components — NOT live data."
)
for name in components:
if not is_data_driven(name):
st.error(f"`{name}` is not a data-driven component in the installed `facett` wheel.")
continue
data = payload_for(name)
if data is None:
st.warning(f"`{name}` has no gallery payload to show offline.")
continue
st.caption(f"`{name}` · gallery payload (offline)")
facett_component(name, data=data, height=height, key=f"offline-{key}-{name}")