-
Notifications
You must be signed in to change notification settings - Fork 1
Codecarbon integration #154
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #154 +/- ##
============================================
+ Coverage 81.85% 83.05% +1.20%
Complexity 22 22
============================================
Files 9 11 +2
Lines 1521 1629 +108
Branches 56 56
============================================
+ Hits 1245 1353 +108
Misses 232 232
Partials 44 44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mam10eks
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.
Looks good to me, the only question that I have: should we use the offline emission tracker?
| # Start the CodeCarbon tracking, if available. | ||
| if CODECARBON_INSTALLED: | ||
| if codecarbon_tracker is None: | ||
| codecarbon_tracker = EmissionsTracker() |
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.
Does this need an internet connection? There was, if I recall correctly, also an offline tracker? We would need the offline tracker here, so that things are directly compatible with tira, which would be very helpful :)
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.
Users can override the CodeCarbon tracker and use the offline variant, e.g., with:
with tirex_tracker.tracking(
codecarbon_tracker=codecarbon.OfflineEmissionsTracker(country_iso_code="GER"),
) as results:
# Do stuffThat code would fully work offline.
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.
But this is super complicated?
Can we maybe go into the direction that Tim mentioned below, to not report the CO2 emissions? And rather the raw energy? That would be the more clean way, as one could do the math to calculate the emissions later.
| _PYTHON_MEASURES = { | ||
| **_PYTHON_MEASURES, | ||
| Measure.CODECARBON_EMISSIONS: MeasureInfo( | ||
| description="CO2 emissions in kg, as measured by CodeCarbon.", |
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.
We could instead (or additionally) report the energy itself since the estimated emissions are only the energy usage multiplied by the carbon intensity of the local energy mix. Alternatively, (and I don't know if the Codecarbon API makes this available), we could report Carbon intensity and energy usage and the user can multiply them themselves for the estimated emissions.
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.
I think this would be a good option.
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.
This would also resolve the country-code thing above, or?
This PR integrates a Python-specific
CODECARBON_EMISSIONSmeasure, which, if CodeCarbon is installed, tracks the carbon emissions using CodeCarbon. This third-party measure might be used to compare results from different tracking backends.