Skip to content

Record a format version in AuditResults.to_dict() - #132

Merged
SushantGautam merged 1 commit into
SimulaMet:mainfrom
avalyset:feat/audit-results-format-version
Nov 3, 2026
Merged

SushantGautam merged 1 commit into
SimulaMet:mainfrom
avalyset:feat/audit-results-format-version

Conversation

@avalyset

Copy link
Copy Markdown
Contributor

#114 asks for the export format to be versioned on purpose: RepeatedExperimentResults.to_dict() writes "version": "1.0", but AuditResults.to_dict() writes no version, so a downstream converter reading a saved single run cannot tell which shape it has.

This adds "version": "1.0" as the first key of AuditResults.to_dict(), so save() writes it too. AuditResults.load() reads only results and timestamp, so files written before this still load. This covers the first point of #114 only; the second (calling out export-shape changes in release notes) is for the release process, not code.

The new test TestSaveLoadRoundTrip::test_saved_json_carries_format_version in tests/test_audit_flow.py checks the key in to_dict() and in the saved file, and that a file without the key still loads. pytest -n auto (no API keys in the environment) gave 1 failed (the new test), 1861 passed, 4 skipped on main, and 1862 passed, 4 skipped with the change; ruff check --select E9,F821 . is clean.

Design questions:

  • Each run nested in a RepeatedExperimentResults export now also carries "version": "1.0", and both document types say "1.0", so the number alone does not tell a converter which document it holds. Would you rather name the key format_version, or add a field naming the document type?
  • Should RepeatedExperimentResults move to "1.1", since its nested runs gained a key?

AI disclosure: implemented with Claude Code.

RepeatedExperimentResults already writes "version": "1.0"; a single
run's export had no version, so a consumer of the saved JSON could not
tell which shape it was reading. Add the same key to AuditResults. load()
does not read it, so files written before it still load.
@SushantGautam
SushantGautam merged commit 3dee975 into SimulaMet:main Nov 3, 2026
8 checks passed
avalyset pushed a commit to avalyset/simpleaudit that referenced this pull request Nov 4, 2026
Record a format version in AuditResults.to_dict()
@avalyset
avalyset deleted the feat/audit-results-format-version branch November 4, 2026 17:54
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