Skip to content

Make chart data generation reproducible - #54

Merged
fsargent merged 2 commits into
mainfrom
codex/p1-reproducible-charts
Jul 17, 2026
Merged

Make chart data generation reproducible#54
fsargent merged 2 commits into
mainfrom
codex/p1-reproducible-charts

Conversation

@fsargent

@fsargent fsargent commented Jul 14, 2026

Copy link
Copy Markdown
Member

Closes #20.

Adds a documented full-results generator for the chart analysis and changes vseCheck.R to accept the generated CSV path explicitly. Generated simulation output remains untracked.

Validation:

  • uv run python scripts/generate_published_results.py --elections 1 --output /tmp/vse-published-smoke
  • uv run python -m pytest -q

Summary by Sourcery

Make chart analysis data generation reproducible by introducing a scripted CSV generator and updating the R analysis to consume an explicit results file path.

New Features:

  • Add a Python script to generate the full simulation CSV used by the published chart analysis with configurable elections, seed, and output prefix.

Enhancements:

  • Update the R-based chart analysis to accept a results CSV path via command-line arguments instead of relying on a hardcoded filename.

Documentation:

  • Add a chart reproduction guide documenting how to generate the published results CSV and run the historical R analysis.
  • Update the README to point to the chart reproduction guide for generating the chart simulation data.

Summary by CodeRabbit

  • New Features
    • Added a command-line tool to generate the full simulation CSV used for chart analysis, with configurable elections count, seed, and output location.
    • Updated chart analysis to take the input CSV path as a runtime argument (instead of using a fixed file).
  • Documentation
    • Added a chart reproduction guide explaining how to regenerate the published charts and produce the full simulation CSV.
    • Updated the README to link to the guide.
  • Chores
    • Adjusted the CI trunk check configuration to run without post-annotation posting.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36694a0d-ca11-4d60-9e0e-2579b946ae62

📥 Commits

Reviewing files that changed from the base of the PR and between d999795 and 9586713.

📒 Files selected for processing (1)
  • .github/workflows/trunk.yml
💤 Files with no reviewable changes (1)
  • .github/workflows/trunk.yml

📝 Walkthrough

Walkthrough

The change adds a documented Python workflow for generating the chart-analysis simulation CSV, updates vseCheck.R to accept a supplied CSV path, and removes trunk-action post-annotation configuration.

Changes

Chart reproduction workflow

Layer / File(s) Summary
Generate published results
scripts/generate_published_results.py, docs/chart-reproduction.md, README.md
Adds a configurable CsvBatch generation script and documents its command, output location, CSV metadata, and analysis workflow.
Analyze a supplied CSV
vseCheck.R
Replaces the hardcoded input with validated command-line path handling and updates a nearby comment.

Workflow checks

Layer / File(s) Summary
Adjust trunk check configuration
.github/workflows/trunk.yml
Removes post-annotations: true from the trunk action configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant generate_published_results.py
  participant CsvBatch
  participant OutputCSV
  participant vseCheck.R
  User->>generate_published_results.py: Run with elections, seed, and output path
  generate_published_results.py->>CsvBatch: Configure and execute batch
  CsvBatch->>OutputCSV: Write simulation CSV
  User->>vseCheck.R: Pass CSV path as one argument
  vseCheck.R->>OutputCSV: Read supplied CSV
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR provides an equivalent reproducible CSV workflow, but the summary doesn't confirm the requested R package installation guidance. Confirm the docs include R package installation steps and chart customization guidance, or add them if missing.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: making chart data generation reproducible.
Out of Scope Changes check ✅ Passed The changes stay focused on reproducible chart data generation, documentation, and the related R script workflow.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/p1-reproducible-charts

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

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Make chart analysis data generation reproducible by adding a Python results generator script, wiring the R visualization to accept an explicit CSV path, and documenting the chart reproduction workflow.

Sequence diagram for reproducible chart data generation and analysis

