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

Carbon Intensity Fetcher Error #64

Open
raghavian opened this issue Feb 23, 2024 · 1 comment
Open

Carbon Intensity Fetcher Error #64

raghavian opened this issue Feb 23, 2024 · 1 comment

Comments

@raghavian
Copy link
Collaborator

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
Copy link
Collaborator Author

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"

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

No branches or pull requests

1 participant