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

Add a UAT registry constraint #649

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

msdemlei
Copy link
Contributor

@msdemlei msdemlei commented Feb 13, 2025

This PR adds a constraint for doing keyword searches over the controlled vocabulary of the terms supposed to be in rr.res_subject. The rationale and a lot more is discussed in https://blog.g-vo.org/a-new-constraint-class-in-pyvo-s-registry-api-uat.html

This is for somewhat formal searches against semantic concepts.
Copy link

codecov bot commented Feb 13, 2025

Codecov Report

Attention: Patch coverage is 34.61538% with 17 lines in your changes missing coverage. Please review.

Project coverage is 82.30%. Comparing base (093f2d2) to head (a89d1d0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pyvo/registry/rtcons.py 34.61% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #649      +/-   ##
==========================================
- Coverage   82.47%   82.30%   -0.17%     
==========================================
  Files          72       72              
  Lines        7480     7506      +26     
==========================================
+ Hits         6169     6178       +9     
- Misses       1311     1328      +17     

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

Most of them are unrelated to the UAT constraint, but they seem so minor
that I'd say an extra PR won't buy us anything.
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.

Some comments for the failing tests

@@ -154,7 +170,7 @@ interactive data discovery, however, it is usually preferable to use the

And to look for tap resources *in* a specific cone, you would do

.. doctest-remote-data::
.. doctest-remote-data:: # doctest: +IGNORE_OUTPUT
Copy link
Member

Choose a reason for hiding this comment

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

This won't work, the #doctest commands should be added at the end of the lines (each one of them) that are affected. But this example already has it.

class TestUATConstraint:
def test_basic(self):
cons = rtcons.UAT("solar-flares")
assert (cons.get_search_condition(FAKE_GAVO)
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 have some tests that query the remote service rather than the mock version? (OTOH, if you say the doctests should be enough for that, I would be signing off on it)

.. doctest-remote-data::

>>> resources = registry.search(
... registry.UAT("cepheid-variable-stars", expand_down=3))
Copy link
Member

Choose a reason for hiding this comment

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

Somehow this throws an error, even though cepheid-variable-stars are in the list on the referred website

_____________________________ [doctest] index.rst ______________________________
102 constraints is generally preferable with more complex queries.
103 An advantage of using explicit constraints is that you can pass
104 additional parameters to the constraints.  For instance, the UAT
105 constraint can optionally expand your keyword to narrower or wider
106 concepts.  When looking for resources talking about Cepheids of all
107 kinds, you can thus say:
108 
109 .. doctest-remote-data::
110 
111   >>> resources = registry.search(
UNEXPECTED EXCEPTION: DALQueryError: cepheid-variable-stars does not identify an IVOA uat concept (see http://www.ivoa.net/rdf/uat).
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.11/x64/lib/python3.11/doctest.py", line 1355, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest index.rst[4]>", line 2, in <module>
  File "/home/runner/work/pyvo/pyvo/.tox/py311-test-alldeps-online/lib/python3.11/site-packages/pyvo/registry/rtcons.py", line 713, in __init__
    raise dalq.DALQueryError(
pyvo.dal.exceptions.DALQueryError: cepheid-variable-stars does not identify an IVOA uat concept (see http://www.ivoa.net/rdf/uat).
/home/runner/work/pyvo/pyvo/docs/registry/index.rst:111: UnexpectedException
=========================== short test summary info ============================

@msdemlei msdemlei changed the title [Draft] Add a UAT registry constraint Add a UAT registry constraint Feb 14, 2025
It was a bad idea to have a compact UAT as a local resource; it poisons
astropy's download cache and is then hard to get rid of again, in particular
because pyvo caches the vocabularies in RAM.

In consequence, the unit tests for the UAT constraint are now marked as
using the network.  It does, too, when you run the tests in a freshly made
environment.

I'd still like to keep the commit with the fixture in the history.  Perhaps
we want something like that elsewhere some day.
@msdemlei
Copy link
Contributor Author

msdemlei commented Feb 17, 2025 via email

@bsipocz
Copy link
Member

bsipocz commented Feb 18, 2025

The test failures look relevant, lots of VocabularyErrors

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.

2 participants