sofarocean / sofar-api-client-python

Python Client for Wavefleet
Apache License 2.0
7 stars 5 forks source link

Using Spotter.grab_data() fails when attempting to get data from a Spotter you don't own but have access to #14

Closed g-mo closed 2 years ago

g-mo commented 2 years ago

The return payload from grab_data() is expected to have a limit key in it but it doesn't when you don't own the Spotter you're accessing. When this happens, this line triggers a KeyError

tcj commented 2 years ago

Ran into this today. Thanks for the pointer @g-mo.

What thoughts do you have on a potential resolution? Would it likely be server-side or client-side?

tcj commented 2 years ago

https://github.com/sofarocean/sofar-api-client-python/blob/e93ff9e97867a620345fa8d590b8dcf048d0e4ae/src/pysofar/sofar.py#L586-L597

The line in question sets a variable that is only being used by a line that is commented out. This line sets lim:

lim = _query['limit']

and/but it looks like lim is only being used here:

# len(results) < lim

So might it be possible to also comment out the line that sets lim as a possible way to resolve this issue?

tcj commented 2 years ago

Confirmed, commenting out this line allows client to advance with no further tracebacks.

https://github.com/sofarocean/sofar-api-client-python/blob/e93ff9e97867a620345fa8d590b8dcf048d0e4ae/src/pysofar/sofar.py#L586

tcj commented 2 years ago

This was still happening to me today, even while on pysofar 0.1.13. May need to look into this.