Problem
share_url() on a Dashboard without data returns a URL that opens but never shows data. Its docstring says the method neither starts a server nor registers the source, and that the server must already serve source_name. That reads as "no data needed", but data is needed.
import polars as pl
from flexviz import Dashboard
lf = pl.LazyFrame({"t": [0, 1, 2], "value": [1.0, 2.0, 3.0]})
for label, d in [("Dashboard()", Dashboard()), ("Dashboard(lf)", Dashboard(lf))]:
d.add_figure().add_line(x="t", y="value")
print(label, d.to_spec(source_name="logs").figures[0].source)
# Dashboard() None
# Dashboard(lf) logs
The cause is Dashboard.to_spec(): src = source_name if self._backend_lf is not None else None. In a browser, GET /view returns 200. Then each /dashboard/update returns 500 (KeyError: 't' in trace/line.py, get_aggregation_spec, for a line), and the console logs "initial load failed, panels are empty". Nothing fails in Python.
It is easy to hit in web apps (#73, #141). The page script builds the URL, and the server registers the data in another file or process. The web apps guide now works around it: build the Dashboard on a lazy scan of the same file.
Proposal
Honour source_name in to_spec(), with or without data. This changes share_url(), save_spec(), and to_spec() together. The server already checks axis-link types against the registered schema on /view and on each update (_check_link_types), so the client-side link check can stay limited to dashboards with data. show() registers no source for a dashboard without data, so it passes no source_name and keeps its behaviour.
The alternative is to raise ValueError in share_url() when the dashboard has no data. That is smaller, but it keeps the second scan in web apps for no reason.
Done when
Dashboard().share_url(source_name="x") gives figures with source == "x", and the page loads data from a server that serves x.
- A test covers it.
- The web apps guide drops the "same data" rule, or limits it to dashboards with linked axes.
Problem
share_url()on aDashboardwithout data returns a URL that opens but never shows data. Its docstring says the method neither starts a server nor registers the source, and that the server must already servesource_name. That reads as "no data needed", but data is needed.The cause is
Dashboard.to_spec():src = source_name if self._backend_lf is not None else None. In a browser,GET /viewreturns 200. Then each/dashboard/updatereturns 500 (KeyError: 't'intrace/line.py,get_aggregation_spec, for a line), and the console logs "initial load failed, panels are empty". Nothing fails in Python.It is easy to hit in web apps (#73, #141). The page script builds the URL, and the server registers the data in another file or process. The web apps guide now works around it: build the
Dashboardon a lazy scan of the same file.Proposal
Honour
source_nameinto_spec(), with or without data. This changesshare_url(),save_spec(), andto_spec()together. The server already checks axis-link types against the registered schema on/viewand on each update (_check_link_types), so the client-side link check can stay limited to dashboards with data.show()registers no source for a dashboard without data, so it passes nosource_nameand keeps its behaviour.The alternative is to raise
ValueErrorinshare_url()when the dashboard has no data. That is smaller, but it keeps the second scan in web apps for no reason.Done when
Dashboard().share_url(source_name="x")gives figures withsource == "x", and the page loads data from a server that servesx.