-
Notifications
You must be signed in to change notification settings - Fork 85
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
Expected type of search_data() "bounding_box" seems too narrow #279
Comments
Good catch! Looks like we're specifically checking for tuples and splatting them. If we were also splatting lists in the same way, that would solve this issue, but would it possibly introduce another issue? @betolink
|
It would be useful to accept a list where we currently have tuples, the reason to use tuples is that |
We'll move forward with updating https://earthaccess.readthedocs.io/en/latest/user-reference/api/api/#earthaccess.api.search_data for both temporal and bounding box to clarify that tuple is required. |
We also discussed coming back to handling list-like objects with 4 elements at a future time. |
Addresses #279, but does not resolve it.
Circling back with some research from another ticket: We can achieve this with Pydantic's runtime validation decorator: https://docs.pydantic.dev/latest/concepts/validation_decorator/#argument-types |
Not sure if this is helpful, but a couple years ago we separated out the temporal and spatial handling in icepyx to their own modules. Each module (here the examples are spatial) parses the user input (e.g. bbox lists, polygons, and shapefiles are accepted for the spatial ones), verifies that it's a valid geometry, and stores it as a list of coordinates. Additional functions make it easy to then return that verified spatial info in whatever format is needed (a geodataframe; a string formatted for cmr (or EGI); a string formatted for another API). I'm not sure if this is a good programmatic approach from a dev perspective, but I'd be happy to brainstorm if this sort of thing would be a good fit for earthaccess to allow users a broader set of input types (and if it makes sense to push these modules upstream). |
This is documented in the API but not in User Guide. |
We may still need a decision here on whether to support lists in the future. This may be a good example for a decision committee (#761 ) |
Would love to see some progress on this item, as I'm teaching |
Agreed we should make a decision on this, and I think we should try to make that decision as a more general rule that can save time on future decisions. I think we should adopt the API design principle: Specify inputs loosely, i.e. take any sequence with 4 elements for a bounding box (( |
It ties in with some ongoing conversation over in #804 too. |
The following generates a
TypeError
(Traceback at bottom of post):While this example works as expected (no error):
It's not immediately obvious from the documentation that
bounding_box
must be a tuple.Maybe there is a good reason that a
list
type is not acceptable? It seems to me likelist
andtuple
should both be accepted.Traceback:
The text was updated successfully, but these errors were encountered: