tests: check that client and server schemas match#1192
Open
HirenGajjar wants to merge 1 commit into
Open
Conversation
Add 15 parametrized tests across EmissionBase, RunBase, ExperimentBase, ProjectBase and OrganizationBase that verify the client (codecarbon/core/schemas.py) and server (carbonserver/carbonserver/api/schemas.py) schemas are compatible. Tests check: - All client fields exist in the server schema - All required server fields exist in the client schema - Shared fields have wire-compatible types Uses ast to parse schema files without importing either module, so the test runs in the client test environment with no extra deps. This would have caught the on_cloud: str vs bool mismatch fixed in mlco2#1189. Closes mlco2#1190
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a test suite that verifies the client (
codecarbon/core/schemas.py) and server (carbonserver/carbonserver/api/schemas.py) schemas stay compatible, addressing #1190.What it checks
For each shared model pair (
EmissionBase,RunBase,ExperimentBase,ProjectBase,OrganizationBase) — 15 parametrized tests total:Why
astinstead of importsThe client and server live in separate
uvenvironments. Using Python'sastmodule to parse schema files as source avoids any import or path issues — the test runs in the existing client test environment with zero extra dependencies.Regression proof
This test catches the exact bug fixed in #1189. Temporarily changing
on_cloud: Optional[bool]toOptional[str]on the server produces:Related Issue
Closes #1190
Types of changes
AI Usage Disclosure
Checklist