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

Feature: add possibility to return full list of services #505

Merged
merged 10 commits into from
Dec 22, 2023

Conversation

ManonMarchand
Copy link
Member

@ManonMarchand ManonMarchand commented Dec 6, 2023

Hello PyVO,

EDIT following conversation

  • make lax false by default
  • add repr to DALService
  • add method list_services that return a list of services

What it looks like

>>> from pyvo import registry
>>> catalogue_ivoid = f"ivo://CDS.VizieR/I/239"
>>> voresource = registry.search(ivoid=catalogue_ivoid)[0]
>>> voresource.list_services()
[SCSService(baseurl : 'http://vizier.cds.unistra.fr/viz-bin/conesearch/I/239/tyc_main?', description : 'Cone search capability for table I/239/tyc_main (The main part of Tycho Catalogue)'), SCSService(baseurl : 'http://vizier.cds.unistra.fr/viz-bin/conesearch/I/239/hip_main?', description : 'Cone search capability for table I/239/hip_main (The Hipparcos Main Catalogue)'), TAPService(baseurl : 'http://tapvizier.cds.unistra.fr/TAPVizieR/tap', description : 'None'), SCSService(baseurl : 'http://vizier.cds.unistra.fr/viz-bin/conesearch/I/239/solar_t?', description : 'Cone search capability for table I/239/solar_t (Solar System Annex: Tycho astrometry/photometry)'), SCSService(baseurl : 'http://vizier.cds.unistra.fr/viz-bin/conesearch/I/239/solar_ha?', description : 'Cone search capability for table I/239/solar_ha (Solar System Annex: Astrometric catalogue)'), SCSService(baseurl : 'http://vizier.cds.unistra.fr/viz-bin/conesearch/I/239/h_dm_com?', description : 'Cone search capability for table I/239/h_dm_com (Double and Multiples: Component solutions -COMP)')]
>>> voresource.list_services('tap')
[TAPService(baseurl : 'http://tapvizier.cds.unistra.fr/TAPVizieR/tap', description : 'None')]

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (10e9dbd) 80.28% compared to head (fec5e3e) 80.32%.

Files Patch % Lines
pyvo/dal/sla.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #505      +/-   ##
==========================================
+ Coverage   80.28%   80.32%   +0.04%     
==========================================
  Files          52       52              
  Lines        6152     6175      +23     
==========================================
+ Hits         4939     4960      +21     
- Misses       1213     1215       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

I think we should aim to keep the current behaviour and make lax opt-in, but I let the others to chime in.

pyvo/registry/regtap.py Outdated Show resolved Hide resolved
@bsipocz bsipocz added this to the v1.5 milestone Dec 6, 2023
@msdemlei
Copy link
Contributor

msdemlei commented Dec 7, 2023 via email

@gilleslandais
Copy link

gilleslandais commented Dec 7, 2023

Hi,
indeed, may be the PR doesn't resolve the issue.

Some catalogues contains several tables having positions (so multiple conesearch) . Each conesearch is described in 1 interface and 1 capability : see the OAI record provided by CDS:
https://cds.unistra.fr/registry/?verb=GetRecord&metadataPrefix=ivo_vor&identifier=ivo://cds.vizier/b/corot

