Skip to content

refactor(report): build chart specs once in og-render - #537

Open
geiresx wants to merge 4 commits into
GeiserX:mainfrom
geiresx:pgp/port-report-charts
Open

geiresx wants to merge 4 commits into
GeiserX:mainfrom
geiresx:pgp/port-report-charts

Conversation

@geiresx

@geiresx geiresx commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The report's five charts (ClinVar stars, the genome ideogram, the heteroplasmic chrM sites, fine-grained ancestry and the PRS percentiles) are still built by bin/report_charts.py. The HTML report and the live page's charts plugin both read them from there. 1.0.0 ships with no owned Python, so the charts need a Rust builder before the reports can switch to og.

Fix

  • og report charts --summary summary.json --charts-json <sample>_charts.json builds the five chart specs and their inline SVG in og-render (rust/crates/og-render/src/charts/). The specs are built once: charts::json gives the live page's file, and charts::figure gives the line the HTML report puts under a section's caveat.
  • It reads the summary with Python's rules (an int stays an int, str(), int(), float(), Python's min and max), draws in Python's arithmetic order, and takes every caveat from og_render::notes by name. So it writes what bin/render_report.py --charts-json writes, byte for byte, and prints the same Sections: line. og report charts takes render_report.py's --summary and --charts-json; it does not take the report's other arguments (-o, --sample, --sample-dir and the rest).
  • The 5 MB floor of the genome chart is the roh section's own constant (og_summary ... roh::ROH_MIN_BP). The GRCh38 lengths are public (charts::GRCH38) for the live family page.
  • Checks 1 to 6 of tests/test_report_charts.py and the anchor of a hit past the table moved to rust/crates/og-render/tests/charts.rs (18 tests). They check og report charts. Each detector also runs on a broken input and must catch it. A frozen vector (FNV-1a of the oracle's charts JSON) holds the output to what bin/report_charts.py wrote at 65095e9, on the fixture and five changed copies.
  • tests/test_report_charts.py keeps the checks of what bin/render_report.py still ships, with their code unchanged:
    • check 7: the HTML report has no <script>, every href="#..." resolves to an id, each of the five charts sits once in its section below that section's caveat, and the hits table carries id="clinvar-hits" with at least 50 rows;
    • check 8: two renders of the demo give the same charts file apart from generated_utc, with its schema version and the five chart ids;
    • check 10: the live page in a browser.

No output changes: no step calls og report charts yet, and bin/render_report.py still writes the charts until the reports switch to og.

Decisions

  • Check 7 stays in Python. og report render does not embed the figures yet: wiring charts::figure into the section frames is a change to html.rs, outside this package. The lane that does it must port check 7 to its cargo tests, as the spec of where a figure goes.
  • The browser check stays in Python for now. It drives the Python live server, so it moves when the live server's charts plugin is ported. A Rust browser check of charts.js on og's file needs og-browser and og-render in one crate's dev-dependencies, and neither Cargo.toml is in this package's files.
  • The corpus parity is not a CI case yet. tests/parity/cases.tsv and oracle.ref are not in this package's files. The rows are mechanical, because the verb takes the oracle's own arguments: report-charts <case> gen:report-corpus.sh --summary <case>.json --charts-json <case>_charts.json <case>_charts.json json PYTHON_IMAGE, with the oracle row report-charts 65095e975bea01c74ed92a4f1b8c1bd00d05caaa file:bin/render_report.py sh ./oracle.sh report charts. Until they land, CI holds the parity on the 6 frozen summaries only.
  • Two docs still call the verb a stub, and both are outside this package's files. Follow-ups: drop og report charts from the stub list in docs/rust.md:45, and change rust/README.md:25 to say charts are ported (no caller yet).
  • Check 9 of the old file (og run delta sees no change for the added heteroplasmic_sites) is dropped. og run delta compares section states and the ClinVar, CPSR, CPIC, CYP2D6 and PRS data only, so no mito field can make a change.

How it was checked

Bead: D1

og report charts --summary IN --charts-json OUT writes what
bin/render_report.py --charts-json writes, byte for byte, and prints the
same Sections line, so both run with the same arguments. The specs are
built once (charts::build) for the HTML report (charts::figure) and the
live page (charts::json).

Bead: D1
Every non-browser check of tests/test_report_charts.py now runs on og
report charts in rust/crates/og-render/tests/charts.rs, each with its red
control, plus frozen hashes of the oracle's charts JSON on the fixture and
five changed copies. The Python file keeps only the live page's browser
check, which needs the Python live server.

Bead: D1
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fd81a5c and 497aecb.

Files selected for processing: 6

  • CHANGELOG.md
  • rust/crates/og-render/src/charts/build.rs
  • rust/crates/og-render/src/charts/mod.rs
  • rust/crates/og-render/src/charts/svg.rs
  • rust/crates/og-render/tests/charts.rs
  • tests/test_report_charts.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

… figures

Old checks 7 and 8 test what bin/render_report.py still ships: each chart once in its section below the caveat, every anchor resolving, and two renders giving the same charts file. og report render does not embed the figures yet, so they stay in Python until html.rs does. The charts.rs header and the changelog now say which checks moved.
@geiresx

geiresx commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

geiresx pushed a commit to geiresx/OwnGenome that referenced this pull request Nov 20, 2026
geiresx pushed a commit to geiresx/OwnGenome that referenced this pull request Nov 20, 2026
…rpus summaries

GeiserX#537 ported the charts but left its corpus rows out of the parity list, so CI
held the charts only on the six frozen summaries. One report-charts case per
report-render summary, compared as JSON, and the oracle row at 65095e9.
scripts/ci/oracle-diff.sh report-charts: all 616 items in 154 cases agree;
a planted key rename in og's charts file makes both cases it touches differ.
geiresx pushed a commit to geiresx/OwnGenome that referenced this pull request Nov 20, 2026
It writes the chart specs as render_report.py --charts-json does (GeiserX#537); no
step calls it yet.

This branch has not been deployed

No deployments
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.

2 participants