← Back to Pull requests

feat(core): notebook cards for core resources #1260

Closed
unknown closed this pull request without merging on Nov 04, 2026 19:21 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 19:24 UTC
Author

Merge after #1257. The new example notebook runs on build and creates resources in the default profile's workspace, and its outputs show their IDs. nominal-io/nominal-sphinx-theme#46, now merged, replaces those UUIDs with stand-ins on the published pages, and #1257 bumps this repo's theme pin to it.

What and why

Until now, a resource at the end of a notebook cell showed its dataclass repr: one line, with nanosecond timestamps and nothing about related resources. Now, in Jupyter, VS Code and Colab, core resources display as HTML cards, similar to xarray's datasets:

  • Fields: each card shows the resource's fields, with timestamps formatted, labels as tags, properties in a collapsible section, and an archived badge.

  • Links and copy buttons: names and RIDs link to their pages in the Nominal app, and IDs have copy buttons.

  • Related resources: an asset lists its datasets, active runs and attachments, and a run its assets, datasets and attachments. A dataset lists its files and channels. A numeric channel shows its sample count, min, max, mean, first and last timestamps, and a small chart. Related resources need a few requests per card, which run in parallel within fetch_timeout. If one fails or doesn't load in time, its section says so and the rest of the card still displays. If building a card fails, the notebook shows the plain repr.

  • Attachment downloads: an attachment's name, in an asset's or run's card, links to its file, and an attachment's card has a download link. The links go through the Nominal app's /api/downloadAttachment/{rid} route, which uses the browser's sign-in. Signed out, the app asks you to sign in, then downloads the file. Attachment.get_contents instead uses a presigned URI that expires after two minutes, which would break links in a saved notebook.
  • Cards exist for NominalClient, Asset, Dataset, Run, Channel, DatasetFile, Event, Workbook, WorkbookTemplate, Checklist, Attachment, DataReview, Workspace and User. Video and VideoFile are deprecated, so they don't get one.

    set_display_options configures every card, as a call or a with block, like xarray.set_options. get_display_options returns the current DisplayOptions:

    | Option | Default | Effect |
    | --- | --- | --- |
    | style | "html" | "text" keeps the plain repr |
    | timezone | "UTC" | "local" or an IANA name |
    | time_format | "iso" | "readable": 2026-11-02 09:52:57 MST |
    | time_precision | "s" | "ms", "us" or "ns". Hovering shows the full value. |
    | show_link | True | links to the Nominal app |
    | fetch_details | True | False: no requests, only the object's own fields |
    | collapse_threshold | 10 | sections with more items start collapsed |
    | max_items | 50 | items listed and loaded per section |
    | fetch_timeout | 5.0 | seconds a card waits, in total, for what it loads |

    A new example, docs/src/examples/notebook_display.md, shows each card on a test rig with two datasets, three runs and an event.

    While testing the example in JupyterLab I found that the examples' jupytext.toml strips extension from notebook front matter. Without it, JupyterLab's Open With → Jupytext Notebook opened every example as one Markdown cell, which breaks the steps on the "Running the examples" page. The config now reads and saves .md files there as MyST.

    A new just notebook recipe opens docs/src/examples/ in JupyterLab, with the client, the docs group and Jupytext installed, so the examples can be run without a separate setup.

    Validation

  • tests/core/test_display.py covers:

  • - cards rendering with no requests when links and loading are off
    - escaping of user values, and refusing non-http(s) links
    - timestamp precision, time zone and format
    - durations
    - collapsing and cutting off long sections, and stopping a load past max_items
    - load failures becoming a note in the section
    - a slow section or workspace stopping at the card's time limit, and a card that fails to build falling back to the repr
    - an asset's runs loading only as many pages as the card lists
    - attachments listed by name, up to max_items, each linked to its download
    - text style making no requests
    - channel statistics combined from buckets, and from a single point
  • just test check, just check-format-notebooks and the docs extension tests pass. just build-docs passes and runs the example against a staging workspace.

  • I also ran the notebook in JupyterLab's UI: all cells ran without errors and every card displayed. Clicking a copy button copied the full RID.

  • I checked the rendered cards in the docs theme in light and dark mode, and in JupyterLab's dark theme. I haven't checked VS Code or Colab.
  • Review notes

  • New public API: DisplayOptions, get_display_options and set_display_options in nominal.core. In the reference docs they're filed under the client topic.

  • Deliberate exception: _display.fetched catches Exception, so a failing related-resource request can't break the display. The error shows in the card.

  • Channel statistics: these use the private Channel._decimate_request. Channel._Clients now also declares catalog, which every caller already passes, to read the dataset's time span.

  • Structural review: the thermo-nuclear structural review hasn't been run on this change.

  • Two problems in the existing client, not changed here:

  • - datasource_to_dataframe(channel_exact_match=[a, b]) with two names returned no channels.
    - Passing channels=dataset.get_channels(...) without list() fails, because the helper reads the iterable twice.

    🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: stefanv Review duration: 2877m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1260"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%