-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
Add flexible parameters to criteria #1659
Add flexible parameters to criteria #1659
Conversation
Hello @olyoberdorf! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-03-03 00:09:31 UTC |
astroquery/gemini/core.py
Outdated
@@ -156,9 +156,10 @@ def query_object(self, objectname, radius=0.3*units.deg): | |||
return self.query_criteria(objectname=objectname, radius=radius) | |||
|
|||
@class_or_instance | |||
def query_criteria(self, coordinates=None, radius=0.3*units.deg, pi_name=None, program_id=None, utc_date=None, | |||
def query_criteria(self, *args, coordinates=None, radius=0.3*units.deg, pi_name=None, program_id=None, utc_date=None, |
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 is an API break, users could have used the kwargs as positional args before, and those will fails with then new added *args
. So I would suggest to add it to the end as a new keyword, e.g. rawqueryargs
(well, something more sensible, than this)
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've renamed them with the rawquery name prefix and moved args to the back. I ended up putting orderby sandwiched between them to prevent people using it via position. I didn't want future search terms to result in orderby sitting in the middle of the positonal args list.
Prior, orderby was being picked up by the *args, so the explicit add and handling is really just making the signature match the docs.
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. We could also switch to keyword only args, definitely in the next refactoring release, but given the gemini
module is relatively new, if you want you can make that change any time you wish.
@@ -252,6 +253,17 @@ def query_criteria(self, coordinates=None, radius=0.3*units.deg, pi_name=None, p | |||
'PROCESSED_FLAT', | |||
'PROCESSED_FRINGE', | |||
'PROCESSED_ARC' | |||
orderby : str, optional |
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 is not in the signature
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.
per above, made it explicit in the signature
astroquery/gemini/core.py
Outdated
@@ -343,7 +371,9 @@ def query_raw(self, *args, **kwargs): | |||
The list of parameters to be passed via the query path to the webserver | |||
kwargs : | |||
The dictionary of parameters to be passed by name=value within the query | |||
path to the webserver | |||
path to the webserver. The `orderby` key value pair has a special |
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.
use double backticks. sphinx will try to convert single ones to links and fails to do it for any parameters
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.
done
def test_observations_query_region(self): | ||
""" test query against a region of the sky against actual archive """ | ||
result = gemini.Observations.query_region(coords, radius=0.3 * units.deg) | ||
assert isinstance(result, Table) |
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 check on the content of the Table would be nice in the tests, just to make sure data is returned rather than an empty table (which is the default behaviour for a nonsensical query, if I see correctly)
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've added a length > 0 check. That is still pretty naive but at least it will prevent the default causing a false pass.
docs/gemini/gemini.rst
Outdated
@@ -83,6 +83,20 @@ and the program ID. For a complete list of available search fields, see | |||
0.0 Full Frame -- Gemini-North True ... | |||
0.0 Full Frame -- Gemini-North True ... | |||
|
|||
In addition, the criteria query can accept additional parameters via the `args` and `kwargs` optional parameters. |
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.
double backticks
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.
also, might be nice to have another extra example with passing in the 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.
done
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.
also, might be nice to have another extra example with passing in the kwargs
I missed this but made a note of it for next time
Some minor comments, otherwise this looks good. @olyoberdorf - could you also rebase to get rid of the merge commit? |
Thanks for looking so quickly - I will make those edits and rebase and post back. |
409fd93
to
d7b8e43
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.
I could spot these two more cases of single vs double backtick usage. Otherwise once CI is all green this is ready to go in.
astroquery/gemini/core.py
Outdated
@@ -252,18 +255,45 @@ def query_criteria(self, coordinates=None, radius=0.3*units.deg, pi_name=None, p | |||
'PROCESSED_FLAT', | |||
'PROCESSED_FRINGE', | |||
'PROCESSED_ARC' | |||
orderby : str, optional | |||
Indicates how the results should be sorted. Values should be like the ones used | |||
in the archive website when sorting a column. For example, `data_label_desc` would |
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.
in the archive website when sorting a column. For example, `data_label_desc` would | |
in the archive website when sorting a column. For example, ``data_label_desc`` would |
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.
done
docs/gemini/gemini.rst
Outdated
In addition, the criteria query can accept additional parameters via the ``*rawqueryargs`` and ``**rawquerykwargs`` | ||
optional parameters. | ||
|
||
The `orderby` parameter can be used to pass the desired sort order. |
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.
The `orderby` parameter can be used to pass the desired sort order. | |
The ``orderby`` parameter can be used to pass the desired sort order. |
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.
done
…ria to be passed down to the URL Added support for ordering results via orderby parameter (properly used as URL query argument) fixed documentation to latest tweaks for added criteria query args and sort order Changelog entry for Gemini enhancements alphabetizing my changelog entry by module name tagging tests as remote
d7b8e43
to
491b2a3
Compare
Thanks @olyoberdorf! |
This enhances query_criteria to allow additional arguments to pass through to the raw query. This enables users to call the helper method (query_criteria) but still have access to any new or less common parameters in the webservice.
#1658