Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python binding for Scaphandre. #184

Merged

Conversation

fvaleye
Copy link
Contributor

@fvaleye fvaleye commented Jul 3, 2022

Description

  • Add Python binding (>3.7) using pyo3 to call Scaphandre Rust code from Python.
  • Add the first version with the sensor PowercapRAPL as default.
  • Expose 3 methods: init, is_compatible and get_energy_consumption_measures.
  • Add Python documentation.
  • Expose Rust version Scaphandre crate

Documentation

@mrchrisadams
Copy link
Contributor

Hi there - would PR this mean you could install Scaphandre on a machine by doing pip install scaphandre access its output as python objects?

If so, I'd be happy to contribute some docs on how to use it in python applications.

@fvaleye
Copy link
Contributor Author

fvaleye commented Jul 5, 2022

Hello @mrchrisadams 👋,

Not yet but that's the goal, call Scaphandre Rust codebase from Python 👍

As a follow-up after this PR, we could publish the scaphandre Python package in pypi and you could install it using pip as you described with pip install scaphandre.

The documentation is already implemented in this PR so we could include documentation using Sphinx, any contributions on this would be welcomed!

@demeringo
Copy link
Contributor

Hello, @fvaleye, do you plan to use Scaphandre in tracarbon ?

@fvaleye
Copy link
Contributor Author

fvaleye commented Jul 6, 2022

Hello @demeringo 👋,

If this PR is accepted and merged, yes 👍

Using Scaphandre to get electrical power consumption metrics for Tracarbon, the focus will be more on calculating the associated carbon emissions instead of redeveloping or integrating energy consumption sensors in it. This Python binding could be extended by exposing other Rust functions of Scaphandre and several use cases could be activated by having only Python as a requirement.

@mrchrisadams
Copy link
Contributor

ok, thanks @fvaleye.

Oh neat - I had no idea Tracarbon existed!

We've been doing something similar - we've been building a library for getting carbon intensity from various providers of this data, to use with tooling like Scaphandre, and integrate into anything written in Go (i.e. schedulers like Nomad and K8s, and so on).

https://github.com/thegreenwebfoundation/grid-intensity-go

I'll look over Tracarbon, as previously I had been looking at tools like codecarbon as a way for python apps to self describe their own resource footprint, but it ends up duplicating some of what Scaphandre already does, and if it's consuming output from Scaphandre, that feels like it reduces duplication of work 👍

@bpetit bpetit added this to the Release v0.6.0 milestone Aug 10, 2022
@bpetit
Copy link
Contributor

bpetit commented Mar 4, 2023

Hi @fvaleye !

Review is ok !

Merge on the way !

@bpetit bpetit merged commit b9cbcbe into hubblo-org:main Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Previous releases
Development

Successfully merging this pull request may close these issues.

4 participants