Skip to content
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

RegTAP search: add a flag for including standard auxiliary capabilities #258

Merged
merged 10 commits into from
May 12, 2021

Conversation

theresadower
Copy link
Contributor

Proposed search flag includeaux : boolean, default false.

This flag controls whether to include auxiliary capabilities (with standard interfaces) in registry search results. This may result in duplicate capabilities being returned, especially if the servicetype is not specified, and therefore remains default off.

This behavior is discussed in #238 . The issue originally arose in a NAVO-run pyvo workshop at AAS, where a workflow of performing cone searches and then moving to a related TAP service for more fine-grained queries and additional filtering didn't work as expected. @trjaffe and @tomdonaldson can comment further from the workshop experience.

per astropy#238

Proposed search flag includeaux : boolean
Flag for whether to include auxiliary capabilities in results. This may result in duplicate capabilities being returned, especially if the servicetype is not specified. 

This came up in a NAVO notebook use case, not sure yet if it's exactly what we want.
@codecov
Copy link

codecov bot commented Apr 5, 2021

Codecov Report

Merging #258 (841807b) into master (fba1ebc) will increase coverage by 0.00%.
The diff coverage is 90.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #258   +/-   ##
=======================================
  Coverage   74.94%   74.95%           
=======================================
  Files          44       44           
  Lines        5057     5063    +6     
