Send emissions data to HTTP endpoint Warning : This is an empty model to guide you. We do not provide a server.
| 10 | |
| 11 | |
| 12 | class 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 | |
| 36 | class CodeCarbonAPIOutput(BaseOutput): |
no outgoing calls
searching dependent graphs…