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.
Files changed (131) hide show
  1. {codecarbon-3.2.8 → codecarbon-3.3.0}/PKG-INFO +46 -16
  2. {codecarbon-3.2.8 → codecarbon-3.3.0}/README.md +45 -15
  3. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/__init__.py +1 -1
  4. codecarbon-3.3.0/codecarbon/_version.py +1 -0
  5. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/main.py +79 -22
  6. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/monitor.py +5 -4
  7. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/api_client.py +55 -85
  8. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/cpu.py +16 -3
  9. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/emissions.py +4 -3
  10. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu.py +17 -0
  11. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu_amd.py +6 -1
  12. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu_device.py +14 -0
  13. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/gpu_nvidia.py +6 -1
  14. codecarbon-3.3.0/codecarbon/core/hardware_cache.py +254 -0
  15. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/powermetrics.py +17 -6
  16. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/resource_tracker.py +94 -31
  17. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/util.py +3 -2
  18. codecarbon-3.3.0/codecarbon/core/windows_emi.py +625 -0
  19. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/emissions_tracker.py +131 -73
  20. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/hardware.py +34 -8
  21. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/ram.py +1 -3
  22. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/task.py +1 -1
  23. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/input.py +29 -12
  24. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/file.py +15 -19
  25. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/http.py +13 -8
  26. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/PKG-INFO +46 -16
  27. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/SOURCES.txt +4 -0
  28. {codecarbon-3.2.8 → codecarbon-3.3.0}/pyproject.toml +3 -3
  29. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_api_call.py +203 -16
  30. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_config.py +18 -28
  31. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_core_util.py +22 -0
  32. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_cpu.py +45 -7
  33. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_cpu_load.py +7 -0
  34. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_custom_handler.py +4 -2
  35. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_electricitymaps_config_backward_compatibility.py +4 -8
  36. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions_tracker.py +175 -10
  37. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions_tracker_constant.py +10 -15
  38. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_gpu.py +7 -0
  39. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_gpu_nvidia.py +35 -0
  40. codecarbon-3.3.0/tests/test_hardware_cache.py +306 -0
  41. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_input.py +6 -3
  42. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_logger.py +1 -1
  43. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_offline_emissions_tracker.py +11 -0
  44. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_powermetrics.py +83 -0
  45. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_ram.py +21 -12
  46. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_resource_tracker.py +299 -4
  47. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_tracking_inference.py +4 -1
  48. codecarbon-3.3.0/tests/test_windows_emi.py +672 -0
  49. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/testdata.py +7 -0
  50. codecarbon-3.2.8/codecarbon/_version.py +0 -1
  51. {codecarbon-3.2.8 → codecarbon-3.3.0}/LICENSE +0 -0
  52. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/__init__.py +0 -0
  53. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/auth.py +0 -0
  54. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/cli/cli_utils.py +0 -0
  55. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/__init__.py +0 -0
  56. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/cloud.py +0 -0
  57. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/config.py +0 -0
  58. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/electricitymaps_api.py +0 -0
  59. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/measure.py +0 -0
  60. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/rapl.py +0 -0
  61. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/schemas.py +0 -0
  62. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/telemetry_client.py +0 -0
  63. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/telemetry_schemas.py +0 -0
  64. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/core/units.py +0 -0
  65. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/canada_provinces.geojson +0 -0
  66. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/cloud/impact.csv +0 -0
  67. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_dataset_builder/amd_cpu_scrapper.py +0 -0
  68. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_dataset_builder/intel_cpu_scrapper.py +0 -0
  69. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_dataset_builder/merge_scrapped_cpu_power.py +0 -0
  70. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/hardware/cpu_power.csv +0 -0
  71. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/2016/usa_emissions.json +0 -0
  72. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/2023/canada_energy_mix.json +0 -0
  73. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/carbon_intensity_per_source.json +0 -0
  74. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/global_energy_mix.json +0 -0
  75. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/data/private_infra/nordic_emissions.json +0 -0
  76. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/__init__.py +0 -0
  77. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/geography.py +0 -0
  78. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/logger.py +0 -0
  79. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/external/scheduler.py +0 -0
  80. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/lock.py +0 -0
  81. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output.py +0 -0
  82. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/__init__.py +0 -0
  83. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/base_output.py +0 -0
  84. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/__init__.py +0 -0
  85. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/mapper.py +0 -0
  86. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/models.py +0 -0
  87. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/boamps/output.py +0 -0
  88. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/emissions_data.py +0 -0
  89. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/logger.py +0 -0
  90. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/__init__.py +0 -0
  91. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/logfire.py +0 -0
  92. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/metric_docs.py +0 -0
  93. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/output_methods/metrics/prometheus.py +0 -0
  94. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/py.typed +0 -0
  95. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/__init__.py +0 -0
  96. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/__init__.py +0 -0
  97. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/car_icon.png +0 -0
  98. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/house_icon.png +0 -0
  99. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/assets/tv_icon.png +0 -0
  100. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/carbonboard.py +0 -0
  101. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/carbonboard_on_api.py +0 -0
  102. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/components.py +0 -0
  103. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/data.py +0 -0
  104. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon/viz/units.py +0 -0
  105. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/dependency_links.txt +0 -0
  106. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/entry_points.txt +0 -0
  107. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/requires.txt +0 -0
  108. {codecarbon-3.2.8 → codecarbon-3.3.0}/codecarbon.egg-info/top_level.txt +0 -0
  109. {codecarbon-3.2.8 → codecarbon-3.3.0}/setup.cfg +0 -0
  110. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_boamps_output.py +0 -0
  111. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_cloud.py +0 -0
  112. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_docs_examples.py +0 -0
  113. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_electricitymaps_api.py +0 -0
  114. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_electricitymaps_backward_compatibility.py +0 -0
  115. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions.py +0 -0
  116. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_emissions_tracker_flush.py +0 -0
  117. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_energy.py +0 -0
  118. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_geography.py +0 -0
  119. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_gpu_amd.py +0 -0
  120. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_lock.py +0 -0
  121. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_logging_output.py +0 -0
  122. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_package_integrity.py +0 -0
  123. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_rapl_mmio_scanning.py +0 -0
  124. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_rapl_parameters.py +0 -0
  125. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_rapl_permissions.py +0 -0
  126. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_telemetry_client.py +0 -0
  127. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_unsupported_gpu.py +0 -0
  128. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_utilization_tracking.py +0 -0
  129. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_viz_data.py +0 -0
  130. {codecarbon-3.2.8 → codecarbon-3.3.0}/tests/test_viz_units.py +0 -0
  131. {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.2.8
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 | 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 |
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/) | 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
- | [EcoLogits](https://ecologits.ai/) | Track emissions from GenAI API calls |
151
- | [Discord Community](https://discord.gg/GS9js2XkJR) | Chat with us and the community |
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
- ### Star History
232
-
233
- [![Star History Chart](https://api.star-history.com/svg?repos=mlco2/codecarbon,lfwa/carbontracker,sb-ai-lab/Eco2AI,fvaleye/tracarbon,Breakend/experiment-impact-tracker&type=Date)](https://star-history.com/#mlco2/codecarbon&lfwa/carbontracker&sb-ai-lab/Eco2AI&fvaleye/tracarbon&Breakend/experiment-impact-tracker&Date)
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
+ &nbsp;&nbsp;&nbsp;
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
+ &nbsp;&nbsp;&nbsp;
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
+ &nbsp;&nbsp;&nbsp;
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 | 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 |
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/) | 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
- | [EcoLogits](https://ecologits.ai/) | Track emissions from GenAI API calls |
104
- | [Discord Community](https://discord.gg/GS9js2XkJR) | Chat with us and the community |
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
- ### Star History
185
-
186
- [![Star History Chart](https://api.star-history.com/svg?repos=mlco2/codecarbon,lfwa/carbontracker,sb-ai-lab/Eco2AI,fvaleye/tracarbon,Breakend/experiment-impact-tracker&type=Date)](https://star-history.com/#mlco2/codecarbon&lfwa/carbontracker&sb-ai-lab/Eco2AI&fvaleye/tracarbon&Breakend/experiment-impact-tracker&Date)
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
+ &nbsp;&nbsp;&nbsp;
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
+ &nbsp;&nbsp;&nbsp;
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
+ &nbsp;&nbsp;&nbsp;
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>
@@ -8,7 +8,7 @@ from .emissions_tracker import (
8
8
  OfflineEmissionsTracker,
9
9
  track_emissions,
10
10
  )
11
- from .output import OutputMethod
11
+ from .output_methods.base_output import OutputMethod
12
12
 
13
13
  __all__ = [
14
14
  "EmissionsTracker",
@@ -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 = api.get_list_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 = api.create_organization(organization=organization_create)
220
- if organization is None:
221
- print("Error creating organization")
222
- return
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 = api.list_projects_from_organization(org_id)
230
- project_names = [project["name"] for project in projects] if projects else []
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 = api.create_project(project=project_create)
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 = api.list_experiments_from_project(project_id)
254
- experiments_names = (
255
- [experiment["name"] for experiment in experiments] if experiments else []
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 = api.add_experiment(experiment=experiment_create)
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(project_id)
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.args
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(