tracarbon

🌍 Tracarbon tracks your device's energy consumption and calculates your carbon emissions using your location.

https://github.com/fvaleye/tracarbon

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • β—‹
    CITATION.cff file
  • βœ“
    codemeta.json file
    Found codemeta.json file
  • βœ“
    .zenodo.json file
    Found .zenodo.json file
  • β—‹
    DOI references
  • β—‹
    Academic publication links
  • β—‹
    Committers with academic emails
  • β—‹
    Institutional organization owner
  • β—‹
    JOSS paper metadata
  • β—‹
    Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords

carbon-footprint electricity-consumption energy energy-consumption energy-efficiency sustainability

Keywords from Contributors

projection interactive serializer cycles packaging charts network-simulation shellcodes hacking autograding
Last synced: 10 months ago · JSON representation

Repository

🌍 Tracarbon tracks your device's energy consumption and calculates your carbon emissions using your location.

Basic Info
Statistics
  • Stars: 104
  • Watchers: 5
  • Forks: 7
  • Open Issues: 6
  • Releases: 33
Topics
carbon-footprint electricity-consumption energy energy-consumption energy-efficiency sustainability
Created over 4 years ago · Last pushed 11 months ago
Metadata Files
Readme License Code of conduct Codeowners

README.md

Tracarbon Logo

example workflow pypi doc licence

πŸ“Œ Overview

Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.

It detects your location and your device automatically before starting to export measurements to an exporter. It could be used as a CLI with already defined metrics or programmatically with the API by defining the metrics that you want to have.

Read more in this article.

πŸ“¦ Where to get it

```sh

Install Tracarbon

pip install tracarbon ```

```sh

Install one or more exporters from the list

pip install 'tracarbon[datadog,prometheus,kubernetes]' ```

πŸ”Œ Devices: energy consumption

| Devices | Description | | ----------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | Mac | βœ… Global energy consumption of your Mac (must be plugged into a wall adapter). | | Linux | ⚠️ Only with RAPL. See #1. It works with containers on Kubernetes using the Metric API if available. | | Windows | ❌ Not yet implemented. See #184. |

| Cloud Provider | Description | | ------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | | AWS | βœ… Use the hardware's usage with the EC2 instances carbon emissions datasets of cloud-carbon-coefficients. | | GCP | ❌ Not yet implemented. | | Azure | ❌ Not yet implemented. |

πŸ“‘ Exporters

| Exporter | Description | | ------------ | :-------------------------------: | | Stdout | Print the metrics in Stdout. | | JSON | Write the metrics in a JSON file. | | Prometheus | Send the metrics to Prometheus. | | Datadog | Send the metrics to Datadog. |

πŸ—ΊοΈ Locations

| Location | Description | Source | | ------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Worldwide | Get the latest co2g/kwh in near real-time using the CO2Signal or ElectricityMaps APIs. See here for the list of available zones. | CO2Signal API or ElectricityMaps | | Europe | Static file created from the European Environment Agency Emission for the co2g/kwh in European countries. | EEA website | | AWS | Static file of the AWS Grid emissions factors. | cloud-carbon-coefficients |

βš™οΈ Configuration

The environment variables can be set from an environment file .env.

| Parameter | Description | | ----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | TRACARBONCO2SIGNALAPIKEY | The api key received from CO2Signal or ElectricityMaps. | | TRACARBONCO2SIGNALURL | The url of CO2Signal is the default endpoint to retrieve the last known state of the zone, but it could be changed to ElectricityMaps. | | TRACARBONMETRICPREFIXNAME | The prefix to use in all the metrics name. | | TRACARBONINTERVALINSECONDS | The interval in seconds to wait between the metrics evaluation. | | TRACARBONLOG_LEVEL | The level to use for displaying the logs. |

πŸ”Ž Usage

Request your API key

  • Go to CO2Signal and get your free API key for non-commercial use, or go to ElectricityMaps for commercial use.
  • This API is used to retrieve the last known carbon intensity (in gCO2eq/kWh) of electricity consumed in your location.
  • Set your API key in the environment variables, in the .env file or directly in the configuration.
  • If you would like to start without an API key, it's possible, the carbon intensity will be loaded statistically from a file.
  • Launch Tracarbon πŸš€

Command Line

sh tracarbon run

API

```python from tracarbon import TracarbonBuilder, TracarbonConfiguration

configuration = TracarbonConfiguration() # Your configuration tracarbon = TracarbonBuilder(configuration=configuration).build() tracarbon.start()

Your code

tracarbon.stop()

with tracarbon: # Your code

report = tracarbon.report() # Get the report ```

πŸ’» Development

Local: using uv

sh make init make test-unit

πŸ›‘οΈ Licence

Apache License 2.0

πŸ“š Documentation

The documentation is hosted here: https://fvaleye.github.io/tracarbon/documentation

Owner

  • Name: Florian Valeye
  • Login: fvaleye
  • Kind: user
  • Location: France
  • Company: @BackMarket

GitHub Events

Total
  • Create event: 63
  • Issues event: 3
  • Release event: 7
  • Watch event: 5
  • Delete event: 58
  • Issue comment event: 50
  • Push event: 75
  • Pull request review event: 8
  • Pull request event: 108
  • Fork event: 1
Last Year
  • Create event: 63
  • Issues event: 3
  • Release event: 7
  • Watch event: 5
  • Delete event: 58
  • Issue comment event: 50
  • Push event: 75
  • Pull request review event: 8
  • Pull request event: 108
  • Fork event: 1

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 349
  • Total Committers: 5
  • Avg Commits per committer: 69.8
  • Development Distribution Score (DDS): 0.238
Past Year
  • Commits: 56
  • Committers: 3
  • Avg Commits per committer: 18.667
  • Development Distribution Score (DDS): 0.214
Top Committers
Name Email Commits
dependabot[bot] 4****] 266
fvaleye f****e@g****m 79
Patric Gruber me@p****t 2
Brice AIELLO b****o@m****m 1
Florian VALEYE f****e@F****l 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 12
  • Total pull requests: 556
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 5 days
  • Total issue authors: 7
  • Total pull request authors: 4
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.31
  • Merged pull requests: 396
  • Bot issues: 0
  • Bot pull requests: 474
Past Year
  • Issues: 2
  • Pull requests: 123
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 10 days
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.51
  • Merged pull requests: 65
  • Bot issues: 0
  • Bot pull requests: 110
Top Authors
Issue Authors
  • corentinbettiol (3)
  • fvaleye (3)
  • fatma-laribi (2)
  • maxbaiw29 (1)
  • patricgruber (1)
  • AceWang377 (1)
  • JosuaCarl (1)
Pull Request Authors
  • dependabot[bot] (493)
  • fvaleye (81)
  • patricgruber (2)
  • baiello (1)
Top Labels
Issue Labels
enhancement (6) bug (3) help wanted (2) energy-consumption (2) good first issue (1)
Pull Request Labels
dependencies (501) enhancement (37) python (29) release (19) bug (13) documentation (8) energy-consumption (2)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 77 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 66
  • Total maintainers: 1
proxy.golang.org: github.com/fvaleye/tracarbon
  • Versions: 33
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 11 months ago
pypi.org: tracarbon

Tracarbon is a Python library that tracks your device's energy consumption and calculates your carbon emissions.

  • Versions: 33
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 77 Last month
Rankings
Dependent packages count: 10.0%
Average: 17.3%
Downloads: 20.0%
Dependent repos count: 21.7%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/build.yml actions
  • abatilo/actions-poetry v2 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/codeql-analysis.yml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/release.yml actions
  • abatilo/actions-poetry v2 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
Dockerfile docker
  • python 3.8-buster build
poetry.lock pypi
  • Babel 2.11.0 develop
  • GitPython 3.1.30 develop
  • Jinja2 3.1.2 develop
  • MarkupSafe 2.1.1 develop
  • PyYAML 6.0 develop
  • Pygments 2.14.0 develop
  • Sphinx 5.3.0 develop
  • alabaster 0.7.13 develop
  • bandit 1.7.4 develop
  • beautifulsoup4 4.11.1 develop
  • black 22.12.0 develop
  • commonmark 0.9.1 develop
  • coverage 7.0.5 develop
  • docutils 0.19 develop
  • exceptiongroup 1.1.0 develop
  • execnet 1.9.0 develop
  • future 0.18.3 develop
  • gitdb 4.0.10 develop
  • imagesize 1.4.1 develop
  • iniconfig 2.0.0 develop
  • isort 5.11.4 develop
  • mando 0.6.4 develop
  • mypy 0.991 develop
  • mypy-extensions 0.4.3 develop
  • packaging 23.0 develop
  • pathspec 0.10.3 develop
  • pbr 5.11.1 develop
  • platformdirs 2.6.2 develop
  • pluggy 1.0.0 develop
  • pprintpp 0.4.0 develop
  • pydata-sphinx-theme 0.12.0 develop
  • pytest 7.2.1 develop
  • pytest-asyncio 0.20.3 develop
  • pytest-clarity 1.0.1 develop
  • pytest-cov 4.0.0 develop
  • pytest-mock 3.10.0 develop
  • pytest-xdist 3.1.0 develop
  • pytz 2022.7.1 develop
  • radon 5.1.0 develop
  • rich 13.1.0 develop
  • six 1.16.0 develop
  • smmap 5.0.0 develop
  • snowballstemmer 2.2.0 develop
  • soupsieve 2.3.2.post1 develop
  • sphinxcontrib-devhelp 1.0.2 develop
  • sphinxcontrib-htmlhelp 2.0.0 develop
  • sphinxcontrib-jsmath 1.0.1 develop
  • sphinxcontrib-qthelp 1.0.3 develop
  • sphinxcontrib-serializinghtml 1.1.5 develop
  • sphinxcontrib.applehelp 1.0.2 develop
  • stevedore 3.5.2 develop
  • toml 0.10.2 develop
  • tomli 2.0.1 develop
  • typed-ast 1.5.4 develop
  • types-aiofiles 22.1.0.4 develop
  • types-requests 2.28.11.7 develop
  • types-ujson 5.7.0.0 develop
  • types-urllib3 1.26.25.4 develop
  • aiocache 0.12.0
  • aiofiles 22.1.0
  • aiohttp 3.8.3
  • aiosignal 1.3.1
  • async-timeout 4.0.2
  • asynctest 0.13.0
  • attrs 22.2.0
  • cached-property 1.5.2
  • certifi 2022.12.7
  • charset-normalizer 2.1.1
  • click 8.1.3
  • colorama 0.4.6
  • datadog 0.44.0
  • ec2-metadata 2.11.0
  • frozenlist 1.3.3
  • idna 3.4
  • importlib-metadata 6.0.0
  • loguru 0.6.0
  • msgpack 1.0.4
  • multidict 6.0.4
  • prometheus-client 0.15.0
  • psutil 5.9.4
  • pydantic 1.10.4
  • python-dotenv 0.21.0
  • requests 2.28.2
  • typer 0.7.0
  • typing-extensions 4.4.0
  • ujson 5.7.0
  • urllib3 1.26.14
  • win32-setctime 1.1.0
  • yarl 1.8.2
  • zipp 3.11.0
pyproject.toml pypi
  • bandit ^1.7.4 develop
  • black ^22.12.0 develop
  • datadog ^0.44.0 develop
  • isort ^5.11.4 develop
  • mypy ^0.991 develop
  • prometheus-client ^0.15.0 develop
  • pydata-sphinx-theme ^0.12.0 develop
  • pytest ^7.2.0 develop
  • pytest-asyncio ^0.20.3 develop
  • pytest-clarity ^1.0.1 develop
  • pytest-cov ^4.0.0 develop
  • pytest-mock ^3.7.0 develop
  • pytest-xdist ^3.1.0 develop
  • radon ^5.1.0 develop
  • sphinx ^5.3.0 develop
  • toml ^0.10.2 develop
  • types-aiofiles ^22.1.0 develop
  • types-requests ^2.28.11 develop
  • types-ujson ^5.7.0 develop
  • aiocache >=0.11.1,<0.13.0
  • aiofiles ^22.1.0
  • aiohttp ^3.8.1
  • datadog ^0.44.0
  • ec2-metadata ^2.10.0
  • loguru ^0.6.0
  • msgpack ^1.0.4
  • prometheus-client ^0.15.0
  • psutil ^5.9.1
  • pydantic ^1.9.1
  • python ^3.7
  • python-dotenv ^0.21.0
  • typer >=0.4.1,<0.8.0
  • ujson ^5.3.0