...
File "path/to/helpers.py", line 51, in get_weather_file_from_api
fetcher = wtkfetcher.fetch(lon_lats)
File "PySAM/ResourceTools.py", line 577, in fetch
results.append(self.data_function(job))
File "PySAM/ResourceTools.py", line 503, in _NSRDB_worker
data_response_json = data_response.json()
File "requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
This issue happened while using pysam to get the weather file for these coordinates (lng=-76.2002669, lat=43.0402873). The problem is that the current implementation expects the response to be always json when the response.status >= 400. However, a 404 response returns some html instead.
It should be noted that I was not able to replicate the error again (running the same code with the above coordinates returns the weather file). Some possible explanations:
https://gds-hsds-nsrdb-files.nrelcloud.orgusually has the headerx-amz-expiration: expiry-date="Thu, 29 Jul 2021 00:00:00 GMT", rule-id="24 hour retention"on it. The error I'm reporting happened atJul 17, 2021 12:33:53 AM UTCwhich seems to be somewhat close to when those files are usually set to expire.Even though the issue can't be replicated, I think it's worth it to fix it.
Additional Info
The API call in question that returned a 404 instead of the expected csv file
PySAM expected the response to be json while the response was actually some html
The relevant part of the traceback
The code used to get the weather file