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 output to loggers option #297

Merged
merged 5 commits into from
Apr 26, 2022

Conversation

HerveMignot
Copy link

Logger Output

New feature

Add two classes to output emissions data to loggers:

  • LoggerOutput(): output to Python logging logger.
  • GoogleCloudLoggerOutput(): output to Google Cloud Logging. This sends emissions data of tracked scripts/workloads to some project Cloud Logging

Emissions data are logged as a JSON record, on tracker.stop()

See Collecting emissions to a logger.md for additional explanations & examples.

Files modified

  • codecarbon/output.py: add new classes
  • codecarbon/emissions_tracker.py: add arguments for saving to loggers

Note: .pre-commit-config.yaml has been updated to black 22.3.0 since version 21 is broken by click 8.1.

Files added

  • tests/test_logging_output.py: LoggerOutput test case
  • examples/logging_demo.py: example to demonstrate usage from the command line
  • Collecting emissions to a logger.md: explanations & examples

Misc

pre-commit has been applied.

Roadmap

  • Add option to format / structure output to loggers
  • Add support for AWS & Azure logging facilities.

@SaboniAmine
Copy link
Collaborator

SaboniAmine commented Apr 20, 2022

Hello, thank you for your contribution!
Sending logs directly to a managed logging service is something we hadn't thought of. Could you please give us details about your usage of those logs ?

@HerveMignot
Copy link
Author

We use these logs (and especially the capabilities to collect them centrally through syslog based systems) to collect emissions from several data pipelines running on data platforms we develop. In the case of Google Cloud, Cloud Logging service allows to easily collect these logs and use Cloud Monitoring for dashboarding emissions by process.
Hope this helps.

@SaboniAmine
Copy link
Collaborator

It really does, thank you!
We propose a hosted API, on which you could also persist data from your different pipelines, with a dashboard which will let users within an organisation centralize & share their data (this is still in building phase).
Would it be something useful in your case ?

@SaboniAmine SaboniAmine merged commit 0f13326 into mlco2:master Apr 26, 2022
@HerveMignot
Copy link
Author

This could be an option in some cases.

The advantage with the logging facility is that codecarbon messages end up with other logging message. Supervisors have a central source for logs to use.

@benoit-cty
Copy link
Contributor

Thanks for your contribution, it is now available for all in the last release https://pypi.org/project/codecarbon/2.1.0/

The dashboard Amine was talking about is live at http://dashboard.codecarbon.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants