Skip to content
Open
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 .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Here's what you need to know to navigate and contribute effectively.
### Key Directories

- **tests/** - Unit tests for the core package
- **docs/** - Sphinx documentation (build with `uv run task docs`)
- **docs/** - Zensical documentation (build with `uv run task docs`)
- **examples/** - Usage examples and demos
- **deploy/** - Deployment configurations and scripts

Expand Down
8 changes: 1 addition & 7 deletions .github/pyproject_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_version_from_file(filepath: str, pattern: str) -> str:

def get_all_versions() -> dict:
"""
Read versions from all three files managed by bumpver.
Read versions from files managed by bumpver.

:return: Dict containing versions from all files
"""
Expand All @@ -60,11 +60,6 @@ def get_all_versions() -> dict:
"codecarbon/_version.py", r'^__version__\s*=\s*["\']([^"\']+)["\']'
)

# Get version from docs/edit/conf.py
versions["docs_conf"] = get_version_from_file(
"docs/edit/conf.py", r'^release\s*=\s*["\']([^"\']+)["\']'
)

return versions


Expand Down Expand Up @@ -95,7 +90,6 @@ def check_version_coherence(quiet=False) -> bool:
file_mapping = {
"pyproject_toml": "pyproject.toml [tool.bumpver] current_version",
"codecarbon_version": "codecarbon/_version.py __version__",
"docs_conf": "docs/edit/conf.py release",
}
logging.error(f" {file_mapping[file_key]}: {version}")
logging.error(
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ venv.bak/

# mkdocs documentation
/site
/deploy

# mypy
.mypy_cache/
Expand Down
90 changes: 58 additions & 32 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@

<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->

- [</a> Have a Question?](#have-a-question)
- [</a> Found a Bug?](#found-a-bug)
- [</a> Have a Feature Request?](#have-a-feature-request)
- [Alternative ways of contributing](#alternative-ways-of-contributing)
- [</a> Ready to Contribute!](#ready-to-contribute)
* [Installation](#installation)
* [Some UV commands](#some-uv-commands)
* [Tests](#tests)
* [Stress your computer](#stress-your-computer)
* [Update all dependancies](#update-all-dependancies)
* [Branching and Pull Requests](#branching-and-pull-requests)
* [Debug in VS Code](#debug-in-vs-code)
* [Coding style && Linting](#coding-style-linting)
* [Dependencies management](#dependencies-management)
* [Build Documentation 🖨️](#build-documentation)
* [Release process](#release-process)
+ [Test the build in Docker](#test-the-build-in-docker)
- [API and Dashboard](#api-and-dashboard)
* [CSV Dashboard](#csv-dashboard)
* [Web dashboard](#web-dashboard)
* [API](#api)
* [Test the API](#test-the-api)
* [Restore database from a production Backup](#restore-database-from-a-production-backup)
* [Deployment](#deployment)
+ [API](#api-1)
+ [Dashboard](#dashboard)
- [License](#license)
- [Contributing to Code Carbon](#contributing-to-code-carbon)
- [ Have a Question?](#-have-a-question)
- [ Found a Bug?](#-found-a-bug)
- [ Have a Feature Request?](#-have-a-feature-request)
- [Alternative ways of contributing](#alternative-ways-of-contributing)
- [ Ready to Contribute!](#-ready-to-contribute)
- [Installation](#installation)
- [Some UV commands](#some-uv-commands)
- [Tests](#tests)
- [Stress your computer](#stress-your-computer)
- [Update all dependancies](#update-all-dependancies)
- [Branching and Pull Requests](#branching-and-pull-requests)
- [Debug in VS Code](#debug-in-vs-code)
- [Coding style \&\& Linting](#coding-style--linting)
- [Dependencies management](#dependencies-management)
- [Build Documentation 🖨️](#build-documentation-️)
- [Release process](#release-process)
- [Test the build in Docker](#test-the-build-in-docker)
- [API and Dashboard](#api-and-dashboard)
- [CSV Dashboard](#csv-dashboard)
- [Web dashboard](#web-dashboard)
- [API](#api)
- [Test the API](#test-the-api)
- [Restore database from a production Backup](#restore-database-from-a-production-backup)
- [Deployment](#deployment)
- [API](#api-1)
- [Dashboard](#dashboard)
- [License](#license)

<!-- TOC end -->

Expand Down Expand Up @@ -225,7 +226,7 @@ Here is the launch.json to be able to debug examples and tests:

Then run opened test with this button:

![vscode_debug](docs/edit/images/vscode_debug.png)
![vscode_debug](docs/images/vscode_debug.png)


<!-- TOC --><a name="coding-style-linting"></a>
Expand Down Expand Up @@ -271,15 +272,40 @@ Dependencies are defined in different places:
### Build Documentation 🖨️

No software is complete without great documentation!
To make generating documentation easier, we use [`sphinx` package](https://www.sphinx-doc.org/en/master/usage/installation.html#installation-from-pypi).
To make generating documentation easier, we use [Zensical](https://zensical.org/).

In order to make changes, edit the `.rst` files that are in the `/docs/edit` folder, and then run in root folder:
In order to make changes, edit the `.md` files in the `/docs` folder, and then run in root folder:

```sh
uv run --only-group doc task docs
```

to regenerate the html files.
to regenerate the html files. For local preview with live reload, run `uv run --only-group doc task docs-serve`.

### Rebase your branch on master

Before creating a PR, please make sure to rebase your branch on master to avoid merge conflicts and make the review easier. You can do it with the following command:
```sh
# Be careful, this command will delete every local changes you have, make sure to commit or stash them before running it
TARGET_BRANCH=master
current_branch=$(git symbolic-ref --short HEAD)
git switch $TARGET_BRANCH && git pull
git switch $current_branch --force && git fetch origin $TARGET_BRANCH
git rebase $TARGET_BRANCH
```

In case of a conflict during a rebase, "incoming" refers to your branch, and "current" refers to master. This is because the commits from your branch are being applied to master, so they are incoming. In case of a merge, it's the opposite!

Check if everything is fine:

```sh
git status
```

Push force
```sh
git push --force-with-lease
```

### Rebase your branch on master

Expand Down Expand Up @@ -313,7 +339,7 @@ git push --force-with-lease
- Create a PR bumping the version with `uv run bumpver update --patch`. For a release candidate, use `uv run bumpver update --set-version 3.0.0_rc1`.
- Run `uv run python .github/pyproject_versions.py -c` to check version consistancy.
- Update the dependencies with `uv sync --upgrade`
- [Build Documentation](#documentation) with `uv run --only-group doc task docs`.
- [Build Documentation](#build-documentation) with `uv run --only-group doc task docs`.
- Push the changes.
- Merge the PR.
- Wait for the Github Action `ReleaseDrafter` to finish running on the merge commit.
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![banner](docs/edit/images/banner.png)
![banner](docs/images/banner.png)

Estimate and track carbon emissions from your computer, quantify and analyze their impact.

Expand All @@ -22,14 +22,18 @@ CodeCarbon websites:

- [About CodeCarbon 💡](#about-codecarbon-)
- [Quickstart 🚀](#quickstart-)
- [Installation 🔧](#installation-)
- [Start to estimate your impact 📏](#start-to-estimate-your-impact-)
- [Monitoring your whole machine](#monitoring-your-machine-)
- [In your python code](#in-your-python-code-)
- [Visualize](#visualize-)
- [Installation 🔧](#installation-)
- [Start to estimate your impact 📏](#start-to-estimate-your-impact-)
- [Without using the online dashboard](#without-using-the-online-dashboard)
- [With the online dashboard](#with-the-online-dashboard)
- [Monitoring your machine 💻](#monitoring-your-machine-)
- [Detecting your hardware 🔍](#detecting-your-hardware-)
- [In your Python code 🐍](#in-your-python-code-)
- [Visualize 📊](#visualize-)
- [Contributing 🤝](#contributing-)
- [How To Cite 📝](#how-to-cite-)
- [Contact 📝](#contact-)
- [Star History](#star-history)

# About CodeCarbon 💡

Expand All @@ -45,7 +49,7 @@ At **CodeCarbon**, we believe, along with Niels Bohr, that "Nothing exists until

We created a Python package that estimates your hardware electricity power consumption (GPU + CPU + RAM) and we apply to it the carbon intensity of the region where the computing is done.

![calculation Summary](docs/edit/images/calculation.png)
![calculation Summary](docs/images/calculation.png)

We explain more about this calculation in the [**Methodology**](https://mlco2.github.io/codecarbon/methodology.html#) section of the documentation.

Expand Down Expand Up @@ -128,7 +132,7 @@ There is other ways to use **codecarbon** package, please refer to the documenta
## Visualize 📊

You can now visualize your experiment emissions on the [dashboard](https://dashboard.codecarbon.io/).
![dashboard](docs/edit/images/dashboard.png)
![dashboard](docs/images/dashboard.png)


> Hope you enjoy your first steps monitoring your carbon computing impact!
Expand Down
4 changes: 0 additions & 4 deletions docs/.buildinfo

This file was deleted.

Binary file removed docs/_images/Experiment&run.png
Binary file not shown.
Loading
Loading