sb-ai-lab / Eco2AI

eco2AI is a python library which accumulates statistics about power consumption and CO2 emission during running code.
Apache License 2.0
226 stars 18 forks source link

Feature for sending consumption data via webhook #7

Closed andvarfolomeev closed 1 year ago

andvarfolomeev commented 1 year ago

To use, you need to pass a parameter with a string to the url. For Example:

import time

from eco2ai import Tracker

tracker = Tracker(
    alpha_2_code="RU",
    region="Primorskiy Kray",
    cpu_processes="all",
    webhook_url="http://localhost:8000/webhook", # <--
    measure_period=1,
)

tracker.start()

for i in range(10):
    time.sleep(1)

tracker.stop()

I wrote a test server to test. To run it, you need to write the command docker run -p 8000:8000 -t ada0l/ada0l-eco2ai-playground