Skip to content

tests: check client server schema compatibility#1207

Merged
benoit-cty merged 1 commit into
mlco2:masterfrom
puneetdixit200:tests/schema-compatibility
May 20, 2026
Merged

tests: check client server schema compatibility#1207
benoit-cty merged 1 commit into
mlco2:masterfrom
puneetdixit200:tests/schema-compatibility

Conversation

@puneetdixit200
Copy link
Copy Markdown
Contributor

@puneetdixit200 puneetdixit200 commented May 20, 2026

Description

Adds a focused API test that compares the client-side create dataclasses in codecarbon/core/schemas.py with the server-side Pydantic create schemas in carbonserver. 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 wue stay 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.py
  • uv run --group dev python -m pytest -q tests/test_api_call.py
  • uv 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.py
  • uv 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.py

Screenshots (if appropriate):

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

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.

  • 🟥 AI-vibecoded: You cannot explain the logic. Car analogy : the car drive by itself, you are outside it and just tell it where to go.
  • 🟠 AI-generated: Car analogy : the car drive by itself, you are inside and give instructions.
  • ⭐ AI-assisted. Car analogy : you drive the car, AI help you find your way.
  • ♻️ No AI used. Car analogy : you drive the car.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the docs/how-to/contributing.md document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@puneetdixit200 puneetdixit200 requested a review from a team as a code owner May 20, 2026 15:33
@benoit-cty benoit-cty force-pushed the tests/schema-compatibility branch from 0fce0bb to dedca17 Compare May 20, 2026 16:23
@benoit-cty
Copy link
Copy Markdown
Contributor

Thanks that's a great improvement.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.92%. Comparing base (d2ce064) to head (dedca17).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benoit-cty benoit-cty merged commit a88000f into mlco2:master May 20, 2026
15 checks passed
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.

tests: check that client and server schemas match

2 participants