Skip to content

Dashboard: share_url() without data gives a URL whose updates fail #143

Description

@jvdd

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions