Skip to content

Add syrupy snapshot verification with manually triggered CI job#189

Open
ndaelman-hu wants to merge 48 commits into
developfrom
test/pr170-syrupy-verification
Open

Add syrupy snapshot verification with manually triggered CI job#189
ndaelman-hu wants to merge 48 commits into
developfrom
test/pr170-syrupy-verification

Conversation

@ndaelman-hu

Copy link
Copy Markdown
Collaborator

Purpose

Add the snapshot-testing setup used to verify the PR #170 parser migration as a permanent, on-demand regression harness. Snapshot comparison against a tracked baseline caught several regressions the regular test suite missed (GPAW occupations, Octopus model_system, VASP SelfConsistency threshold, QE per-step total_forces).

Scope

Included

  • tests/parsers/test_migration_snapshots.py: one syrupy snapshot test per parser (15 tests, 14 parsers) serializing archive.data
  • Tracked .ambr snapshots: current expected output plus the pre-migration baseline (commit 1c7acd6), ~48 MB under tests/ (not shipped in wheels; src/-only packaging)
  • New workflow_dispatch CI job (.github/workflows/snapshot-tests.yml) running the snapshot suite on demand; the default test run keeps ignoring it
  • syrupy added to the dev extra

Out of scope

Context & Links

Reviewer Notes

Snapshots regenerate with pytest tests/parsers/test_migration_snapshots.py --snapshot-update. The baseline .ambr regenerates byte-identically from a worktree at 1c7acd6.

Status

  • Ready for review

Breaking Changes

  • None

Dependencies / Blockers

  • External dependencies (explain): nomad-FAIR MR 3103 (snapshot ordering determinism)

Testing / Validation

  • Unit tests
  • Manual testing (explain): snapshot suite passes 15/15 deterministically across consecutive runs; structural additivity check against the baseline reports zero removals

JFRudzinski and others added 18 commits May 12, 2026 16:32
remove spurious `return`

Co-authored-by: Esma B. Boydas <80156958+EBB2675@users.noreply.github.com>
- Extract both eigenvalues and occupations with schema-conformant field
  names (`value`, `occupation`, `n_levels`)
- Handle non-spin-polarized arrays by adding an explicit spin dimension;
  set `spin_channel` only for spin-polarized calculations
- Guard against missing eigenvalue or occupation arrays
- `get_systems` accepts dict, list, or None sources and always includes
  the initial system, so `model_system` is populated for static runs
  without minimization data
- Read geometry optimization steps defensively: a missing or unreadable
  `geom/go.*.xyz` file logs a warning instead of aborting the parse
- Inject `_initial_system` into the text parser data in
  `write_to_archive` so the mapping can resolve it
- Add `get_initial_system_for_mapping` fallback accessor
…alues`

- Replace mappings to the non-existent `threshold_change_unit` field
  with `unit='eV'` on the `threshold_change` annotations, fixing an
  AttributeError while keeping the EDIFF convergence threshold
- Revert eigenvalue output from `electronic_band_structures` to
  `electronic_eigenvalues`; drop the corresponding
  `get_band_structures` mappings
- Use schema-conformant eigenvalue payload keys in both OUTCAR and XML
  parsers (`value`, `occupation`, `n_levels`; drop `npoints`)
- Update VASP tests to assert on `electronic_eigenvalues` including
  `occupation`
- Add `get_configuration_forces` helper to `PWSCFMainfileTextParser`,
  index-aligned with `get_configurations`, collecting per-SCF-step
  forces for multi-step runs (geometry optimization, molecular dynamics)
- Populate `Outputs.total_forces` via writer-side fallback in
  `parse_program`: the step-resolved forces were lost when
  `get_configurations` started returning only the final SCF step, and
  mapping-driven payload injection does not reach `archive.data` (same
  limitation as the electronic-properties fallback, see
  TODO(mapping-migration) markers)
- Hoist the configuration methods dict to `_configuration_methods` so
  both helpers iterate identically
- `test_migration_snapshots.py`: one snapshot test per parser (15 tests,
  14 parsers), serializing `archive.data` via `m_to_dict(with_meta=False)`
- `baseline_1c7acd6_snapshots.ambr`: parser output captured at
  pre-migration commit 1c7acd6; regeneration in a worktree at that commit
  reproduces it byte-identically
- `test_migration_snapshots.ambr`: current expected output; migration is
  additive w.r.t. the baseline (zero removals under structural comparison,
  list reordering tolerated)
- Add `syrupy` dev dependency
- Include verification report
The snapshot suite is a development-time verification harness; CI does
not install the `dev` dependency group (syrupy), so the `snapshot`
fixture is unavailable there.
- New `workflow_dispatch` workflow runs
  `tests/parsers/test_migration_snapshots.py` on demand
- Move `syrupy` into the `dev` extra so the standard
  `uv pip install -e '.[dev,md]'` install provides the `snapshot`
  fixture; drop the `[dependency-groups]` block that CI never installed
- The default test run keeps ignoring the snapshot suite
ndaelman-hu added a commit that referenced this pull request Jul 6, 2026
Fix parser data loss found by migration snapshot verification (#189)

- GPAW: extract occupations alongside eigenvalues, schema-conformant field names
- Octopus: populate `model_system` for static calculations
- VASP: fix `SelfConsistency.threshold_change` mapping; revert to `electronic_eigenvalues`
- QE: restore per-step `total_forces` for multi-step runs
@ndaelman-hu ndaelman-hu changed the base branch from fix/pr170-parser-corrections to develop July 6, 2026 08:47
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