-
Notifications
You must be signed in to change notification settings - Fork 91
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
Confusing error when submitting list instead of tuple for temporal
parameter
#804
Comments
temporal
temporal
parameter
Our implementation of the temporal filter does nothing other than override typing and docstring of the python_cmr method. Is the best resolution for this issue to add a type check on the argument before calling earthaccess/earthaccess/search.py Lines 767 to 797 in 699cc4e
Good to bear in mind #488, and (I don't see an issue for this) that we could easily support multiple temporal ranges because python_cmr already supports it. |
We also splat the arg's container IFF the container is a tuple: earthaccess/earthaccess/search.py Lines 508 to 512 in 699cc4e
Yeah, I think so! At least maybe for now. But also, I feel like the "splat the arg only if it's a tuple" behavior is a bit confusing, or at the wrong level of abstraction. I feel like we should never mess with the args at the If we add this handling to the What do you think, Ian? |
Just picking up on this thread as I explore how we could replace icepyx.Query with earthaccess.search (icesat2py/icepyx#575). One of the things I'm finding (here temporal is the relevant input, but it's also the case for spatial) is that icepyx is a lot more flexible and forgiving (and broad) in terms of the inputs it accepts. For instance, users can input not only dates but times (if they want), and icepyx will either use defaults or pass those days/times through all functions. To do this, we essentially have a temporal module that takes the user input (tuple or list, of strings, date, or datetime objects) with optional start and end time kwargs (if they're not already attached to an input datetime object) and makes sure the user inputs can all be turned into valid datetime objects. Then we attach these internally-defined temporal objects as private variables to our query object, and use that temporal module to manipulate our "validated" datetimes for whereever we need to pass it next (like CMR). The motivation for this (and especially for the analogous spatial version; the temporal module is much simpler!) was that we could turn multiple types of user input into a single "desired" (and validated) object, and then depending on what the user asks for later we have a "known" version of it we can easily manipulate (e.g. to pass in whatever format the API we're calling needs - like I bring this up here because I've been grappling with some questions that I think are relevant to this conversation (I'll limit it to temporal ones for thread relevance):
|
Is this issue already tracked somewhere, or is this a new report?
Current Behavior
The error is confusing because it comes from python-cmr after earthaccess has done stuff with the parameters and passed them on. This message tells me I should pass a string instead of a list when it should be telling me to pass a tuple instead of a list.
Expected Behavior
Error should reflect that the container is the wrong type, e.g.
Temporal must be a tuple of date objects or ISO8601 strings
, or earthaccess should handle the input in a way that gives python-cmr the correct container when the user makes a trivial mistake like this.Steps To Reproduce
Environment
Additional Context
No response
The text was updated successfully, but these errors were encountered: