-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Parameter validation on MastMissions queries #3126
Conversation
There are a few tests that might fail due to an unrelated issue that we've been having with PS1 queries. If they happen, the failures would be for the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3126 +/- ##
==========================================
+ Coverage 67.49% 67.53% +0.04%
==========================================
Files 233 233
Lines 18420 18487 +67
==========================================
+ Hits 12433 12486 +53
- Misses 5987 6001 +14 ☔ View full report in Codecov by Sentry. |
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.
Some minor comments in line and bigger picture ones:
-
I think it may be useful for the users to have a method that actually lists all the possibly kwargs?
-
I'm sure there are a couple of related open issues for this as weeding out the everything swallowing **kwargs is a thing I would have liked to see for a while. Could you please cross link those, so we can close a couple of things? So, overall thank you.
astroquery/mast/missions.py
Outdated
|
||
Parameters | ||
---------- | ||
**kwargs |
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.
**kwargs | |
**criteria |
astroquery/mast/missions.py
Outdated
# Create Table with parsed data | ||
col_table = Table(rows=rows, names=('name', 'data_type', 'description')) | ||
self.columns[self.mission] = col_table | ||
except Exception: |
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 see that this is inherited code, but we should be more specific and only except specific exceptions rather than staying this super general. And if we need to stay this general, capture the exception and raise the same more specific type of it rather than reraise the generic Exception
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.
Modified to catch more specific exceptions
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.
Is there a way to programatically generate this file? If yes, does it take long?
(I'm asking as files like this tend to diverge from actual server side behaviour super quickly)
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.
This file is only being used for the non-remote test suite, and programmatically generating it would require a connection. Because it's describing a table schema that already exists (and the query results are being mocked as well), I don't think we should have any issues with server-side changes.
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.
OK. Then just maybe add a readme file in the data
directory that describes how to generate this file, if needed, in the future.
For your first point, there is the
|
It's OK to do that in a follow up. Also, given that there are 50+ options, I think it's a good middle ground to explicitly refer to the method that lists the possible options rather than actually adding them to the docstring.
OK, so if something similar could be done for catalogs, too then we can at least cross that topic off for mast. I'll still need to address it for any of the other modules that do it. |
I made some changes in |
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.
Thank you! One remaining comment about validating params for query_region
, too, otherwise it all looks good.
astroquery/mast/collections.py
Outdated
@@ -109,10 +110,18 @@ def query_region_async(self, coordinates, *, radius=0.2*u.deg, catalog="Hsc", | |||
'dec': coordinates.dec.deg, | |||
'radius': radius.deg} | |||
|
|||
# valid criteria keywords | |||
valid_criteria = [] |
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.
Nitpick, but I would move this into the conditional as you only use it in the else
part
# Determine API connection and service name | ||
if catalog.lower() in self._service_api_connection.SERVICES: | ||
self._current_connection = self._service_api_connection | ||
service = catalog | ||
|
||
# adding additional user specified parameters | ||
for prop, value in criteria.items(): |
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.
Any chance to validate these, or there is way to large a scatter in what's allowed for each of these catalogs?
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.
So, the only service that runs through Catalogs.MAST (currently), and thus the service API connection, is PanSTARRS. I added Catalogs._get_service_col_config
and Catalogs._validate_service_criteria
to fetch the column metadata for PanSTARRS and check parameters.
The last commit is a super quick add for getting cloud URIs of HLSPs! |
Mock MastMissions.get_column_list Increase code coverage
fix JSONDecodeError import
test case, changelog
6a1dbe1
to
ed3bdff
Compare
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.
Thanks, this looks good now!
Checks the validity of criteria keyword arguments on
MastMissions
queries. Raises anInvalidQueryError
if an invalid parameter is passed rather then sending them to the API to be ignored. If the invalid parameter is close to a valid keyword, the user is prompted with the closest match.I also altered the
MastMissions.get_column_list
method to save the column list for each mission in a dictionary class attribute calledcolumns
. This way, we do not make unnecessary API calls.I added a test to
test_mast_remote.py
and modified some intest_mast.py
that were not passing in arguments correctly.@dr-rodriguez @astrojimig