Skip to content

Add versioned benchmark JSON schema validation (v1) - #10

Open
faizan-7890 wants to merge 3 commits into
DaBestCode:mainfrom
faizan-7890:feat/benchmark-schema-v1
Open

Add versioned benchmark JSON schema validation (v1)#10
faizan-7890 wants to merge 3 commits into
DaBestCode:mainfrom
faizan-7890:feat/benchmark-schema-v1

Conversation

@faizan-7890

Copy link
Copy Markdown

Fixes #3

Summary

This PR introduces schema-based validation for benchmark result JSON files.

Changes

  • Added a Draft 2020-12 JSON schema:
    • schemas/benchmark-v1.schema.json
  • Added schema validation tests:
    • tests/test_benchmark_schema.py
    • validates the checked-in Qwen3 microbenchmark result file against schema v1
    • includes parameterized negative tests to ensure required fields are enforced
  • Documented schema/version compatibility expectations in benchmark results docs (if applicable in this branch)

Schema/versioning policy

  • Additive optional fields remain compatible within schema v1.
  • Removing or renaming fields requires a new schema version.
  • Semantic meaning changes to existing fields require a new schema version.

Validation run

  • ruff check .
  • ruff format --check .
  • mypy src
  • pytest -q

All checks pass locally.

Copilot AI lite review requested due to automatic review settings September 7, 2026 18:14

Copilot AI 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.

🟡 Changes recommended

The schema/tests do not currently enforce the required protocol field per Issue #3 acceptance criteria, so the validation guarantees are incomplete.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a versioned (v1) JSON Schema and pytest-based validation to make checked-in benchmark result JSON files machine-checkable and enforce required metadata fields.

Changes:

  • Introduces Draft 2020-12 JSON Schema for benchmark results (schema_version: 1).
  • Adds tests that validate the checked-in Qwen3 microbenchmark result file against the schema and exercise required-field failures.
File summaries
File Description
schemas/benchmark-v1.schema.json Adds the v1 JSON Schema definition for benchmark result files.
tests/test_benchmark_schema.py Adds pytest validation of the checked-in benchmark JSON against the schema plus negative required-field tests.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +7 to +23
"required": [
"schema_version",
"claim_scope",
"model",
"model_revision",
"device",
"runs",
"summary",
"kind",
"prompt_tokens",
"generated_tokens",
"warmup_tokens",
"trials",
"budget",
"buffer_size",
"seed"
],
Comment on lines +19 to +23
schema = load_json(SCHEMA_PATH)
data = load_json(QWEN_RESULT_PATH)
validator = Draft202012Validator(schema)
errors = sorted(validator.iter_errors(data), key=lambda e: list(e.path))
assert errors == [], [e.message for e in errors]
Comment thread tests/test_benchmark_schema.py Outdated
Comment on lines +26 to +42
REQUIRED_FIELDS = [
"schema_version",
"claim_scope",
"model",
"model_revision",
"device",
"runs",
"summary",
"kind",
"prompt_tokens",
"generated_tokens",
"warmup_tokens",
"trials",
"budget",
"buffer_size",
"seed",
]
@faizan-7890

Copy link
Copy Markdown
Author

Hi DaBestCode, could you please approve workflows for this PR? Thank you!

@faizan-7890

Copy link
Copy Markdown
Author

Addressed Copilot review feedback in latest commits:

  • Added required protocol field to schemas/benchmark-v1.schema.json
  • Added protocol to results/qwen3-0.6b-mps-microbenchmark.json
  • Added Draft202012Validator.check_schema(schema) in tests
  • Removed hardcoded required-fields list and now derive required keys from schema

Local checks pass:

  • ruff check .
  • ruff format --check .
  • mypy src
  • pytest -q

Could a maintainer please approve workflows so remaining CI can run? Thanks!

@faizan-7890

Copy link
Copy Markdown
Author

could a maintainer please approve workflows for this PR so CI can continue? Thank you!

@DaBestCode DaBestCode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for taking this on. The schema direction is useful, but this needs four focused fixes before merge:

  1. Please remove the newly added top-level protocol field from both the fixture and schema. The issue guidance explicitly defines the protocol through the existing required fields (kind, token counts, trials, budget, buffer, and seed) and asks not to change the producer format solely to add a key.
  2. Add jsonschema to the test extra in pyproject.toml. In a clean project environment, pytest -q currently fails during collection with ModuleNotFoundError: No module named 'jsonschema'.
  3. Add the schema compatibility policy to results/README.md: additive optional fields remain compatible within v1; removing/renaming fields or changing their semantic meaning requires a new schema version.
  4. Run ruff format on tests/test_benchmark_schema.py; ruff format --check . currently fails on the final assertion.

Verified locally: ruff check . and mypy src pass; formatting and pytest fail for the reasons above. Please rerun the complete CONTRIBUTING.md check list after updating.

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.

Validate benchmark JSON with a versioned schema

3 participants