tests: check client server schema compatibility#1207
Merged
benoit-cty merged 1 commit intoMay 20, 2026
Conversation
0fce0bb to
dedca17
Compare
Contributor
|
Thanks that's a great improvement. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1207 +/- ##
==========================================
+ Coverage 88.88% 88.92% +0.03%
==========================================
Files 45 45
Lines 4302 4306 +4
==========================================
+ Hits 3824 3829 +5
+ Misses 478 477 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
benoit-cty
approved these changes
May 20, 2026
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 focused API test that compares the client-side create dataclasses in
codecarbon/core/schemas.pywith the server-side Pydantic create schemas incarbonserver. The test also validates representative client payloads against the server schemas.The change includes the currently missing emission fields in the client schema and API payload so utilization metrics and
wuestay compatible with the server schema.Related Issue
Closes #1190
Motivation and Context
The client and server define parallel schemas for API communication. If the two drift, the client can silently stop sending fields that the server accepts. This test would have caught the recent schema mismatch mentioned in the issue.
How Has This Been Tested?
uv run --project carbonserver --extra dev python -m pytest -q carbonserver/tests/api/test_schema_compatibility.pyuv run --group dev python -m pytest -q tests/test_api_call.pyuv run --group dev black --check carbonserver/tests/api/test_schema_compatibility.py codecarbon/core/api_client.py codecarbon/core/schemas.py tests/test_api_call.pyuv run --group dev ruff check carbonserver/tests/api/test_schema_compatibility.py codecarbon/core/api_client.py codecarbon/core/schemas.py tests/test_api_call.pyScreenshots (if appropriate):
Not applicable.
Types of changes
AI Usage Disclosure
Please refer to docs/how-to/ai-policy.md for detailed guidelines on how to disclose AI usage in your PR. Accurately completing this section is mandatory.
Checklist: