Skip to content

test: integrate pyhs3 with HS3TestSuite#283

Open
Phmonski wants to merge 1 commit into
scipp-atlas:mainfrom
Phmonski:feat/hs3-test-suite
Open

test: integrate pyhs3 with HS3TestSuite#283
Phmonski wants to merge 1 commit into
scipp-atlas:mainfrom
Phmonski:feat/hs3-test-suite

Conversation

@Phmonski

@Phmonski Phmonski commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR integrates pyhs3 with the external HS3TestSuite, providing a direct comparison against the frozen RooFit reference results stored in the suite.

The integration uses a new backend adapter owned and maintained by pyhs3.

Motivation

ROOT already runs HS3TestSuite against RooFit. Adding the same suite to pyhs3 makes it possible to:

  • Compare RooFit and pyhs3 using identical HS3 documents, scan points, tolerances, and reference values.
  • Track which parts of the HS3 specification pyhs3 currently supports.
  • Detect regressions in already-supported functionality.
  • Identify when an unsupported test starts passing.
  • Review compatibility changes deliberately as the HS3 specification and test suite evolve.

Implementation

This PR adds:

  • A pyhs3-owned HS3TestSuite backend adapter.
  • Manifest-driven pytest cases for every fixture and check in the pinned suite.
  • Exact verification of the upstream commit and manifest digest before loading the suite.
  • A strict known-failure ledger for currently unsupported functionality.
  • Stable failure-stage classification, distinguishing failures during workspace import, evaluation, and numerical comparison.
    JSON, Markdown, and JUnit compatibility reports.
  • A dedicated GitHub Actions job that checks out the exact suite revision and uploads the reports.
  • A candidate-audit command and documentation for deliberately updating the suite pin.

The adapter loads each HS3 workspace with pyhs3, performs the requested structure checks, constructs the corresponding likelihood, and evaluates the twice-delta-NLL scans using public PyTensor APIs.

Current compatibility

The pinned suite contains 56 checks across 19 fixtures. Current pyhs3 results are:

  • 31 passing checks
  • 25 strict expected failures

Expected failures currently cover unsupported HS3 functions and distributions, one multidimensional evaluation issue, and one numerical mismatch. The expected failures are strict: if one starts passing, CI fails until its ledger entry is deliberately removed. CI also fails if a known failure changes stage—for example, if a numerical mismatch regresses into a workspace-import failure.

Pinning and update policy

HS3TestSuite is pinned to:
9d04e321ae6fddd283a35507f14ecf852eb7df61
The pin is intentionally not updated automatically. Updating it requires reviewing changes to:

  • HS3 schemas and fixtures
  • Check identifiers and feature tags
  • RooFit reference vectors
  • Scan points and tolerances
  • Passing and failing pyhs3 checks
  • Known-failure reasons and stages

A candidate revision can be audited without changing the tracked pin:

pixi run -e py312 python tools/audit_hs3testsuite.py \
    --suite-root /path/to/HS3TestSuite \
    --output-dir /tmp/pyhs3-hs3-audit

The resulting reports identify the candidate commit and manifest digest while leaving normal CI pin enforcement unchanged.

Testing

Validated locally with:

pixi run -e py312 test-hs3suite
pytest tests/test_hs3testsuite_backend.py

Results:

HS3TestSuite integration: 36 harness passes and 25 strict xfails
Raw HS3 compatibility: 31 passes and 25 known failures
Adapter unit tests: 8 passes
Ruff and configuration validation pass
Documentation doctests pass

Summary by CodeRabbit

  • New Features

    • Added HS3TestSuite conformance testing for validating compatibility with reference results.
    • Added automated CI execution with JUnit reports, summaries, and downloadable test artifacts.
    • Added a command-line audit tool for evaluating candidate test-suite revisions.
    • Added pinned-suite tracking and a documented known-failure ledger.
  • Documentation

    • Documented local HS3TestSuite validation, CI reporting, pinning, and regression expectations.
  • Bug Fixes

    • Improved test-hook exclusions for HS3 conformance tests.

@Phmonski
Phmonski requested a review from kratsg as a code owner July 21, 2026 13:08
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

The PR adds pinned HS3TestSuite conformance testing, a pyhs3 backend adapter, result and known-failure validation, audit tooling, CI execution with report artifacts, test dependencies, and testing documentation.

HS3TestSuite Conformance

Layer / File(s) Summary
Implement pyhs3 backend
tests/hs3testsuite_pyhs3_backend.py, tests/test_hs3testsuite_backend.py
Adds workspace loading, structure checks, twice-delta-NLL evaluation, staged failures, input validation, and backend unit tests.
Pin and validate suite results
tests/hs3testsuite/*, tests/test_hs3testsuite.py
Pins the external suite and manifest, registers the backend, executes manifest checks, validates known failures and statuses, and writes JSON/Markdown reports.
Run and publish conformance audits
tools/audit_hs3testsuite.py, .github/workflows/ci.yml, pixi.toml, pyproject.toml, .pre-commit-config.yaml, docs/testing.rst
Adds candidate-checkout auditing, test task and dependency wiring, CI report publication, pre-commit exclusions, and conformance documentation.

Possibly related issues

  • scipp-atlas/pyhs3#250 — Directly covers the HS3TestSuite integration implemented by this PR.

Suggested reviewers: kratsg, kratsg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.62% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 summarizes the main change: integrating pyhs3 with HS3TestSuite.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (0425965) to head (7f9d170).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #283   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           39        39           
  Lines         2917      2917           
  Branches       349       349           
=========================================
  Hits          2917      2917           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 140-142: Update the primary actions/checkout step in the CI job to
set persist-credentials to false, matching the existing external-repository
checkout configuration; leave the separate action hash-pinning concern
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 79734c13-8e04-4b97-a4de-b157062145e2

📥 Commits

Reviewing files that changed from the base of the PR and between 0425965 and 7f9d170.

📒 Files selected for processing (11)
  • .github/workflows/ci.yml
  • .pre-commit-config.yaml
  • docs/testing.rst
  • pixi.toml
  • pyproject.toml
  • tests/hs3testsuite/known_failures.json
  • tests/hs3testsuite/pin.json
  • tests/hs3testsuite_pyhs3_backend.py
  • tests/test_hs3testsuite.py
  • tests/test_hs3testsuite_backend.py
  • tools/audit_hs3testsuite.py

Comment thread .github/workflows/ci.yml
Comment on lines +140 to +142
- uses: actions/checkout@v7
with:
fetch-depth: 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Set persist-credentials: false on the primary checkout too.

This job's second checkout (145-150, external HS3TestSuite) already sets persist-credentials: false, but the first checkout of the PR's own repo (140-142) doesn't, despite this job also pulling in a third-party repository into the same workspace. actions/checkout v7 now stores persisted credentials outside .git/config, which reduces the practical exposure, but matching the sibling step's setting is still cheap defense-in-depth.

🔒 Proposed fix
       - uses: actions/checkout@v7
         with:
           fetch-depth: 0
+          persist-credentials: false

Separately, zizmor also flags actions/checkout@v7, setup-pixi@v0.10.0, and actions/upload-artifact@v7 here as unpinned-to-hash — this simply mirrors the existing convention used throughout the rest of this workflow file (e.g. lines 24, 98, 122), so it's better addressed as a repo-wide hash-pinning initiative rather than only in this new job.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
🧰 Tools
🪛 zizmor (1.26.1)

[warning] 140-142: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 140-140: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 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 @.github/workflows/ci.yml around lines 140 - 142, Update the primary
actions/checkout step in the CI job to set persist-credentials to false,
matching the existing external-repository checkout configuration; leave the
separate action hash-pinning concern unchanged.

Source: Linters/SAST tools

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.

1 participant