MCPcopy Create free account
hub / github.com/mlco2/codecarbon / HTTPOutput

Class HTTPOutput

codecarbon/output_methods/http.py:12–33  ·  view source on GitHub ↗

Send emissions data to HTTP endpoint Warning : This is an empty model to guide you. We do not provide a server.

Source from the content-addressed store, hash-verified

10
11
12class HTTPOutput(BaseOutput):
13 """
14 Send emissions data to HTTP endpoint
15 Warning : This is an empty model to guide you.
16 We do not provide a server.
17 """
18
19 def __init__(self, endpoint_url: str):
20 self.endpoint_url: str = endpoint_url
21
22 def out(self, total: EmissionsData, _: EmissionsData):
23 try:
24 payload = dataclasses.asdict(total)
25 payload["user"] = getpass.getuser()
26 resp = requests.post(self.endpoint_url, json=payload, timeout=10)
27 if resp.status_code != 201:
28 logger.warning(
29 "HTTP Output returned an unexpected status code: ",
30 resp,
31 )
32 except Exception as e:
33 logger.error(e, exc_info=True)
34
35
36class CodeCarbonAPIOutput(BaseOutput):

Callers 2

_init_output_methodsMethod · 0.90
setUpMethod · 0.90

Calls

no outgoing calls

Tested by 1

setUpMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…