The issue stays that pyvo registry returns a unique conesearch for these catalogue (eg: B/corot):
(see jupyter notebook @ https://cdsarc.cds.unistra.fr/viz-bin/cat/B/corot)

from pyvo import registry

voresource = registry.search(ivoid="ivo://cds.vizier/b/corot")[0]
voresource.access_modes()
conesearch_center = (104.216, -5.491)
conesearch_records = voresource.get_service("conesearch").search(pos=conesearch_center, sr=1/60.)

I don't see any way to execute a conesearch on the 2 tables (the upper code select 1).
I don't see also how to map the conesearch interface with the good table?

May be, I don't use pyvo correctly?

@ManonMarchand
Copy link
Member Author

ManonMarchand commented Dec 7, 2023

Ah indeed! It's very much our fault because VizieR entries in the registry are catalogs and not tables. So a same entry might have n conesearch capabilities associated to n tables from a single catalog. They are all valid, you just interrogate different things with them.

Writing this made me change my mind. Let's not change behavior for services that correctly declare tables one by one. Could we (pretty please) add "all_services" and "all_interfaces" keywords that would be false by default? This would be very useful for us and shouldn't impact the others.

I updated the commit to implement this.

@gilleslandais : this does not fully solve our problem since we'd still need to find a way to link services to tables... But as soon as we can access the full list we can do something downstream. Maybe a wrapper in astroquery.vizier ?

@ManonMarchand ManonMarchand changed the title Return full list of services in lax mode Feature: add possibility to return full list of services Dec 7, 2023
@ManonMarchand
Copy link
Member Author

ManonMarchand commented Dec 7, 2023

I think we should avoid having something return a sequence that before returned a single item, and I think interfaces that sometimes return a sequence and sometimes an item are quite likely evil (remember cgi.FieldStorage?).

Very true. The new implementation returns an item when all_*** is False and a list when all_*** is True. This could still be an issue... An other alternative would be two new methods get_all_services and get_all_interfaces. What are your thoughts?

@msdemlei
Copy link
Contributor

msdemlei commented Dec 7, 2023 via email

@ManonMarchand ManonMarchand marked this pull request as draft December 8, 2023 08:19
@ManonMarchand
Copy link
Member Author

ManonMarchand commented Dec 8, 2023

Thanks for the detailed answer! I'd like to write an implementation of suggestions a/b1

It's a bit more than I expected to do in the beginning so I'm switching to a draft state until ready.

@msdemlei
Copy link
Contributor

msdemlei commented Dec 8, 2023 via email

@ManonMarchand ManonMarchand force-pushed the fix-get-interface branch 2 times, most recently from 498409f to d858193 Compare December 12, 2023 09:00
@ManonMarchand ManonMarchand marked this pull request as ready for review December 12, 2023 09:01
@ManonMarchand
Copy link
Member Author

I think this addresses our points.
Some DALServices children classes (SSA, SCS, SIA, SLA) already had a way of retrieving a description from the result. I chose that the description coming from the abstract DALService appears if it was provided and otherwise keep the description of the output as it was the case before.

@msdemlei
Copy link
Contributor

msdemlei commented Dec 12, 2023 via email

@ManonMarchand
Copy link
Member Author

No no, you're not the only bothered person. I was feeling uneasy with the two behavior too, but I only thought about renaming the other result_description which would have broken the API. The existence of the two ways of providing a description is a bit awkward but I guess that's not something we can change.

For the list of services, the order should become deterministic with an additional ORDER BY cap_index in the long list of order bys?

What about integrating the choose_service method into list_services with a keyword argument?
Something like
list_services('scs', description_fragment='your_string')
and then the users can use it as they want (like do their own check that there is only one element). I'm just afraid about all the different methods to get services right now and would like if we could avoid to add yet a new one.

Sure for the index.rst, I'll update it!

@msdemlei
Copy link
Contributor

msdemlei commented Dec 13, 2023 via email

@ManonMarchand ManonMarchand marked this pull request as draft December 13, 2023 09:43
@gilleslandais
Copy link

gilleslandais commented Dec 13, 2023

About the mapping between capabities and datasets:
The keyword attribute to search in a list of service is interesting - but not really machine-readable..

Could we envisage an update in a next VOResource version to include the mapping?
For instance with a new element in the schema that lists the datasets which are served by the capability?

@msdemlei
Copy link
Contributor

msdemlei commented Dec 14, 2023 via email

@bsipocz bsipocz removed this from the v1.5 milestone Dec 15, 2023
@ManonMarchand
Copy link
Member Author

Hi! When is the 1.5 going out? Any chance I can still squeeze this in? I think we're close to agreeing on everything and I can submit something around tomorrow

@ManonMarchand ManonMarchand marked this pull request as ready for review December 19, 2023 10:28
@ManonMarchand
Copy link
Member Author

ManonMarchand commented Dec 19, 2023

(note that this is totally unrelated to this PR but I had to rebase and add lax=True) to the RegTAP services example introduced by #386 in the docs, so at least one of the registry endpoints declares more than one TAP service. I did not investigate further.)

Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

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

I have no more nits to pick at this point, and this PR is definitely fixing something that needs fixing at least to the level TOPCAT has. So, let's merge (and then perhaps see at a later point whether we can become better than TOPCAT :-).

@bsipocz bsipocz added this to the v1.5 milestone Dec 19, 2023
@bsipocz
Copy link
Member

bsipocz commented Dec 19, 2023

(and then perhaps see at a later point whether we can become better than TOPCAT :-)

I love the sentiment here, we can always aspire :)

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Unfortunately, this PR introduces a lot of unintended API changes, however, the fixes are trivial.

(I haven't tried to use this or run any more tests, as I hoped to get in the review before someone hits merge)

pyvo/dal/scs.py Outdated Show resolved Hide resolved
pyvo/dal/sia.py Outdated Show resolved Hide resolved
pyvo/dal/sia2.py Outdated Show resolved Hide resolved
pyvo/dal/sla.py Outdated Show resolved Hide resolved
pyvo/dal/tap.py Outdated Show resolved Hide resolved
pyvo/registry/regtap.py Show resolved Hide resolved
pyvo/registry/regtap.py Outdated Show resolved Hide resolved
pyvo/registry/regtap.py Outdated Show resolved Hide resolved
pyvo/registry/regtap.py Outdated Show resolved Hide resolved
pyvo/registry/regtap.py Outdated Show resolved Hide resolved
@bsipocz bsipocz modified the milestones: v1.5, v1.6 Dec 19, 2023
@bsipocz
Copy link
Member

bsipocz commented Dec 19, 2023

Actually, ignore most of my review above (as #507 can go in before this one) as I would suggest we bump this for v1.6, as it wasn't really on the radar for v1.5 anyway, and then we can try to make that release cycle a short one.

@bsipocz
Copy link
Member

bsipocz commented Dec 22, 2023

@ManonMarchand - #507 has gone in, so if you're still around before the holidays, you can go ahead with a rebase and a final commit.

this should prevent from users not discovering that a service might have different services of a same type
this lists the services available for this RegistryResource. They can then be accessed like `record.list_services()[0].search(***)`
this will return the service for which the keyword is a substring of capability_description
@ManonMarchand
Copy link
Member Author

ManonMarchand commented Dec 22, 2023

Pfiou, not my easiest rebase 😅

PS: wishing nice holidays to you both, see you in January!

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

All my review comments have been addressed after the rebase, so this is good to go from the API perspective.

@bsipocz
Copy link
Member

bsipocz commented Dec 22, 2023

Given Marcus' approval above and the fixups against main, this is good to go now. Thank you @ManonMarchand, and hope you have a nice time off!

@bsipocz bsipocz merged commit e9e0eb5 into astropy:main Dec 22, 2023
12 checks passed
@ManonMarchand ManonMarchand deleted the fix-get-interface branch February 19, 2024 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants