lfwa / carbontracker

Track and predict the energy consumption and carbon footprint of training deep learning models.
MIT License
382 stars 29 forks source link

Carbon Intensity Fetcher Error #64

Open raghavian opened 8 months ago

raghavian commented 8 months ago

Recurrent error, mostly something with the python version (3.8) or the API format to electricitymaps.com. Pasting the error message here.


  File "/home/image/miniconda3/lib/python3.8/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/home/image/miniconda3/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/home/image/miniconda3/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/image/miniconda3/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/image/miniconda3/lib/python3.8/site-packages/carbontracker/emissions/intensity/intensity.py", line 105, in carbon_intensity
    carbon_intensity = fetcher.carbon_intensity(g_location, time_dur)
  File "/home/image/miniconda3/lib/python3.8/site-packages/carbontracker/emissions/intensity/fetchers/energidataservice.py", line 21, in carbon_intensity
    ci = self._emission_prognosis(time_dur=time_dur)
  File "/home/image/miniconda3/lib/python3.8/site-packages/carbontracker/emissions/intensity/fetchers/energidataservice.py", line 48, in _emission_prognosis
    raise exceptions.CarbonIntensityFetcherError(response.json())
  File "/home/image/miniconda3/lib/python3.8/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) ```
raghavian commented 8 months ago

I don't know if this is a python version mismatch or due to an update in electricitymaps API. But these two changes now fixes it: Change time string formatting here to: date_format = "%Y-%m-%dT%H:%M"

And the parsing of url here should not have any curly brackets.

url = "https://api.energidataservice.dk/dataset/CO2Emis?start=" + from_str + "&end=" + to_str + "&limit=4"