Ozon3Org / Ozon3

An open-source Python package to easily obtain real-time, historical, or forecasted air quality data for anywhere in the world. Reliable, accurate and simple.
GNU General Public License v3.0
66 stars 23 forks source link

fix: Make `get_multiple_*` methods pass tests by not halting for one bad input #128

Closed lahdjirayhan closed 2 years ago

lahdjirayhan commented 2 years ago

As laid out by the tests, get_multiple_*_air methods shouldn't halt when there is one bad input. One bad input (which in turn will make backend return error/bad response, which will make an exception raised in our part) shouldn't halt the execution of other, likely good, inputs. This is not convenient. For what it's worth, I've always treated get_multiple_* methods as convenience wrappers for their single get_*_air counterparts (otherwise I could just loop them myself).

The example in my mind is this: you are mass-collecting data for a hundred cities. One city turns out to not have AQI station and subsequently raise exception (you likely won't know this in advance). It will be annoying to have the other 99 cities halted.

I realize that this will make an odd difference between e.g. get_city_air (raises exception on bad response) and get_multiple_cities_air (returns nan row on bad response). I don't have really much to say either supporting or against.

Is this a good or common enough use case? Should I implement things differently? I'm curious to hear more.

Milind220 commented 2 years ago

@lahdjirayhan Absolutely! This is something that definitely occurred to me before, but I didn't give it enough thought. The use case that you mentioned of dozens of cities (or more) is certainly one that would be annoying without this.

I think it's a badly needed improvement. Excited that the tests are helping so much! Thanks again for making such a robust set of tests.