mesowx / MesoPy

A Python wrapper for the MesoWest environmental data API
MIT License
58 stars 23 forks source link

groupby keyword documentation does not match use capabilities #30

Open n8geo opened 6 years ago

n8geo commented 6 years ago

When I make requests and use the groupby keyword for methods such as: latest, the groupby keyword is limited to MNET, GACC, and SUBGACC and other key words result in a MesoPyError.

Docs state: groupby: string, optional Results can be grouped by key words: state, county, country, cwa, nwszone, mwsfirezone, gacc, subgacc e.g. groupby='state'

However, behavior is: latest = meso.latest(stid=','.join(afc), groupby='nwszone')

MesoPyError Traceback (most recent call last)

in () ----> 1 latest = meso.latest(stid=','.join(afc), groupby='nwszone') /usr/local/lib/python3.6/site-packages/MesoPy.py in latest(self, **kwargs) 331 kwargs['token'] = self.token 332 --> 333 return self._get_response('stations/latest', kwargs) 334 335 def precip(self, start, end, **kwargs): /usr/local/lib/python3.6/site-packages/MesoPy.py in _get_response(self, endpoint, request_dict) 160 except urllib.error.URLError: 161 raise MesoPyError(http_error) --> 162 return self._checkresponse(json.loads(resp.decode('utf-8'))) 163 164 def _check_geo_param(self, arg_list): /usr/local/lib/python3.6/site-packages/MesoPy.py in _checkresponse(response) 119 elif response['SUMMARY']['RESPONSE_CODE'] == -1: 120 format_error = response['SUMMARY']['RESPONSE_MESSAGE'] --> 121 raise MesoPyError(format_error) 122 else: 123 raise MesoPyError(catch_error) MesoPyError: 'GROUPBY must be either MNET, GACC, or SUBGACC.' This is true for key words: state, county, country, cwa, nwszone, and mwsfirezone. And that last one seems like a typo, should mwsfirezone actually be: nwsfirezone?
joeyoun9 commented 6 years ago

Hi N8geo,

You are correct that our documentation and actual API are inconsistent WRT groupby valid arguments. However, I am afraid the issue is slightly deeper, in that I can't commit that the groupby argument actually changes the API function whatsoever. It probably needs to be deprecated as a whole from the API.

We have started an internal discussion to this end. But at this point the most relevant answer is that the docs are definitely wrong (both in MesoPy and our online resources) and the API error output is correct, it will only allow MNET, GACC and SUBGACC as values (before it does nothing with them)