NREL / REopt-Analysis-Scripts

BSD 3-Clause "New" or "Revised" License
34 stars 35 forks source link

JSONDecodeError #15

Closed Fahad021 closed 3 years ago

Fahad021 commented 3 years ago

How to get around this error?

File "/home/ec2-user/SageMaker/src/post_and_poll.py", line 23, in get_api_results results = poller(url=results_url.replace('', run_id)) File "/home/ec2-user/SageMaker/src/results_poller.py", line 26, in poller resp_dict = json.loads(resp.content) File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

NLaws commented 3 years ago

@Fahad021 how would one recreate this error?

Fahad021 commented 3 years ago

@Fahad021 how would one recreate this error?

Hi @NLaws , when Reopt server was down, i was getting this error. So, when server was not returning an object that jsondecoder accepts, that created the error.

NLaws commented 3 years ago

The error stems from this line because the API was down as you said. There are a lot of ways to get around this, perhaps the easiest of which would be to wrap that line with a try/except block.

NLaws commented 3 years ago

Closing this since it is not an issue with the code in this repo (the problem was that the API was temporarily down due to Rancher issues).