Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Satsearch "limit" keyword bugs with E84 earthsearch endpoint #109

Open
scottyhq opened this issue Nov 17, 2020 · 0 comments
Open

Satsearch "limit" keyword bugs with E84 earthsearch endpoint #109

scottyhq opened this issue Nov 17, 2020 · 0 comments

Comments

@scottyhq
Copy link

Setting a limit keyword arg has unexpected results:

import satsearch
URL='https://earth-search.aws.element84.com/v0'
results = satsearch.Search.search(url=URL,
                                  collections=['sentinel-s2-l2a-cogs'],
                                  bbox=[-54, 67.65, -50, 69.37],
                                  datetime='2019-08-15/2020-08-15',
                                  limit=200,
                                 )
print(f'{len(results.items())} S2 Items')

There are more items found (2158) than the limit (200) provided.
500 S2 Items

( I expect to have 200 items returned)

  1. changing limit to 700 in the above codeblock surprising leads to:

There are more items found (2158) than the limit (700) provided.
1000 S2 Items

  1. increasing limit to a value greater than the total items found results in a internal server error:
---------------------------------------------------------------------------
SatSearchError                            Traceback (most recent call last)
<ipython-input-4-6c0f70cd4c07> in <module>
      7                                   limit=2500,
      8                                  )
----> 9 print(f'{len(results.items())} S2 Items')

~/miniconda3/envs/intake-stac-gui/lib/python3.7/site-packages/satsearch/search.py in items(self, limit, page_limit, headers)
     88     def items(self, limit=10000, page_limit=500, headers=None):
     89         """ Return all of the Items and Collections for this search """
---> 90         found = self.found(headers=headers)
     91         limit = self.limit or limit
     92         if found > limit:

~/miniconda3/envs/intake-stac-gui/lib/python3.7/site-packages/satsearch/search.py in found(self, headers)
     60         url = urljoin(self.url, 'search')
     61 
---> 62         results = self.query(url=url, headers=headers, **kwargs)
     63         # TODO - check for status_code
     64         logger.debug(f"Found: {json.dumps(results)}")

~/miniconda3/envs/intake-stac-gui/lib/python3.7/site-packages/satsearch/search.py in query(self, url, headers, **kwargs)
     78         # API error
     79         if response.status_code != 200:
---> 80             raise SatSearchError(response.text)
     81         return response.json()
     82 

SatSearchError: {"message": "Internal server error"}

This PR seems related #107 (Hi @acannistra!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant