-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Fix / test mpc error messages 2022.07 #2466
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2466 +/- ##
==========================================
- Coverage 65.86% 62.92% -2.94%
==========================================
Files 233 133 -100
Lines 17907 17302 -605
==========================================
- Hits 11795 10888 -907
- Misses 6112 6414 +302
... and 180 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
astroquery/mpc/core.py
Outdated
'identifiers correct? Is the MPC ' | ||
'database search working for your ' | ||
'object? The service is hosted at ' | ||
'https://www.minorplanetcenter.net/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually liked the previous error message more, and at minimum we should use the URL from a variable rather than hard wire in here. Maybe the overall issue should be rather mentioned in the docs? (E.g. as everywhere in astroqeury, if a query doesn't work with the web interface then it's not really an issue for astroquery but either an upstream issue/bug or user error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the error instead simply reported what it found? EmptyResponseError("The query returned no observations.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are two main cases when there are no results. One, that should raise an error is when e.g. the identifiers are incorrect, and the service may even return an error itself. OTOH I can think of valid empty responses when all inputs are correct, just there are simply no observations in the given region/epoch for the given object.
Here we have the first case, I suppose, and therefore an EmptyResponseError is a good approach (or a ValueError if we also identify the issue with one of the input parameters, but I don't think we are checking on those)
astroquery/mpc/core.py
Outdated
@@ -1184,7 +1184,11 @@ def _parse_result(self, result, **kwargs): | |||
|
|||
if len(src) == 0: | |||
raise RuntimeError(('No data queried. Are the target ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related to the issue, but astroquery
defines a more appropriate error type:
astroquery/astroquery/exceptions.py
Line 109 in f2d0bd2
class EmptyResponseError(ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there are certainly better error types than the RunTimeError, e.g. in these case even a ValueError may be more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, RuntimeError is not the right one. EmptyResponseError: Astroquery error class to be raised when the query returns an empty result. For this error the result is an empty list, i.e., []
. If that is OK, then I'd like to use EmptyResponseError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think that's appropriate (my reading is that EmptyResponseError
should be raised when query results are expected but empty is what's returned (as opposed to legit empty response when e.g. there are no matches with the query parameters, but because there are no observations of the given region etc., that case e.g. an empty table can be returned)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we saying, then, that we want to have EmptyResponseError
instead of RuntimeError
before merging this PR? (I'm asking mostly to bump this PR, which otherwise looks useful)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to change the error type, but because these lines of code were not introduced in this pull request then I don't think this should be a requirement for merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and did the change, we could merge when CI is happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this PR as is, but left a few comments regarding the error type we raise.
I think I would not rephrase the error message, I find it verbose and informative enough (it points out there may be some issues with the input rather than no observations), but if you think the extended message would better direct users to check their inputs on the mpc services when running into issues, I'm OK for having the extended message.
astroquery/mpc/core.py
Outdated
@@ -1184,7 +1184,11 @@ def _parse_result(self, result, **kwargs): | |||
|
|||
if len(src) == 0: | |||
raise RuntimeError(('No data queried. Are the target ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think that's appropriate (my reading is that EmptyResponseError
should be raised when query results are expected but empty is what's returned (as opposed to legit empty response when e.g. there are no matches with the query parameters, but because there are no observations of the given region etc., that case e.g. an empty table can be returned)
astroquery/mpc/core.py
Outdated
'identifiers correct? Is the MPC ' | ||
'database search working for your ' | ||
'object? The service is hosted at ' | ||
'https://www.minorplanetcenter.net/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are two main cases when there are no results. One, that should raise an error is when e.g. the identifiers are incorrect, and the service may even return an error itself. OTOH I can think of valid empty responses when all inputs are correct, just there are simply no observations in the given region/epoch for the given object.
Here we have the first case, I suppose, and therefore an EmptyResponseError is a good approach (or a ValueError if we also identify the issue with one of the input parameters, but I don't think we are checking on those)
There is a relevant online test failure (should be easy to fix), so I revoke this approval for now
An object without observations suggests a problem at the MPC.
1ec3b88
to
6097b39
Compare
Thanks! |
Update the
MPC.get_observations
error message to direct the user to the Minor Planet Center in order to help determine if the error is due to a problem with astroquery or MPC.Also, test
MPC.get_ephemeris
with an object that exists, but apparently has no orbital elements in the database.Addresses #2464