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

ENH: Make regtap service aware #386

Merged
merged 15 commits into from
Dec 15, 2023
Merged

ENH: Make regtap service aware #386

merged 15 commits into from
Dec 15, 2023

Conversation

msdemlei
Copy link
Contributor

@msdemlei msdemlei commented Nov 9, 2022

This PR contains a set of changes addressing the fixable but not yet
fixed issues raised by Tom in
https://wiki.ivoa.net/internal/IVOA/InterOpOct2022Reg/PyVOandNAVORegTAP.pdf

PyVO now properly checks whether the server can do something not in
RegTAP 1.0 before trying it. This concerns the optimisation of the
Freetext constraint as well as the STC constraints.

To make this reasonably easy to write, this retrofits some methods to
non-registry code:

  • get_tap_cap to TAPService
  • get_adql to tr.TableAccesss
  • get_feature_list, get_feature, and get_udf to tr.Language

@tomdonaldson tomdonaldson marked this pull request as draft November 9, 2022 13:45
Comment on lines +342 to +528
There are several RegTAP services in the VO. PyVO by default uses the
one at the TAP access URL http://reg.g-vo.org/tap. You can use
alternative ones, for instance, because they are nearer to you or
because the default endpoint is down.

You can pre-select the URL by setting the ``IVOA_REGISTRY`` environment
variable to the TAP access URL of the service you would like to use. In
a bash-like shell, you would say::

export IVOA_REGISTRY="http://vao.stsci.edu/RegTAP/TapService.aspx"
Copy link
Member

Choose a reason for hiding this comment

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

I know that you don't yet want review, so I leave only one comment:

we should be able to do this with a more programatic way, from inside the python interpreter.
Whether to use the astropy config system, or also provide ways to override the defaults in a session, or be able to do both is a detail, but I very strongly think it should be doable without shell variables.

@msdemlei
Copy link
Contributor Author

msdemlei commented Dec 22, 2022 via email

@msdemlei msdemlei force-pushed the make-regtap-service-aware branch 2 times, most recently from e8bb39b to 2caee9d Compare January 13, 2023 10:55
@bsipocz bsipocz added this to the v1.5 milestone Mar 1, 2023
@bsipocz
Copy link
Member

bsipocz commented Mar 1, 2023

I milestoned this for 1.5, with the mindset that this is rather an enhancement rather than a bugfix.

@bsipocz
Copy link
Member

bsipocz commented May 8, 2023

I think this is the only thing that holds up 1.5, if we want to maybe do a release soonish? I recall using this branch when testing the SIA2 registry stuff, so overall not sure how much more is missing for this to be ready to be merged. Maybe it's only a rebase from Markus and a review from Tom?

@bsipocz
Copy link
Member

bsipocz commented May 8, 2023

(I'm mostly pushing for the release as it would be nice to get that SIA2 registry search compatibility out of the door)

@msdemlei
Copy link
Contributor Author

msdemlei commented May 8, 2023 via email

@bsipocz
Copy link
Member

bsipocz commented May 9, 2023

I've hence done
the rebase (oh boy, never rebase over a whitespace-everywhere commit)
and I hope I've not messed things up too much.

Could you push this back to the branch here?

@msdemlei msdemlei force-pushed the make-regtap-service-aware branch from 2caee9d to dec257d Compare May 9, 2023 15:32
@bsipocz
Copy link
Member

bsipocz commented May 10, 2023

I made some CI improvements, so will go ahead and rebase again and flip the switch to move this out from the draft PR status.

@bsipocz bsipocz force-pushed the make-regtap-service-aware branch from dec257d to 9e01762 Compare May 10, 2023 08:08
@bsipocz bsipocz marked this pull request as ready for review May 10, 2023 08:09
@bsipocz bsipocz changed the title Make regtap service aware [draft, don't review just yet] Make regtap service aware May 10, 2023
@codecov
Copy link

codecov bot commented May 10, 2023

Codecov Report

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

Comparison is base (3c8c67f) 80.11% compared to head (1bbc88f) 80.27%.

Files Patch % Lines
pyvo/registry/regtap.py 57.14% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #386      +/-   ##
==========================================
+ Coverage   80.11%   80.27%   +0.16%     
==========================================
  Files          52       52              
  Lines        6085     6150      +65     
==========================================
+ Hits         4875     4937      +62     
- Misses       1210     1213       +3     

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

@bsipocz
Copy link
Member

bsipocz commented May 10, 2023

@msdemlei - I wonder why CI doesn't see those failures you mention before, are they covered by tests or it's about use cases you haven't covered in the test suite yet? Sorry for the noise, apparently it's indeed failing. But the QTAble one went away, I suppose that's good news.

@tomdonaldson - this is all yours for review.

@bsipocz bsipocz changed the title Make regtap service aware ENH: Make regtap service aware May 10, 2023
@msdemlei
Copy link
Contributor Author

msdemlei commented May 10, 2023 via email

@bsipocz
Copy link
Member

bsipocz commented May 10, 2023

bleeding-edge venv

I would certainly raise this issue upstream. IMO it should all work in a stable environment and when it doesn't it certainly should be looked at as a bug rather than a feature. Getting the latest and greatest cool tools shouldn't be a requirement to do dev work.

@msdemlei
Copy link
Contributor Author

msdemlei commented Jul 7, 2023

Um... I just noticed this still lingers in the doldrums where I'd say it's a big improvement over what we have in terms of letting people switch registries.

So... @tomdonaldson – could you spare an eye? Or perhaps @theresadower?

@msdemlei
Copy link
Contributor Author

msdemlei commented Dec 1, 2023

So, I've rebased and force-pushed here. Locally, I get three test failures at the moment:

  • test_auth.test_cookies_auth -- that's unrelated and probably an upstream failure
  • test_regtap.test_endpoint_switching -- that's a new bug and due to a parser bug at the MAST TAP server. I'd be willing to work around it (actually, I thought I already had), but I'd have to know what to do. It'd be lovely if this could be fixed before this branch gets stale again.
  • [doctest] index.rst: there's an UnknownElementWarning about nrows, probably in a tables element. Again unrelated to this, and it'd be lovely if someone could fix it (nrows was introduced with VODataService in Nov 2021, so I'm a bit surprised this only shows now and here; DaCHS has been handing out nrows forever, so this warning must be present in many other tests, too).

So... yeah, it would be nice to get the test_endpoint_switching test
to run before merging. MAST, any chance for that?

@bsipocz
Copy link
Member

bsipocz commented Dec 1, 2023

Again unrelated to this, and it'd be lovely if someone could fix it

I'm afraid this might have been rebased on an outdated branch. I started to look into a rebase on main, and some of the test failures are gone, but I see new ones. I expect some more cleaning would fix the unrelated ones of those. I'm happy to push back to this branch (but that won't be before ~middle/late next week)), or have you do another rebase yourself?

@bsipocz bsipocz force-pushed the make-regtap-service-aware branch from 9e01762 to e9a0e82 Compare December 5, 2023 04:46
@bsipocz
Copy link
Member

bsipocz commented Dec 5, 2023

I went ahead and pushed the rebased version back to this branch as I managed to clear up the test failures that were due to the conflicts. I still see the endpoint switching issue @msdemlei mentioned above as well as an unrelated looking TestXSIType.test_bad_type (I'm about to open a separate cleanup PR, if I see this one in there, I'll try to fix it there).
And there is a doctest one that I'll comment/suggest in the review I'm about to submit.

So, bottom line, would be nice to fix that one related test and make this work and merge and then finally release v1.5.

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.

A lot of nitpicky comments with suggestions that would either help with fixing the links in the docsbuild (they could be part of #416, but I feel it's better to get things fixed when they pop-up), or suggestions for the failing doctest.

As none of these are critical (except fixing the failing doctest), that take them or leave them, they should not block merging this PR.

Also, could you please add a changelog entry?

Comment on lines +368 to +546
>>> print("\n".join(sorted(r.get_interface("tap").access_url
... for r in res)))
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: we can have longer lines

Suggested change
>>> print("\n".join(sorted(r.get_interface("tap").access_url
... for r in res)))
>>> print("\n".join(sorted(r.get_interface("tap").access_url for r in res)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mhhh... I actually prefer broken lines and the loop expression on an extra line...

pyvo/dal/tap.py Outdated

Returns
-------
A `pyvo.io.vosi.TableAccess` instance.
Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid a lot of these will cause docs build failures once we turn on nitpicky-mode, e.g. the API is not documented at this namespace but one layer down at https://pyvo.readthedocs.io/en/latest/api/pyvo.io.vosi.tapregext.TableAccess.html

So, while we don't have this nitpicky mode enabled, this practice this means that there are no functional links to the API docs in this docstring: https://pyvo--386.org.readthedocs.build/en/386/api/pyvo.dal.TAPService.html#pyvo.dal.TAPService.get_tap_cap

This is not merge blocker, just a heads up that we need to use the API path to the actual namespace we put things in.

Some of these I commented for in this PR, but I very likely didn't catch all of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, can I be lazy and just ask: What's the right way that will be nitpicky-safe?

Copy link
Member

Choose a reason for hiding this comment

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

Wrapping up #416 and putting it into CI. I was doing a little bit of work on that PR, but the main issue is that we need to make some decisions about what's in the public API (and thus documented) and what's not. Currently I went ahead and ignored a couple of classes that we said is not for public consumption, yet we try to link to them as e.g. they are used as base classes.

Copy link
Member

Choose a reason for hiding this comment

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

(btw, wrapping up #416 is a bit of a hustle as there is an underlying sphinx-osx issue that in theory has a workaround but I never managed to make it work here, so I have to rely on CI for the iterations)

pyvo/dal/tap.py Outdated
@@ -128,6 +128,20 @@ def __init__(self, baseurl, session=None):
if hasattr(self._session, 'update_from_capabilities'):
self._session.update_from_capabilities(self.capabilities)

def get_tap_cap(self):
Copy link
Member

Choose a reason for hiding this comment

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

can we spell out cap here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, yes.


def get_feature(self, ivoid, form):
"""
returns the `LanguageFeature` with ivoid and form if present.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
returns the `LanguageFeature` with ivoid and form if present.
returns the `~pyvo.io.vosi.tapregext.LanguageFeature` with ivoid and form if present.

pyvo/dal/tap.py Outdated

Returns
-------
A `pyvo.io.vosi.TableAccess` instance.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
A `pyvo.io.vosi.TableAccess` instance.
A `~pyvo.io.vosi.tapregext.TableAccess` instance.


Parameters
----------
service : `dal.tap.TAPService`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
service : `dal.tap.TAPService`
service : `~pyvo.dal.tap.TAPService`

to write that constraint, or because it is missing a table or column.

To recover, choose another RegTAP service. Search constraining
``datamodel="regtap"``, and then use `pyvo.registry.switch_RegTAP_service`
Copy link
Member

Choose a reason for hiding this comment

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

switch_RegTAP_service doesn't seem to exist anywhere in the API. Is it meant to be choose_RegTAP_service here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes... this is what happens when you change your naming preferences in between edits. Fixed.

Returns
-------

~`pyvo.registry.regtap.Interface`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
~`pyvo.registry.regtap.Interface`
`~pyvo.registry.regtap.Interface`

tables, etc.

To switch to a different RegTAP service, use
:py:func:`change_RegTAP_service`.
Copy link
Member

Choose a reason for hiding this comment

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

there doesn't seem to be a change_RegTAP_service. Is it meant to be choose_RegTAP_service here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please hand me a brown bag. Fixed in the next commit as well.

... for r in res)))
http://dc.zah.uni-heidelberg.de/tap
http://gavo.aip.de/tap
http://voparis-rr.obspm.fr:80/tap
Copy link
Member

Choose a reason for hiding this comment

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

This causes one of the test failures

Suggested change
http://voparis-rr.obspm.fr:80/tap
http://voparis-rr.obspm.fr/tap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks...

@bsipocz
Copy link
Member

bsipocz commented Dec 7, 2023

Perhaps we should have an integration test suite that contains the
more expensive of the tests requiring external services. This could
then be run on "major" occasions like, say, merge of PRs, without
making everyday test runs more tedious;

Good point, and exactly the reason we don't run astroquery remote tests on PRs, but on commits. Which means extra care has to be made prior to merging (in practice I run the given module locally), but ultimately we may figure out a way that does it more automaticly (e.g. only trigger remote tests of the given module, but even that would be too much for astroquery where we have diverse contributions).

Here, I'll try to remember to look into whether the PR status can be a trigger for github actions (e.g. we don't run the full test suite for draft PRs), or we may just want to use a label to trigger more resourceful remote tests?

TLDR, I'll need to think about how to make it more robust without adding a large burden for the remote services.

@tomdonaldson
Copy link
Contributor

Curse optional features. Let's not do them any more unless there is absolutely no alternative. Supporting multiple code paths is a pain we shouldn't inflict on our clients.

Yes, I enthusiastically agree!

@bsipocz
Copy link
Member

bsipocz commented Dec 13, 2023

gentle ping that once this one gets wrapped up we can do the long-awaited 1.5 release 😄

msdemlei added a commit to msdemlei/pyvo that referenced this pull request Dec 14, 2023
@msdemlei
Copy link
Contributor Author

msdemlei commented Dec 14, 2023 via email

msdemlei and others added 15 commits December 14, 2023 12:20
That's regtap.choose_RegTAP_service.

While I'm at it (not really related): cleanup of get_interface's docstring
More specifically, it will use UNION only if available, falling back to
the much-harder-to-plan OR otherwise.

This commit also fixes a bug in the UNION-based condition where multiple
words were joined (in effect) with an OR rather than and AND as
documented.

To make this more convenient, this adds a get_tap_cap method to
TAPServices; this returns the (first) tr:TableAccess capability on the
service.  The IVOA are not really saying what multiple such capabilities
would mean, so for now I'd say we're good on just returning the first
one (and it's in line with what we've been doing so far with maxrec and
hardlimit; upload_methods would now change behaviour if there were
upload methods distributed over multiple TableAccess-es; but the
previous behaviour would have been bad anyway).

We are also adding convenience methods for accessing the tap capability
to the TAPService, for accessing the ADQL language in there, and for
pulling out language features and UDFs.  We probably want to document
these somewhere visible, as advanced users (cross-server) can do smart
things with them.  But then perhaps that's too esoteric for now.

It is an interesting question whether at least get_adql (or something
more aptly named) should sit on TAPService itself...
...when the current TAP server doesn't support MOC or doesn't have
stc_spatial.
Regrettably, this currently fails on both alternative endpoints because
of validity problems.  I'll try to work it out with the operators.
(and a pdb tracing call removed)
This helps certain SQLServer-based implementations while not impacting
compliant ones; consider this defensive programming.
This enables checking for table presence doing table_name in tableset.
This was missing the declaration of the res_subject table that it
needs (and that's not neccessary in the union branch because the
table is in a subquery there.
@msdemlei
Copy link
Contributor Author

Ok, and I've rebased to current main. @tomdonaldson, can you perhaps add your placet?

@msdemlei msdemlei force-pushed the make-regtap-service-aware branch from 29958e0 to 1bbc88f Compare December 14, 2023 11:22
Copy link
Contributor

@tomdonaldson tomdonaldson left a comment

Choose a reason for hiding this comment

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

Thanks @msdemlei ! This all look good to me now. The _extra_tables mechanism seems like a nice way to address the need for the extra join.

Comment on lines +48 to +50
- registry.search now introspects the TAP service's capabilities and
only offers extended functionality or optimisations if the required
features are present [#386]
Copy link
Member

Choose a reason for hiding this comment

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

As this is user facing, I would think the information that now it's possible to use other registries is important to list, or to list as well.

That being said, I would go ahead and merge this as is so I can go ahead and do more tests and cleanups, but please do advise a rephrasing and I'll fix up the changelog before the release.

@bsipocz bsipocz merged commit c49a408 into main Dec 15, 2023
14 checks passed
@bsipocz
Copy link
Member

bsipocz commented Dec 15, 2023

Thank you so much @msdemlei!

@bsipocz bsipocz deleted the make-regtap-service-aware branch December 15, 2023 23:07
@msdemlei
Copy link
Contributor Author

msdemlei commented Dec 18, 2023 via email

@bsipocz
Copy link
Member

bsipocz commented Dec 19, 2023

Is it legal to have two Changelog items for one PR?

Of course it is, thanks for the extra text!

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.

3 participants