-
-
Notifications
You must be signed in to change notification settings - Fork 237
Switch from CO2Signal to ElectricityMaps #980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Backward Compatibility for CO2 Signal → Electricity Maps MigrationSummaryThe API formerly known as CO2 Signal has been rebranded to Electricity Maps, and their API has been updated from v1 to v3. To maintain backward compatibility while adopting the new naming, we've implemented the following changes: Parameter Renaming
Backward Compatibility Features1. Parameter AliasesThe old parameter name # Both work, but the old name emits a deprecation warning
tracker = EmissionsTracker(co2_signal_api_token="your-token") # Deprecated
tracker = EmissionsTracker(electricitymaps_api_token="your-token") # Recommended2. Configuration File SupportConfiguration files can use either the old or new parameter name: [codecarbon]
# Old name (deprecated, but still works)
co2_signal_api_token=your-token
# New name (recommended)
electricitymaps_api_token=your-token3. Deprecation WarningsWhen using the old parameter name, a warning is logged: Migration GuideFor UsersNo immediate action required. Your existing code will continue to work, but you'll see deprecation warnings. To migrate:
Example migration: # Before
from codecarbon import EmissionsTracker
tracker = EmissionsTracker(
co2_signal_api_token="your-token"
)
# After
from codecarbon import EmissionsTracker
tracker = EmissionsTracker(
electricitymaps_api_token="your-token"
)For DevelopersWhen both old and new parameters are provided:
Implementation details:
Timeline
TestingBackward compatibility is tested in:
Run tests with: uv run pytest tests/test_backward_compatibility.py tests/test_config_backward_compatibility.py -v |
eb76fc1 to
ddf11d2
Compare
ddf11d2 to
85eca64
Compare
inimaz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks @benoit-cty . This will update it so users can input the new electricity maps token.
Some minor comments on the tests. But other than that great!
Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com>
Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com>
Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com>
Co-authored-by: inimaz <49730431+inimaz@users.noreply.github.com>
…rbon into fix/979_electricitymaps_api
inimaz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!

Description
CO2 Signal was the previous name of Electricity Maps API. The url https://api.co2signal.com/v1/latest is no longer working so we need to migrate.
Related Issue
Please link to the issue this PR resolves: #979
Motivation and Context
The url https://api.co2signal.com/v1/latest is no longer working
How Has This Been Tested?
Use a test token.
Types of changes
What types of changes does your code introduce? Put an
xin all the boxes that apply:Checklist:
Go over all the following points, and put an
xin all the boxes that apply.