-
Notifications
You must be signed in to change notification settings - Fork 0
Add deterministic reproducibility test for layered admissibility artifact #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||||||||||||||||
| from collections.abc import Callable | ||||||||||||||||||||||||||||||||||||||||||||||||||
| from dataclasses import dataclass | ||||||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| from scripts.generate_layered_admissibility_artifact import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| generate_layered_admissibility_artifact, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @dataclass(frozen=True) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| class DeterministicArtifactSpec: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| """Configuration for a reproducible committed artifact check.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| name: str | ||||||||||||||||||||||||||||||||||||||||||||||||||
| committed_path: Path | ||||||||||||||||||||||||||||||||||||||||||||||||||
| regenerate: Callable[[Path], Path] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ARTIFACT_SPECS: tuple[DeterministicArtifactSpec, ...] = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| DeterministicArtifactSpec( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| name="layered_admissibility_results", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| committed_path=Path("artifacts/layered_admissibility_results.json"), | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| regenerate=generate_layered_admissibility_artifact, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| def _load_json(path: Path) -> object: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return json.loads(path.read_text(encoding="utf-8")) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_committed_deterministic_artifacts_are_reproducible(tmp_path: Path) -> None: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| for spec in ARTIFACT_SPECS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| regenerated_path = tmp_path / spec.committed_path.name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| spec.regenerate(regenerated_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| regenerated_payload = _load_json(regenerated_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| committed_payload = _load_json(spec.committed_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| assert regenerated_payload == committed_payload, ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| f"Deterministic artifact drift detected for '{spec.name}'. " | ||||||||||||||||||||||||||||||||||||||||||||||||||
| f"Regenerate with: python scripts/generate_layered_admissibility_artifact.py" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor the test to use
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import
pytestand defineREPO_ROOTto allow for robust path resolution relative to the repository structure, ensuring tests are runnable from any directory.