sequenceDiagram
    actor User
    participant PythonScript as generate_published_results.py
    participant CsvBatch
    participant RScript as vseCheck.R
    participant fread as data.table_fread

    User->>PythonScript: python scripts/generate_published_results.py --elections 15000 --output artifacts/published-results
    PythonScript->>CsvBatch: CsvBatch(KSModel, allSystems, niter, baseName, seed)
    CsvBatch-->>PythonScript: output_file
    PythonScript-->>User: print(output_file)

    User->>RScript: Rscript vseCheck.R PATH_TO_RESULTS.csv
    RScript->>RScript: commandArgs(trailingOnly=TRUE)
    RScript->>fread: fread(PATH_TO_RESULTS.csv)
    fread-->>RScript: fvse data
    RScript-->>User: charts from honestScenarios2
Loading

File-Level Changes

Change Details Files
Require vseCheck.R to consume an explicit CSV file path from the command line instead of a hard-coded filename.
  • Parse trailing command-line arguments via commandArgs
  • Validate that exactly one argument is provided and error with a usage string otherwise
  • Read the simulation results CSV using the provided path instead of a fixed filename
vseCheck.R
Introduce a Python script to generate the full published-results simulation CSV used by the charts.
  • Add an argparse-based CLI with elections count, seed, and output prefix options
  • Wire in existing simulation primitives (KSModel, allSystems, CsvBatch, fuzzyMediaFor) to run the batch with chart settings
  • Ensure output directory creation and print the final generated CSV filename
  • Disable debug logging and configure CsvBatch to overwrite and avoid retaining individual rows
scripts/generate_published_results.py
Document the workflow for reproducing chart data and using the R analysis on generated results.
  • Add a README pointer to the chart reproduction documentation
  • Create a chart-reproduction guide that shows the exact Python and R commands to generate and analyze the CSV
  • Clarify that the generated CSV is not committed and note the metadata recorded in its header
README.md
docs/chart-reproduction.md

Assessment against linked issues

Issue Objective Addressed Explanation
#20 Provide a reproducible data source (instead of the missing target4.csv/target3.csv) so that vseCheck.R can run successfully.
#20 Document how to reproduce the chart data and run vseCheck.R, including required packages and how to pass the CSV input.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@fsargent
fsargent marked this pull request as ready for review July 14, 2026 19:51

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In vseCheck.R, consider allowing additional arguments or using a named flag instead of enforcing exactly one positional argument, so future extensions to the script’s CLI don’t break the usage check.
  • In generate_published_results.py, the --seed parameter defaults to a string like target15000; clarifying in the help text how this seed is interpreted (and how to choose alternative seeds) would make reproducibility behavior more transparent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `vseCheck.R`, consider allowing additional arguments or using a named flag instead of enforcing exactly one positional argument, so future extensions to the script’s CLI don’t break the usage check.
- In `generate_published_results.py`, the `--seed` parameter defaults to a string like `target15000`; clarifying in the help text how this seed is interpreted (and how to choose alternative seeds) would make reproducibility behavior more transparent.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
vseCheck.R (1)

142-142: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Address the truncated comment.

This comment appears to end abruptly ("but it's a)"). Consider completing the sentence or removing it if the thought is no longer relevant.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vseCheck.R` at line 142, Update the truncated comment near the
strategy-refinement note so it forms a complete, clear sentence, or remove it if
the thought is no longer relevant; do not leave the unfinished “but it’s a)”
text.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@vseCheck.R`:
- Line 142: Update the truncated comment near the strategy-refinement note so it
forms a complete, clear sentence, or remove it if the thought is no longer
relevant; do not leave the unfinished “but it’s a)” text.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f499fea2-1661-46cb-a943-b75b3d21b657

📥 Commits

Reviewing files that changed from the base of the PR and between 40fec52 and d999795.

📒 Files selected for processing (4)
  • README.md
  • docs/chart-reproduction.md
  • scripts/generate_published_results.py
  • vseCheck.R

Co-authored-by: Cursor <cursoragent@cursor.com>
@fsargent
fsargent merged commit 4820ee4 into main Jul 17, 2026
5 checks passed
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.

Add target4.csv; Document vseCheck.R

1 participant