codecarbon 3.2.8__tar.gz → 3.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codecarbon-3.2.8 → codecarbon-3.3.0}/PKG-INFO +46 -16
- {codecarbon-3.2.8 → codecarbon-3.3.0}/README.md +45 -15
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/__init__.py +1 -1
- codecarbon-3.3.0/codecarbon/_version.py +1 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/main.py +79 -22
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/monitor.py +5 -4
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/api_client.py +55 -85
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/cpu.py +16 -3
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/emissions.py +4 -3
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu.py +17 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu_amd.py +6 -1
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu_device.py +14 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu_nvidia.py +6 -1
- codecarbon-3.3.0/codecarbon/core/hardware_cache.py +254 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/powermetrics.py +17 -6
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/resource_tracker.py +94 -31
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/util.py +3 -2
- codecarbon-3.3.0/codecarbon/core/windows_emi.py +625 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/emissions_tracker.py +131 -73
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/hardware.py +34 -8
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/ram.py +1 -3
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/task.py +1 -1
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/input.py +29 -12
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/file.py +15 -19
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/http.py +13 -8
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/PKG-INFO +46 -16
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/SOURCES.txt +4 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/pyproject.toml +3 -3
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_api_call.py +203 -16
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_config.py +18 -28
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_core_util.py +22 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_cpu.py +45 -7
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_cpu_load.py +7 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_custom_handler.py +4 -2
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_electricitymaps_config_backward_compatibility.py +4 -8
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions_tracker.py +175 -10
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions_tracker_constant.py +10 -15
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_gpu.py +7 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_gpu_nvidia.py +35 -0
- codecarbon-3.3.0/tests/test_hardware_cache.py +306 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_input.py +6 -3
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_logger.py +1 -1
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_offline_emissions_tracker.py +11 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_powermetrics.py +83 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_ram.py +21 -12
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_resource_tracker.py +299 -4
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_tracking_inference.py +4 -1
- codecarbon-3.3.0/tests/test_windows_emi.py +672 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/testdata.py +7 -0
- codecarbon-3.2.8/codecarbon/_version.py +0 -1
- {codecarbon-3.2.8 → codecarbon-3.3.0}/LICENSE +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/auth.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/cli_utils.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/cloud.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/config.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/electricitymaps_api.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/measure.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/rapl.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/schemas.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/telemetry_client.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/telemetry_schemas.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/units.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/canada_provinces.geojson +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/cloud/impact.csv +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_dataset_builder/amd_cpu_scrapper.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_dataset_builder/intel_cpu_scrapper.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_dataset_builder/merge_scrapped_cpu_power.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_power.csv +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/2016/usa_emissions.json +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/2023/canada_energy_mix.json +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/carbon_intensity_per_source.json +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/global_energy_mix.json +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/nordic_emissions.json +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/geography.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/logger.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/scheduler.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/lock.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/base_output.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/mapper.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/models.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/output.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/emissions_data.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/logger.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/logfire.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/metric_docs.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/prometheus.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/py.typed +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/__init__.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/car_icon.png +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/house_icon.png +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/tv_icon.png +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/carbonboard.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/carbonboard_on_api.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/components.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/data.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/units.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/dependency_links.txt +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/entry_points.txt +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/requires.txt +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/top_level.txt +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/setup.cfg +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_boamps_output.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_cloud.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_docs_examples.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_electricitymaps_api.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_electricitymaps_backward_compatibility.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions_tracker_flush.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_energy.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_geography.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_gpu_amd.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_lock.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_logging_output.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_package_integrity.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_rapl_mmio_scanning.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_rapl_parameters.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_rapl_permissions.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_telemetry_client.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_unsupported_gpu.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_utilization_tracking.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_viz_data.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_viz_units.py +0 -0
- {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/testutils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codecarbon
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
4
4
|
Author: Mila, DataForGood, BCG GAMMA, Comet.ml, Haverford College
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Project-URL: Homepage, https://codecarbon.io/
|
|
@@ -137,18 +137,19 @@ You can visualize your experiment emissions on the [dashboard](https://dashboard
|
|
|
137
137
|
|
|
138
138
|
## Quick links
|
|
139
139
|
|
|
140
|
-
| Section
|
|
141
|
-
|
|
142
|
-
| [Quickstart](https://docs.codecarbon.io/latest/tutorials/first-tracking/)
|
|
143
|
-
| [Installation](https://docs.codecarbon.io/latest/how-to/installation/)
|
|
144
|
-
| [CLI Tutorial](https://docs.codecarbon.io/latest/tutorials/cli/)
|
|
145
|
-
| [Python API Tutorial](https://docs.codecarbon.io/latest/tutorials/python-api/)
|
|
140
|
+
| Section | Description |
|
|
141
|
+
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------ |
|
|
142
|
+
| [Quickstart](https://docs.codecarbon.io/latest/tutorials/first-tracking/) | Get started in 5 minutes |
|
|
143
|
+
| [Installation](https://docs.codecarbon.io/latest/how-to/installation/) | Install CodeCarbon |
|
|
144
|
+
| [CLI Tutorial](https://docs.codecarbon.io/latest/tutorials/cli/) | Track emissions from the command line |
|
|
145
|
+
| [Python API Tutorial](https://docs.codecarbon.io/latest/tutorials/python-api/) | Track emissions in Python code |
|
|
146
146
|
| [Comparing Model Efficiency](https://docs.codecarbon.io/latest/tutorials/comparing-model-efficiency/) | Measure carbon efficiency across ML models |
|
|
147
|
-
| [API Reference](https://docs.codecarbon.io/latest/reference/api/)
|
|
148
|
-
| [Framework examples (scikit-learn)](https://docs.codecarbon.io/latest/how-to/scikit-learn/)
|
|
149
|
-
| [Methodology](https://docs.codecarbon.io/latest/explanation/methodology/)
|
|
150
|
-
| [EcoLogits](https://
|
|
151
|
-
| [
|
|
147
|
+
| [API Reference](https://docs.codecarbon.io/latest/reference/api/) | Full parameter documentation |
|
|
148
|
+
| [Framework examples (scikit-learn)](https://docs.codecarbon.io/latest/how-to/scikit-learn/) | Task-oriented ML framework examples |
|
|
149
|
+
| [Methodology](https://docs.codecarbon.io/latest/explanation/methodology/) | How emissions are calculated |
|
|
150
|
+
| [When to use CodeCarbon vs EcoLogits](https://docs.codecarbon.io/latest/explanation/when-to-use/) | Choose the right tool |
|
|
151
|
+
| [EcoLogits](https://ecologits.ai/) | Track emissions from GenAI API calls |
|
|
152
|
+
| [Discord Community](https://discord.gg/GS9js2XkJR) | Chat with us and the community |
|
|
152
153
|
|
|
153
154
|
## Links
|
|
154
155
|
|
|
@@ -156,6 +157,7 @@ You can visualize your experiment emissions on the [dashboard](https://dashboard
|
|
|
156
157
|
- [Dashboard](https://dashboard.codecarbon.io/) to see your emissions.
|
|
157
158
|
- [Documentation](https://docs.codecarbon.io/) to learn how to use the package and our methodology.
|
|
158
159
|
- [EcoLogits](https://ecologits.ai/) to track emissions from GenAI API calls (OpenAI, Anthropic, etc.).
|
|
160
|
+
- [mlco2 on GitHub](https://github.com/mlco2) for our other open-source projects.
|
|
159
161
|
- [GitHub](https://github.com/mlco2/codecarbon) to look at the source code and contribute.
|
|
160
162
|
- [Discord](https://discord.gg/GS9js2XkJR) to chat with us.
|
|
161
163
|
|
|
@@ -210,7 +212,7 @@ If you find CodeCarbon useful for your research, you can find a citation under a
|
|
|
210
212
|
MinervaBooks},
|
|
211
213
|
title = {mlco2/codecarbon: v2.4.1},
|
|
212
214
|
month = may,
|
|
213
|
-
year = 2024,
|
|
215
|
+
year = {2024},
|
|
214
216
|
publisher = {Zenodo},
|
|
215
217
|
version = {v2.4.1},
|
|
216
218
|
doi = {10.5281/zenodo.11171501},
|
|
@@ -228,6 +230,34 @@ Codecarbon was formerly developed by volunteers from [**Mila**](http://mila.queb
|
|
|
228
230
|
|
|
229
231
|
Now CodeCarbon is supported by [**Code Carbon**](https://www.helloasso.com/associations/code-carbon), a French non-profit organization whose mission is to accelerate the development and adoption of CodeCarbon.
|
|
230
232
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
## Sponsors
|
|
234
|
+
|
|
235
|
+
<div align="center">
|
|
236
|
+
<a href="https://www.clever-cloud.com/">
|
|
237
|
+
<picture>
|
|
238
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/clever_cloud.png">
|
|
239
|
+
<img src="https://cdn.clever-cloud.com/uploads/2023/03/logoonwhite.svg" alt="Clever Cloud" height="48">
|
|
240
|
+
</picture>
|
|
241
|
+
</a>
|
|
242
|
+
|
|
243
|
+
<a href="https://dataforgood.fr/">
|
|
244
|
+
<picture>
|
|
245
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/dataforgood.png">
|
|
246
|
+
<img src="https://dataforgood.fr/images/dataforgood.svg" alt="Data For Good" height="48">
|
|
247
|
+
</picture>
|
|
248
|
+
</a>
|
|
249
|
+
|
|
250
|
+
<a href="https://github.com/">
|
|
251
|
+
<picture>
|
|
252
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/GitHub.png">
|
|
253
|
+
<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Logo.png" alt="GitHub" height="48">
|
|
254
|
+
</picture>
|
|
255
|
+
</a>
|
|
256
|
+
|
|
257
|
+
<a href="https://www.mozilla.org/">
|
|
258
|
+
<picture>
|
|
259
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/mozilla.svg">
|
|
260
|
+
<img src="https://upload.wikimedia.org/wikipedia/commons/d/df/Mozilla_2024_logo.svg" alt="Mozilla" height="48">
|
|
261
|
+
</picture>
|
|
262
|
+
</a>
|
|
263
|
+
</div>
|
|
@@ -90,18 +90,19 @@ You can visualize your experiment emissions on the [dashboard](https://dashboard
|
|
|
90
90
|
|
|
91
91
|
## Quick links
|
|
92
92
|
|
|
93
|
-
| Section
|
|
94
|
-
|
|
95
|
-
| [Quickstart](https://docs.codecarbon.io/latest/tutorials/first-tracking/)
|
|
96
|
-
| [Installation](https://docs.codecarbon.io/latest/how-to/installation/)
|
|
97
|
-
| [CLI Tutorial](https://docs.codecarbon.io/latest/tutorials/cli/)
|
|
98
|
-
| [Python API Tutorial](https://docs.codecarbon.io/latest/tutorials/python-api/)
|
|
93
|
+
| Section | Description |
|
|
94
|
+
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------ |
|
|
95
|
+
| [Quickstart](https://docs.codecarbon.io/latest/tutorials/first-tracking/) | Get started in 5 minutes |
|
|
96
|
+
| [Installation](https://docs.codecarbon.io/latest/how-to/installation/) | Install CodeCarbon |
|
|
97
|
+
| [CLI Tutorial](https://docs.codecarbon.io/latest/tutorials/cli/) | Track emissions from the command line |
|
|
98
|
+
| [Python API Tutorial](https://docs.codecarbon.io/latest/tutorials/python-api/) | Track emissions in Python code |
|
|
99
99
|
| [Comparing Model Efficiency](https://docs.codecarbon.io/latest/tutorials/comparing-model-efficiency/) | Measure carbon efficiency across ML models |
|
|
100
|
-
| [API Reference](https://docs.codecarbon.io/latest/reference/api/)
|
|
101
|
-
| [Framework examples (scikit-learn)](https://docs.codecarbon.io/latest/how-to/scikit-learn/)
|
|
102
|
-
| [Methodology](https://docs.codecarbon.io/latest/explanation/methodology/)
|
|
103
|
-
| [EcoLogits](https://
|
|
104
|
-
| [
|
|
100
|
+
| [API Reference](https://docs.codecarbon.io/latest/reference/api/) | Full parameter documentation |
|
|
101
|
+
| [Framework examples (scikit-learn)](https://docs.codecarbon.io/latest/how-to/scikit-learn/) | Task-oriented ML framework examples |
|
|
102
|
+
| [Methodology](https://docs.codecarbon.io/latest/explanation/methodology/) | How emissions are calculated |
|
|
103
|
+
| [When to use CodeCarbon vs EcoLogits](https://docs.codecarbon.io/latest/explanation/when-to-use/) | Choose the right tool |
|
|
104
|
+
| [EcoLogits](https://ecologits.ai/) | Track emissions from GenAI API calls |
|
|
105
|
+
| [Discord Community](https://discord.gg/GS9js2XkJR) | Chat with us and the community |
|
|
105
106
|
|
|
106
107
|
## Links
|
|
107
108
|
|
|
@@ -109,6 +110,7 @@ You can visualize your experiment emissions on the [dashboard](https://dashboard
|
|
|
109
110
|
- [Dashboard](https://dashboard.codecarbon.io/) to see your emissions.
|
|
110
111
|
- [Documentation](https://docs.codecarbon.io/) to learn how to use the package and our methodology.
|
|
111
112
|
- [EcoLogits](https://ecologits.ai/) to track emissions from GenAI API calls (OpenAI, Anthropic, etc.).
|
|
113
|
+
- [mlco2 on GitHub](https://github.com/mlco2) for our other open-source projects.
|
|
112
114
|
- [GitHub](https://github.com/mlco2/codecarbon) to look at the source code and contribute.
|
|
113
115
|
- [Discord](https://discord.gg/GS9js2XkJR) to chat with us.
|
|
114
116
|
|
|
@@ -163,7 +165,7 @@ If you find CodeCarbon useful for your research, you can find a citation under a
|
|
|
163
165
|
MinervaBooks},
|
|
164
166
|
title = {mlco2/codecarbon: v2.4.1},
|
|
165
167
|
month = may,
|
|
166
|
-
year = 2024,
|
|
168
|
+
year = {2024},
|
|
167
169
|
publisher = {Zenodo},
|
|
168
170
|
version = {v2.4.1},
|
|
169
171
|
doi = {10.5281/zenodo.11171501},
|
|
@@ -181,6 +183,34 @@ Codecarbon was formerly developed by volunteers from [**Mila**](http://mila.queb
|
|
|
181
183
|
|
|
182
184
|
Now CodeCarbon is supported by [**Code Carbon**](https://www.helloasso.com/associations/code-carbon), a French non-profit organization whose mission is to accelerate the development and adoption of CodeCarbon.
|
|
183
185
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
## Sponsors
|
|
187
|
+
|
|
188
|
+
<div align="center">
|
|
189
|
+
<a href="https://www.clever-cloud.com/">
|
|
190
|
+
<picture>
|
|
191
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/clever_cloud.png">
|
|
192
|
+
<img src="https://cdn.clever-cloud.com/uploads/2023/03/logoonwhite.svg" alt="Clever Cloud" height="48">
|
|
193
|
+
</picture>
|
|
194
|
+
</a>
|
|
195
|
+
|
|
196
|
+
<a href="https://dataforgood.fr/">
|
|
197
|
+
<picture>
|
|
198
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/dataforgood.png">
|
|
199
|
+
<img src="https://dataforgood.fr/images/dataforgood.svg" alt="Data For Good" height="48">
|
|
200
|
+
</picture>
|
|
201
|
+
</a>
|
|
202
|
+
|
|
203
|
+
<a href="https://github.com/">
|
|
204
|
+
<picture>
|
|
205
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/GitHub.png">
|
|
206
|
+
<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Logo.png" alt="GitHub" height="48">
|
|
207
|
+
</picture>
|
|
208
|
+
</a>
|
|
209
|
+
|
|
210
|
+
<a href="https://www.mozilla.org/">
|
|
211
|
+
<picture>
|
|
212
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mlco2/codecarbon-landing-page/main/public/assets/partners/mozilla.svg">
|
|
213
|
+
<img src="https://upload.wikimedia.org/wikipedia/commons/d/df/Mozilla_2024_logo.svg" alt="Mozilla" height="48">
|
|
214
|
+
</picture>
|
|
215
|
+
</a>
|
|
216
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "3.3.0"
|
|
@@ -5,15 +5,12 @@ import time
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Optional
|
|
7
7
|
|
|
8
|
-
import questionary
|
|
9
|
-
import requests
|
|
10
8
|
import typer
|
|
11
9
|
from rich import print
|
|
12
10
|
from rich.prompt import Confirm
|
|
13
11
|
from typing_extensions import Annotated
|
|
14
12
|
|
|
15
13
|
from codecarbon import __app_name__, __version__
|
|
16
|
-
from codecarbon.cli.auth import authorize, get_access_token
|
|
17
14
|
from codecarbon.cli.cli_utils import (
|
|
18
15
|
create_new_config_file,
|
|
19
16
|
get_api_endpoint,
|
|
@@ -21,10 +18,6 @@ from codecarbon.cli.cli_utils import (
|
|
|
21
18
|
get_existing_exp_id,
|
|
22
19
|
overwrite_local_config,
|
|
23
20
|
)
|
|
24
|
-
from codecarbon.cli.monitor import run_and_monitor
|
|
25
|
-
from codecarbon.core.api_client import ApiClient, get_datetime_with_timezone
|
|
26
|
-
from codecarbon.core.schemas import ExperimentCreate, OrganizationCreate, ProjectCreate
|
|
27
|
-
from codecarbon.emissions_tracker import EmissionsTracker, OfflineEmissionsTracker
|
|
28
21
|
|
|
29
22
|
API_URL = os.environ.get("API_URL", "https://dashboard.codecarbon.io/api")
|
|
30
23
|
|
|
@@ -47,6 +40,20 @@ def main():
|
|
|
47
40
|
raise sys.exit(1)
|
|
48
41
|
|
|
49
42
|
|
|
43
|
+
def _api_call(action: str, func, *args, **kwargs):
|
|
44
|
+
"""
|
|
45
|
+
Run a call to the Code Carbon API, turning the errors it now raises into a
|
|
46
|
+
readable message and a clean exit instead of a traceback.
|
|
47
|
+
|
|
48
|
+
:action: what was being attempted, used as the first part of the message.
|
|
49
|
+
"""
|
|
50
|
+
try:
|
|
51
|
+
return func(*args, **kwargs)
|
|
52
|
+
except Exception as e:
|
|
53
|
+
print(f"[yellow]{action}[/yellow]. (error: {e})")
|
|
54
|
+
raise typer.Exit(1)
|
|
55
|
+
|
|
56
|
+
|
|
50
57
|
def _version_callback(value: bool) -> None:
|
|
51
58
|
if value:
|
|
52
59
|
print(f"{__app_name__} v{__version__}")
|
|
@@ -68,6 +75,9 @@ def version(
|
|
|
68
75
|
|
|
69
76
|
|
|
70
77
|
def show_config(path: Path = Path("./.codecarbon.config")) -> None:
|
|
78
|
+
from codecarbon.cli.auth import get_access_token
|
|
79
|
+
from codecarbon.core.api_client import ApiClient
|
|
80
|
+
|
|
71
81
|
d = get_config(path)
|
|
72
82
|
print("Current configuration : \n")
|
|
73
83
|
print("Config file content : ")
|
|
@@ -114,24 +124,34 @@ def api_get():
|
|
|
114
124
|
"""
|
|
115
125
|
ex: test-api
|
|
116
126
|
"""
|
|
127
|
+
from codecarbon.cli.auth import get_access_token
|
|
128
|
+
from codecarbon.core.api_client import ApiClient
|
|
129
|
+
|
|
117
130
|
api_endpoint = get_api_endpoint()
|
|
118
131
|
api = ApiClient(endpoint_url=api_endpoint)
|
|
119
132
|
api.set_access_token(get_access_token())
|
|
120
|
-
organizations = api.get_list_organizations
|
|
133
|
+
organizations = _api_call("API request failed", api.get_list_organizations)
|
|
121
134
|
print(organizations)
|
|
122
135
|
|
|
123
136
|
|
|
124
137
|
@codecarbon.command("login", short_help="Login to CodeCarbon")
|
|
125
138
|
def login():
|
|
139
|
+
from codecarbon.cli.auth import authorize, get_access_token
|
|
140
|
+
from codecarbon.core.api_client import ApiClient
|
|
141
|
+
|
|
126
142
|
authorize()
|
|
127
143
|
api_endpoint = get_api_endpoint()
|
|
128
144
|
api = ApiClient(endpoint_url=api_endpoint)
|
|
129
145
|
access_token = get_access_token()
|
|
130
146
|
api.set_access_token(access_token)
|
|
131
|
-
api.check_auth
|
|
147
|
+
_api_call("Authentication check failed", api.check_auth)
|
|
132
148
|
|
|
133
149
|
|
|
134
150
|
def get_api_key(project_id: str):
|
|
151
|
+
import requests
|
|
152
|
+
|
|
153
|
+
from codecarbon.cli.auth import get_access_token
|
|
154
|
+
|
|
135
155
|
api_endpoint = get_api_endpoint()
|
|
136
156
|
api_endpoint = api_endpoint.rstrip("/")
|
|
137
157
|
req = requests.post(
|
|
@@ -143,6 +163,7 @@ def get_api_key(project_id: str):
|
|
|
143
163
|
},
|
|
144
164
|
headers={"Authorization": f"Bearer {get_access_token()}"},
|
|
145
165
|
)
|
|
166
|
+
req.raise_for_status()
|
|
146
167
|
api_key = req.json()["token"]
|
|
147
168
|
return api_key
|
|
148
169
|
|
|
@@ -161,6 +182,13 @@ def config():
|
|
|
161
182
|
"""
|
|
162
183
|
Initialize CodeCarbon, this will prompt you for configuration of Organisation/Team/Project/Experiment.
|
|
163
184
|
"""
|
|
185
|
+
from codecarbon.cli.auth import get_access_token
|
|
186
|
+
from codecarbon.core.api_client import ApiClient, get_datetime_with_timezone
|
|
187
|
+
from codecarbon.core.schemas import (
|
|
188
|
+
ExperimentCreate,
|
|
189
|
+
OrganizationCreate,
|
|
190
|
+
ProjectCreate,
|
|
191
|
+
)
|
|
164
192
|
|
|
165
193
|
print("Welcome to CodeCarbon configuration wizard")
|
|
166
194
|
home = Path.home()
|
|
@@ -199,7 +227,10 @@ def config():
|
|
|
199
227
|
overwrite_local_config("api_endpoint", api_endpoint, path=file_path)
|
|
200
228
|
api = ApiClient(endpoint_url=api_endpoint)
|
|
201
229
|
api.set_access_token(get_access_token())
|
|
202
|
-
organizations =
|
|
230
|
+
organizations = _api_call(
|
|
231
|
+
"Could not list organizations from API. Please check your login and API endpoint",
|
|
232
|
+
api.get_list_organizations,
|
|
233
|
+
)
|
|
203
234
|
org = questionary_prompt(
|
|
204
235
|
"Pick existing organization from list or Create new organization ?",
|
|
205
236
|
[org["name"] for org in organizations] + ["Create New Organization"],
|
|
@@ -216,18 +247,23 @@ def config():
|
|
|
216
247
|
name=org_name,
|
|
217
248
|
description=org_description,
|
|
218
249
|
)
|
|
219
|
-
organization =
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
250
|
+
organization = _api_call(
|
|
251
|
+
"Could not create the organization",
|
|
252
|
+
api.create_organization,
|
|
253
|
+
organization=organization_create,
|
|
254
|
+
)
|
|
223
255
|
print(f"Created organization : {organization}")
|
|
224
256
|
else:
|
|
225
257
|
organization = [orga for orga in organizations if orga["name"] == org][0]
|
|
226
258
|
org_id = organization["id"]
|
|
227
259
|
overwrite_local_config("organization_id", org_id, path=file_path)
|
|
228
260
|
|
|
229
|
-
projects =
|
|
230
|
-
|
|
261
|
+
projects = _api_call(
|
|
262
|
+
"Could not list projects from API",
|
|
263
|
+
api.list_projects_from_organization,
|
|
264
|
+
org_id,
|
|
265
|
+
)
|
|
266
|
+
project_names = [project["name"] for project in projects]
|
|
231
267
|
project = questionary_prompt(
|
|
232
268
|
"Pick existing project from list or Create new project ?",
|
|
233
269
|
project_names + ["Create New Project"],
|
|
@@ -243,17 +279,21 @@ def config():
|
|
|
243
279
|
description=project_description,
|
|
244
280
|
organization_id=org_id,
|
|
245
281
|
)
|
|
246
|
-
project =
|
|
282
|
+
project = _api_call(
|
|
283
|
+
"Could not create the project", api.create_project, project=project_create
|
|
284
|
+
)
|
|
247
285
|
print(f"Created project : {project}")
|
|
248
286
|
else:
|
|
249
287
|
project = [p for p in projects if p["name"] == project][0]
|
|
250
288
|
project_id = project["id"]
|
|
251
289
|
overwrite_local_config("project_id", project_id, path=file_path)
|
|
252
290
|
|
|
253
|
-
experiments =
|
|
254
|
-
|
|
255
|
-
|
|
291
|
+
experiments = _api_call(
|
|
292
|
+
"Could not list experiments from API",
|
|
293
|
+
api.list_experiments_from_project,
|
|
294
|
+
project_id,
|
|
256
295
|
)
|
|
296
|
+
experiments_names = [experiment["name"] for experiment in experiments]
|
|
257
297
|
|
|
258
298
|
experiment = questionary_prompt(
|
|
259
299
|
"Pick existing experiment from list or Create new experiment ?",
|
|
@@ -300,13 +340,17 @@ def config():
|
|
|
300
340
|
cloud_provider=cloud_provider,
|
|
301
341
|
cloud_region=cloud_region,
|
|
302
342
|
)
|
|
303
|
-
experiment =
|
|
343
|
+
experiment = _api_call(
|
|
344
|
+
"Could not create the experiment",
|
|
345
|
+
api.add_experiment,
|
|
346
|
+
experiment=experiment_create,
|
|
347
|
+
)
|
|
304
348
|
|
|
305
349
|
else:
|
|
306
350
|
experiment = [e for e in experiments if e["name"] == experiment][0]
|
|
307
351
|
|
|
308
352
|
overwrite_local_config("experiment_id", experiment["id"], path=file_path)
|
|
309
|
-
api_key = get_api_key
|
|
353
|
+
api_key = _api_call("Could not get the project API key", get_api_key, project_id)
|
|
310
354
|
overwrite_local_config("api_key", api_key, path=file_path)
|
|
311
355
|
show_config(file_path)
|
|
312
356
|
print(
|
|
@@ -342,6 +386,10 @@ def monitor(
|
|
|
342
386
|
str,
|
|
343
387
|
typer.Option(help="Region/province for offline mode"),
|
|
344
388
|
] = None,
|
|
389
|
+
log_level: Annotated[
|
|
390
|
+
str,
|
|
391
|
+
typer.Option(help="Log level (critical, error, warning, info, debug)"),
|
|
392
|
+
] = "error",
|
|
345
393
|
):
|
|
346
394
|
"""Monitor your machine's carbon emissions."""
|
|
347
395
|
|
|
@@ -349,6 +397,7 @@ def monitor(
|
|
|
349
397
|
tracker_args = {
|
|
350
398
|
"measure_power_secs": measure_power_secs,
|
|
351
399
|
"api_call_interval": api_call_interval,
|
|
400
|
+
"log_level": log_level,
|
|
352
401
|
}
|
|
353
402
|
# Set up the tracker arguments based on mode (offline vs online) and validate required args for each mode
|
|
354
403
|
if offline:
|
|
@@ -375,8 +424,12 @@ def monitor(
|
|
|
375
424
|
|
|
376
425
|
tracker_args = {**tracker_args, "save_to_api": api}
|
|
377
426
|
|
|
427
|
+
from codecarbon.emissions_tracker import EmissionsTracker, OfflineEmissionsTracker
|
|
428
|
+
|
|
378
429
|
# If extra args are provided (e.g. `codecarbon monitor -- my_script.py`), delegate to `run_and_monitor`
|
|
379
430
|
if getattr(ctx, "args", None):
|
|
431
|
+
from codecarbon.cli.monitor import run_and_monitor
|
|
432
|
+
|
|
380
433
|
return run_and_monitor(ctx, offline=offline, **tracker_args)
|
|
381
434
|
|
|
382
435
|
# Instantiate the tracker
|
|
@@ -417,6 +470,8 @@ def detect():
|
|
|
417
470
|
"""
|
|
418
471
|
Detects hardware and prints information without running any measurements.
|
|
419
472
|
"""
|
|
473
|
+
from codecarbon.emissions_tracker import EmissionsTracker
|
|
474
|
+
|
|
420
475
|
print("Detecting hardware...")
|
|
421
476
|
tracker = EmissionsTracker(save_to_file=False)
|
|
422
477
|
hardware_info = tracker.get_detected_hardware()
|
|
@@ -438,6 +493,8 @@ def detect():
|
|
|
438
493
|
|
|
439
494
|
|
|
440
495
|
def questionary_prompt(prompt, list_options, default):
|
|
496
|
+
import questionary
|
|
497
|
+
|
|
441
498
|
value = questionary.select(
|
|
442
499
|
prompt,
|
|
443
500
|
list_options,
|
|
@@ -8,8 +8,6 @@ import typer
|
|
|
8
8
|
from rich import print
|
|
9
9
|
from typing_extensions import Annotated
|
|
10
10
|
|
|
11
|
-
from codecarbon.emissions_tracker import EmissionsTracker, OfflineEmissionsTracker
|
|
12
|
-
|
|
13
11
|
|
|
14
12
|
def run_and_monitor(
|
|
15
13
|
ctx: typer.Context,
|
|
@@ -50,12 +48,15 @@ def run_and_monitor(
|
|
|
50
48
|
directory. The file path is shown in the final report.
|
|
51
49
|
"""
|
|
52
50
|
# Suppress all CodeCarbon logs during execution
|
|
51
|
+
from codecarbon.emissions_tracker import EmissionsTracker, OfflineEmissionsTracker
|
|
53
52
|
from codecarbon.external.logger import set_logger_level
|
|
54
53
|
|
|
55
54
|
set_logger_level(log_level)
|
|
56
55
|
|
|
57
|
-
# Get the command from remaining args
|
|
58
|
-
command = ctx
|
|
56
|
+
# Get the command from remaining args (strip nested subcommand / `--` leftovers)
|
|
57
|
+
command = list(getattr(ctx, "args", None) or [])
|
|
58
|
+
while command and command[0] in ("monitor", "--"):
|
|
59
|
+
command.pop(0)
|
|
59
60
|
|
|
60
61
|
if not command:
|
|
61
62
|
print(
|