=======================================
+ Hits         3790     3795    +5     
- Misses       1267     1268    +1     
Impacted Files Coverage Δ
pyvo/registry/regtap.py 51.33% <90.00%> (+1.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fba1ebc...841807b. Read the comment docs.

@theresadower theresadower changed the title RegTAP search: add a flag for including standard auxiliary capabilities WIP: RegTAP search: add a flag for including standard auxiliary capabilities Apr 5, 2021
@cbanek
Copy link
Contributor

cbanek commented Apr 5, 2021

I'm not a registry expert, but this looks pretty good. I'm not sure what's up with the test failures, it looks like maybe those are related to some kind of mock issue, but once the tests pass I'm good to approve!

Thanks for the PR!

@theresadower
Copy link
Contributor Author

I'm not a registry expert, but this looks pretty good. I'm not sure what's up with the test failures, it looks like maybe those are related to some kind of mock issue, but once the tests pass I'm good to approve!

Thanks for the PR!

Thanks! I'm not very familiar with fixtures or mocker myself. I'll spend some time working on this and possibly ask around for help, then un-mark it WIP for further review once they pass.

@theresadower
Copy link
Contributor Author

@cbanek Tests fixed. It looks like one of the remaining failures is needing a milestone; I don't understand the codestyle: commands failed error, caused by the former or otherwise. Please let me know what I should do next, if anything, and thank you for your time!

@cbanek cbanek added this to the v1.2 milestone Apr 5, 2021
Copy link
Contributor

@cbanek cbanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Milestone set. Leaving for anyone else open to comment for a while. While I think the where clauses that are strings could be maybe combined or something, it's probably better to not complicate that part, since it's really readable the way it is here (and there's all sorts of issues with parens and other things like that).

pyvo/registry/tests/test_regtap.py Show resolved Hide resolved
@msdemlei
Copy link
Contributor

msdemlei commented Apr 6, 2021

As commented over in issue #238, this isn't my preferred way to address the underlying use case.

But if we do it this way, we shouldn't blindly match anything that ends in aux; that will give far too many false positives (try servicetype='sia' includeaux=True). If we go the way proposed here, I'd say we ought to have something like

# where perhaps keep this in a central location
KNOWN_SERVICE_TYPES = {"conesearch", "sia", "ssa", "slap", "tap"}

match_caps = None  # not used with this logic, but for robustness
if servicetype:
  match_caps = set([servicetype])
else:
  match_caps = KNOWN_SERVICE_TYPES

if includeaux:
  match_caps |= {s+"#aux" for s in match_caps}

if match_caps:
  wheres.append("standard_id IN ({})".format(
    ",".join(
      tap.as_adql_literal("ivo://ivoa.net/std/"+s)
      for s in match_caps)))

tap.as_adql_literal would have to be defined (but that's a useful function anyway) -- it would return ADQL literals for python values, e.g., 'that''s' for a python string that's.

(I'd like that better than current main's code whether or not we merge this PR)

@msdemlei
Copy link
Contributor

msdemlei commented Apr 6, 2021

Incidentally: Whatever we do, I suppose we need to touch the service property, too, when we deal with auxiliary capabilities. For now, a startwith approach as in describe would look about ok, but I have to admit I've not really looked at this particular part of the API and frankly suspect this needs to be re-thought a bit because of course there are now many resources that are both, say, SCS and TAP.

@theresadower
Copy link
Contributor Author

theresadower commented Apr 6, 2021

As commented over in issue #238, this isn't my preferred way to address the underlying use case.

But if we do it this way, we shouldn't blindly match anything that ends in aux; that will give far too many false positives (try servicetype='sia' includeaux=True). If we go the way proposed here, I'd say we ought to have something like

# where perhaps keep this in a central location
KNOWN_SERVICE_TYPES = {"conesearch", "sia", "ssa", "slap", "tap"}

match_caps = None  # not used with this logic, but for robustness
if servicetype:
  match_caps = set([servicetype])
else:
  match_caps = KNOWN_SERVICE_TYPES

if includeaux:
  match_caps |= {s+"#aux" for s in match_caps}

if match_caps:
  wheres.append("standard_id IN ({})".format(
    ",".join(
      tap.as_adql_literal("ivo://ivoa.net/std/"+s)
      for s in match_caps)))

tap.as_adql_literal would have to be defined (but that's a useful function anyway) -- it would return ADQL literals for python values, e.g., 'that''s' for a python string that's.

(I'd like that better than current main's code whether or not we merge this PR)

OK, double checking just from a read of the code without having run it, the intention is:
if aux is included and servicetype is specified, only return auxiliary capabilities of that servicetype (that also match the rest of keyword WHEREs, etc) and if aux is included but no servicetype, return all standard capabilities and aux capabilities (that also match the rest of the keyword WHEREs, etc) and (while they would be arguably wrong from the registry record creation and organization standpoint) non-standard aux capabilities, if they ever did exist, would not be returned.

Is this right?
I think I like this actually, @trjaffe, is this closer to what we wanted out of the workshop workflow?

Adjusted tests for queries with includeaux to updated generated query.

Additionally, search throws DalQueryError (which it already throws for missing arguments) on provided but bad servicetype argument; relevant pytest added.
@theresadower
Copy link
Contributor Author

As commented over in issue #238, this isn't my preferred way to address the underlying use case.

But if we do it this way, we shouldn't blindly match anything that ends in aux; that will give far too many false positives (try servicetype='sia' includeaux=True). If we go the way proposed here, I'd say we ought to have something like

# where perhaps keep this in a central location
KNOWN_SERVICE_TYPES = {"conesearch", "sia", "ssa", "slap", "tap"}

match_caps = None  # not used with this logic, but for robustness
if servicetype:
  match_caps = set([servicetype])
else:
  match_caps = KNOWN_SERVICE_TYPES

if includeaux:
  match_caps |= {s+"#aux" for s in match_caps}

if match_caps:
  wheres.append("standard_id IN ({})".format(
    ",".join(
      tap.as_adql_literal("ivo://ivoa.net/std/"+s)
      for s in match_caps)))

tap.as_adql_literal would have to be defined (but that's a useful function anyway) -- it would return ADQL literals for python values, e.g., 'that''s' for a python string that's.

(I'd like that better than current main's code whether or not we merge this PR)

Adapted this slightly - we already had a map of accepted servicetypes to standards-names, where users input 'scs' rather than 'conesearch', and used that rather than break it. Given the additional string wrangling around that, the new adql_as_literal does not seem to be needed.

If we want to change around this behaviour on a larger scale we can do a separate branch and MR for it.

Additionally, added a check for bad servicetype input, added to pytest.

@theresadower
Copy link
Contributor Author

@cbanek This is currently failing due to lack of changelog, forgive me for not knowing process or being able to find it, should I just edit CHANGES.rst or is there some other process that will pick it up?

@andamian
Copy link
Contributor

@cbanek This is currently failing due to lack of changelog, forgive me for not knowing process or being able to find it, should I just edit CHANGES.rst or is there some other process that will pick it up?

@theresadower - you need to update the CHANGES.rst and push it. Thanks

To retain functionality which was existent before the includeaux flag, accept both servicetype acronyms (sia, csc) and descriptive names (image, conesearch) listed as keys and values in the service_type_map structure.
@cbanek
Copy link
Contributor

cbanek commented Apr 20, 2021

This looks good to me, is everyone happy with this and ready to go?

@tomdonaldson
Copy link
Contributor

This looks good to me, is everyone happy with this and ready to go?

Looks good to me too.

@tomdonaldson tomdonaldson changed the title WIP: RegTAP search: add a flag for including standard auxiliary capabilities RegTAP search: add a flag for including standard auxiliary capabilities May 12, 2021
@tomdonaldson tomdonaldson merged commit c7a2eba into astropy:master May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants