Skip to content

Chart preview extension using staging server#5673

Open
Marigold wants to merge 47 commits intomasterfrom
chart-preview-staging
Open

Chart preview extension using staging server#5673
Marigold wants to merge 47 commits intomasterfrom
chart-preview-staging

Conversation

@Marigold
Copy link
Collaborator

@Marigold Marigold commented Feb 13, 2026

Motivation

We manage chart configurations through two systems: the Admin UI and, more recently, YAML-based .chart.yml files in ETL (graph steps). This PR builds the infrastructure for graph steps — a new ETL pipeline channel that lets you define charts as code, push them to the database, and preview them live.

It also ships a VSCode extension with a live preview panel, enabling fast iteration on chart configs — both for humans and for agentic workflows where an LLM edits chart YAML with visual feedback in the loop.

What's in here

  • graph:// pipeline channel — new DAG channel with --graph flag; .chart.yml files define chart configs (single charts or multi-dimensional collections)
  • Push/pull sync--graph-push overwrites Admin UI edits, --graph-pull syncs DB changes back to YAML, with conflict detection when both sides have been edited
  • Short indicator names — YAML uses short names like fur_farming_status that auto-expand to full catalog paths using DAG dependencies (no hardcoded versions)
  • Python graph steps — for dynamic values (e.g., calculating thresholds at runtime) alongside YAML configs
  • chart-preview VSCode extension — live preview panel that hot-reloads on save, supports regular charts, mdim graph steps, and export/multidim steps
  • Export/multidim preview support — the extension also works with export://multidim/ steps (.config.yml and .py files), running them with --export --watch

Workflow demo

1. Install the extension and build upstream data

make vsce-compile EXT=chart-preview INSTALL=1
.venv/bin/etlr grapher/animal_welfare/2025-01-07/fur_laws --private

Reload VSCode (Cmd+Shift+P → "Reload Window").

2. Open a chart with live preview

Open etl/steps/graph/animal_welfare/latest/fur-farming-ban.chart.yml. Click the preview icon in the editor title bar — an interactive Grapher chart appears in a side panel. Edit the YAML, save, and the preview refreshes automatically.

Chart preview extension showing live Grapher chart

3. Preview export/multidim steps

The extension also works with the older Python-based multidim steps. Open etl/steps/export/multidim/war/latest/ucdp.py or ucdp.config.yml and click preview — it runs etlr --export --watch and shows the mdim chart from staging.

4. Let Claude Code edit charts for you

Start Claude Code in the repo and use the /chart-editing skill:

> /chart-editing
> Change the color of "Banned" to dark red and add a subtitle

Claude reads the schema, edits the YAML, and iterates. The VSCode preview panel hot-reloads on every save.

Graph step examples

Simple chart (fur-farming-ban.chart.yml):

slug: fur-farming-ban
title: Which countries have banned fur farming?
tab: map
hasMapTab: true
dimensions:
  - property: y
    catalogPath: fur_farming_status

Mdim collection (covid-cases.chart.yml):

slug: covid/covid#covid_cases
title:
  title: COVID-19 confirmed cases
dimensions:
  - slug: period
    choices: [{slug: weekly}, {slug: biweekly}]
views:
  - dimensions: {period: weekly, metric: absolute}
    indicators:
      y: [{catalogPath: weekly_cases}]

Limitations

This is a prototype. Not yet supported:

  • Inheritance from variable metadata
  • Dynamic placeholders in chart YAMLs (e.g. {definitions.description})
  • The render script has ~0.8s startup overhead per render

🤖 Generated with Claude Code

@owidbot
Copy link
Contributor

owidbot commented Feb 13, 2026

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-chart-preview-staging

chart-diff: ❌
  • 0/1 reviewed charts
  • Modified: 0/1
  • New: 0/0
  • Rejected: 0
  • Data changes: 0
  • Metadata changes: 0
data-diff: ✅ No differences found

Automatically updated datasets matching excess_mortality|covid|fluid|flunet|country_profile|garden/ihme_gbd/2019/gbd_risk are not included

Edited: 2026-02-23 11:05:22 UTC
Execution time: 12.88 seconds

@Marigold Marigold changed the base branch from master to wip-prototype-graph-metadata February 13, 2026 13:08
Marigold and others added 2 commits February 13, 2026 14:10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nder_chart.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Marigold Marigold force-pushed the chart-preview-staging branch from 493f715 to f3e5221 Compare February 13, 2026 18:45
Marigold and others added 6 commits February 13, 2026 19:55
In watch mode, etlr doesn't print "All datasets up to date!" — it just
outputs "OK" after dirty detection and waits. Use a 500ms timer after
detection OK to trigger reload, cancelled if "--- Running" arrives.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	dag/main.yml
#	etl/command.py
- Read slug from YAML instead of deriving from filename
- Build full catalogPath with version for mdim charts
- Use /admin/grapher/{encodedCatalogPath} URL for mdim
- Load mdim charts via direct iframe src (not embed script)
- Add vscode-extension-dev skill for build/install workflow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Marigold Marigold changed the base branch from wip-prototype-graph-metadata to master February 14, 2026 14:44
Marigold and others added 7 commits February 23, 2026 11:09
- New `chart-preview.dataset` command (cmd+shift+v) shows indicator cards
  with per-indicator metadata, stats, sparklines, and quality flags
- Per-indicator cards: title, unit, dtype, null%, min/max/mean, sparklines
  (numeric) or top-10 value distribution (string columns)
- Sparklines show per-entity time series (up to 50 entities, 200 points)
- Quality flags: missing title, unit, description, origins
- Tracks in-flight Python processes; kills on panel close/new run/deactivate
- 10-minute timeout on preview script
- Caps indicators at 200 for wide datasets (e.g. WDI ~1500 cols)
- Uses PREFER_DOWNLOAD=1 and STAGING=1 env vars on watch processes
- Friendly error/retry UI when dataset not yet built

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- etl/command.py: print '--- Dataset rebuild complete' sentinel after
  every successful watch cycle so the extension has a reliable trigger
- Extension: replace fragile stdout parsing + filesystem polling with
  single sentinel line detection; handles any number of upstream deps
- Unify cmd+alt+p keybinding for both chart and dataset preview,
  dispatching based on file type (.chart.yml vs steps/data/*.py)
- Fix random entity selection using crypto.getRandomValues()
- Fix feather file path (dataset_path/table.feather not subdir)
- Use pyarrow column projection for fast feather reads (WDI: 67s→1.3s)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unused existsSync import
- Remove redundant args/command aliases in startWatchProcess
- Use crypto.getRandomValues consistently in randomizeEntity

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Restore `command` variable in startWatchProcess (was lost in cleanup, caused "command is not defined" for multidim previews)
- Reset recentOutput at start of each new detecting cycle so errors from previous cycles don't bleed into subsequent runs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Show a small ★ score next to the type chip for indicators with
non-zero popularity from analytics_popularity. Also fix popularity
key to include namespace (namespace/dataset/table#col) so it
correctly matches across dataset versions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move `import rdata` inside each function body so it's only required
when actually reading R data files, not at module load time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Marigold
Copy link
Collaborator Author

Some parts of this were already merged, but we need to wait for the support of chart configs. Then we should rebase.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants