Giter VIP home page Giter VIP logo

tracarbon's Introduction

Alt text

doc pypi example workflow

πŸ“Œ 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

# Install Tracarbon
pip install tracarbon
# Install one or more exporters from the list
pip install 'tracarbon[datadog]'

πŸ”Œ Devices: energy consumption

Devices Description
Mac βœ… Global energy consumption of your Mac (must be plugged into a wall adapter).
Linux ❌ Not yet implemented.
Windows ❌ Not yet implemented.
Cloud Provider Description
AWS βœ… Used the CPU 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.
Datadog Send the metrics to Datadog.

πŸ—ΊοΈ Locations

Location Description Source
Europe Static file of the European Environment Agency Emission for the co2g/kwh for European countries. EEA website
France Get the co2g/kwh in near real-time using the RTE energy consumption. RTE API
AWS Static file of the AWS Grid emissions factors. cloud-carbon-coefficients

βš™οΈ Configuration

Parameter Description
TRACARBON_API_ACTIVATED The activation of the real-time data collection of the carbon emission factor.
TRACARBON_METRIC_PREFIX_NAME The prefix to use in all the metrics name.
TRACARBON_INTERVAL_IN_SECONDS The interval in seconds to wait between the metrics evaluation.
TRACARBON_LOG_LEVEL The level to use for displaying the logs.

πŸ”Ž Usage

Command Line

tracarbon run Stdout

API

from tracarbon import CarbonEmission
from tracarbon.exporters import Metric, StdoutExporter

metric = Metric(
    name="co2_emission",
    value=CarbonEmission().run,
    tags=[],
)
exporter = StdoutExporter(metrics=[metric])
exporter.start()
# Your code
exporter.stop()

with exporter:
    # Your code

πŸ’» Development

Local: using Poetry

make setup
make unit-test

πŸ›‘οΈ Licence

Apache License 2.0

πŸ“š Documentation

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

tracarbon's People

Contributors

fvaleye avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.