Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: black
args: [--safe]
- repo: https://github.com/PyCQA/flake8
rev: 7.2.0
rev: 7.3.0
hooks:
- id: flake8
args: ["--config=.flake8"]
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ If any of the linters/formatters fail, check the difference with `git diff`, add

You can also run `pre-commit` with `uv run pre-commit run -v` if you have some changes staged but you are not ready yet to commit.

It's nice to keep it up-to-date with `uv run precommit-update` sometimes.


<!-- TOC --><a name="dependencies-management"></a>
### Dependencies management
Expand Down Expand Up @@ -284,6 +282,7 @@ to regenerate the html files.
- Run `uv run python3 .github/check_version.py` to check version consistancy.
- Update the dependencies with `uv sync --upgrade`
- Export a requirements.txt `uv pip freeze > requirements.txt`.
- Keep pre-commit up-to-date with `uv run task precommit-update`.
- [Build Documentation](#documentation) with `uv run --only-group doc task docs`.
- Push the changes.
- Merge the PR.
Expand Down
2 changes: 1 addition & 1 deletion codecarbon/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.2"
__version__ = "3.0.3"
2 changes: 1 addition & 1 deletion docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 50eaf21b3112455919f4085ca019ec3b
config: 3dc67ebe45c3e3f033bfe8c12db5ef23
tags: 645f666f9bcd5a90fca523b33c5a78b7
17 changes: 11 additions & 6 deletions docs/_sources/usage.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ Command line
~~~~~~~~~~~~


Create a minimal configuration file (just follow the prompts) :
Create a minimal configuration file (just follow the prompts) :

.. code-block:: console

codecarbon config
codecarbon config

.. image:: https://asciinema.org/a/667970.svg
:align: center
:alt: Init config
:target: https://asciinema.org/a/667970

You can use the same command to modify an existing config :

.. image:: https://asciinema.org/a/667971.svg
Expand All @@ -38,12 +38,12 @@ If you want to track the emissions of a computer without having to modify your c

.. code-block:: console

codecarbon monitor
codecarbon monitor

You have to stop the monitoring manually with ``Ctrl+C``.

In the following example you will see how to use the CLI to monitor all the emissions of you computer and sending everything
to an API running on "localhost:8008" (Or you can start a private local API with "docker-compose up"). Using the public API with
In the following example you will see how to use the CLI to monitor all the emissions of you computer and sending everything
to an API running on "localhost:8008" (Or you can start a private local API with "docker-compose up"). Using the public API with
this is not supported yet (coming soon!)

.. image:: https://asciinema.org/a/667984.svg
Expand All @@ -52,6 +52,11 @@ this is not supported yet (coming soon!)
:target: https://asciinema.org/a/667984


The command line could also works without internet by providing the country code like this:

.. code-block:: console

codecarbon monitor --offline --country-iso-code FRA

Implementing CodeCarbon in your code allows you to track the emissions of a specific block of code.

Expand Down
6 changes: 3 additions & 3 deletions docs/_sources/visualize.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ region to host infrastructure for the concerned cloud provider.
:height: 450px
:width: 750px

Online (Beta)
Online
--------------

A ``Dash App`` is also available for those who chose to connect the package to the API then data are public and available for all to explore.
`preview <https://dashboard.codecarbon.io/>`_
A dashboard is also available for those who chose to connect the package to the public API.
`Got to online dashboard <https://dashboard.codecarbon.io/>`_

from global...
~~~~~~~~~~~~~~
Expand Down
8 changes: 0 additions & 8 deletions docs/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,6 @@ abbr, acronym {
cursor: help;
}

.translated {
background-color: rgba(207, 255, 207, 0.2)
}

.untranslated {
background-color: rgba(255, 207, 207, 0.2)
}

/* -- code displays --------------------------------------------------------- */

pre {
Expand Down
2 changes: 1 addition & 1 deletion docs/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
VERSION: '3.0.2',
VERSION: '3.0.3',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
10 changes: 7 additions & 3 deletions docs/_static/js/versions.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
const themeFlyoutDisplay = "hidden";
const themeVersionSelector = "True";
const themeLanguageSelector = "True";
const themeVersionSelector = true;
const themeLanguageSelector = true;

if (themeFlyoutDisplay === "attached") {
function renderLanguages(config) {
if (!config.projects.translations.length) {
return "";
}

// Insert the current language to the options on the selector
let languages = config.projects.translations.concat(config.projects.current);
languages = languages.sort((a, b) => a.language.name.localeCompare(b.language.name));

const languagesHTML = `
<dl>
<dt>Languages</dt>
${config.projects.translations
${languages
.map(
(translation) => `
<dd ${translation.slug == config.projects.current.slug ? 'class="rtd-current-item"' : ""}>
Expand Down
66 changes: 33 additions & 33 deletions docs/_static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,70 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .err { border: 1px solid #F00 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .o { color: #666 } /* Operator */
.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .cs { color: #408090; background-color: #FFF0F0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gr { color: #F00 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #333333 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .go { color: #333 } /* Generic.Output */
.highlight .gp { color: #C65D09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .gt { color: #04D } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .s { color: #4070A0 } /* Literal.String */
.highlight .na { color: #4070A0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .nc { color: #0E84B5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60ADD5 } /* Name.Constant */
.highlight .nd { color: #555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #D55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nf { color: #06287E } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nn { color: #0E84B5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .nv { color: #BB60D5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .w { color: #BBB } /* Text.Whitespace */
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sa { color: #4070A0 } /* Literal.String.Affix */
.highlight .sb { color: #4070A0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070A0 } /* Literal.String.Char */
.highlight .dl { color: #4070A0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070A0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070A0 } /* Literal.String.Double */
.highlight .se { color: #4070A0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070A0 } /* Literal.String.Heredoc */
.highlight .si { color: #70A0D0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #C65D09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .s1 { color: #4070A0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #06287e } /* Name.Function.Magic */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
.highlight .fm { color: #06287E } /* Name.Function.Magic */
.highlight .vc { color: #BB60D5 } /* Name.Variable.Class */
.highlight .vg { color: #BB60D5 } /* Name.Variable.Global */
.highlight .vi { color: #BB60D5 } /* Name.Variable.Instance */
.highlight .vm { color: #BB60D5 } /* Name.Variable.Magic */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */
13 changes: 8 additions & 5 deletions docs/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,11 @@ const Search = {
// perform the search on the required terms
searchTerms.forEach((word) => {
const files = [];
// find documents, if any, containing the query word in their text/title term indices
// use Object.hasOwnProperty to avoid mismatching against prototype properties
const arr = [
{ files: terms[word], score: Scorer.term },
{ files: titleTerms[word], score: Scorer.title },
{ files: terms.hasOwnProperty(word) ? terms[word] : undefined, score: Scorer.term },
{ files: titleTerms.hasOwnProperty(word) ? titleTerms[word] : undefined, score: Scorer.title },
];
// add support for partial matches
if (word.length > 2) {
Expand Down Expand Up @@ -547,8 +549,9 @@ const Search = {

// set score for the word in each file
recordFiles.forEach((file) => {
if (!scoreMap.has(file)) scoreMap.set(file, {});
scoreMap.get(file)[word] = record.score;
if (!scoreMap.has(file)) scoreMap.set(file, new Map());
const fileScores = scoreMap.get(file);
fileScores.set(word, record.score);
});
});

Expand Down Expand Up @@ -587,7 +590,7 @@ const Search = {
break;

// select one (max) score for the file.
const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
const score = Math.max(...wordList.map((w) => scoreMap.get(file).get(w)));
// add result to the result list
results.push([
docNames[file],
Expand Down
6 changes: 3 additions & 3 deletions docs/advanced_installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Advanced Installation &mdash; CodeCarbon 3.0.2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<title>Advanced Installation &mdash; CodeCarbon 3.0.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />


<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=3f474186"></script>
<script src="_static/documentation_options.js?v=9b3fc59f"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand Down
14 changes: 7 additions & 7 deletions docs/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CodeCarbon API &mdash; CodeCarbon 3.0.2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<title>CodeCarbon API &mdash; CodeCarbon 3.0.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />


<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=3f474186"></script>
<script src="_static/documentation_options.js?v=9b3fc59f"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand Down Expand Up @@ -116,10 +116,10 @@ <h2>CodeCarbon API<a class="headerlink" href="#id1" title="Link to this heading"
</pre></div>
</div>
<p>Or use the API in your code:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">codecarbon</span> <span class="kn">import</span> <span class="n">track_emissions</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">codecarbon</span><span class="w"> </span><span class="kn">import</span> <span class="n">track_emissions</span>

<span class="nd">@track_emissions</span><span class="p">(</span><span class="n">save_to_api</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">train_model</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">train_model</span><span class="p">():</span>
<span class="c1"># GPU intensive training code goes here</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span><span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
Expand All @@ -132,15 +132,15 @@ <h2>CodeCarbon API<a class="headerlink" href="#id1" title="Link to this heading"
<p>And so on for your team, project and experiment.</p>
<p>You then have to set you experiment id in CodeCarbon, with two options:</p>
<p>In the code:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">codecarbon</span> <span class="kn">import</span> <span class="n">track_emissions</span>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">codecarbon</span><span class="w"> </span><span class="kn">import</span> <span class="n">track_emissions</span>

<span class="nd">@track_emissions</span><span class="p">(</span>
<span class="n">measure_power_secs</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span>
<span class="n">api_call_interval</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span>
<span class="n">experiment_id</span><span class="o">=</span><span class="s2">&quot;your experiment id&quot;</span><span class="p">,</span>
<span class="n">save_to_api</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">def</span> <span class="nf">train_model</span><span class="p">():</span>
<span class="k">def</span><span class="w"> </span><span class="nf">train_model</span><span class="p">():</span>
<span class="o">...</span>
</pre></div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/comet.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Comet Integration &mdash; CodeCarbon 3.0.2 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<title>Comet Integration &mdash; CodeCarbon 3.0.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />


<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=3f474186"></script>
<script src="_static/documentation_options.js?v=9b3fc59f"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/edit/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# The full version, including alpha/beta/rc tags

release = "3.0.2"
release = "3.0.3"

# -- General configuration ---------------------------------------------------

Expand Down
Loading
Loading