Skip to content

Commit 2ddb7d2

Browse files
msdemleibsipocz
authored andcommitted
Deprecating image and spectrum as registry servicetype-s
In an attempt to accomodate the concerns brought up in #449 (comment), we also explain a bit why image and spectrum are being deprecated. we still raise deprecation warnings (rather than something else), as that is, I think, what we are doing (and should be doing): We are saying that we discourage people to use these two strings and reserve the right to drop them one day.
1 parent d5582a1 commit 2ddb7d2

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ Enhancements and Fixes
4949
Deprecations and Removals
5050
-------------------------
5151

52+
5253
- SodaRecordMixin no longer will use a datalink#links endpoint for soda [#580]
5354

55+
- Deprecating the use of "image" and "spectrum" in registry Servicetype
56+
constraints [#449]
57+
5458

5559
1.5.3 (unreleased)
5660
==================

docs/registry/index.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ instance. The opening example could be written like this:
303303

304304
>>> from astropy.coordinates import SkyCoord
305305
>>> my_obj = SkyCoord.from_name("Bellatrix")
306-
>>> for res in registry.search(waveband="infrared", servicetype="spectrum"):
306+
>>> for res in registry.search(waveband="infrared", servicetype="ssap"):
307307
... print(res.service.search(pos=my_obj, size=0.001))
308308
...
309309

310310
In reality, you will have to add some error handling to this kind of
311311
all-VO queries: in a wide and distributed network, some service is
312-
always down. See `Appendix: Robust All-VO Queries`_
312+
always down. See `Appendix: Robust All-VO Queries`_.
313313

314314
The central point is: With a ``servicetype`` constraint,
315315
each result has a well-defined ``service`` attribute that contains some
@@ -644,3 +644,7 @@ run all-VO queries without reading at least this sentence):
644644
148.204840298431 29.1690999975089
645645
243.044008 -51.778222
646646
321.63278049999997 -54.579285999999996
647+
648+
Note that even this is not enough to reliably cover use cases like „give
649+
me all images of M1 in the X-Ray in the VO“. In some future version,
650+
pyVO will come with higher-level functionality for such tasks.

pyvo/registry/rtcons.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"""
1212

1313
import datetime
14+
import warnings
1415

1516
from astropy import units as u
1617
from astropy import constants
1718
from astropy.coordinates import SkyCoord
19+
from astropy.utils.exceptions import AstropyDeprecationWarning
1820
import numpy
1921

2022
from ..dal import query as dalq
@@ -361,14 +363,13 @@ class Servicetype(Constraint):
361363
* ``sia``, ``sia1`` (SIAP version 1 services; prefer ``sia1`` for symmetry,
362364
although ``sia`` will be kept as the official IVOA short name for SIA1)
363365
* ``sia2`` (SIAP version 2 services)
364-
* ``spectrum``, ``ssa``, ``ssap`` (all synonymous for spectral
365-
services, prefer ``spectrum``)
366+
* ``ssa``, ``ssap`` (synonymous for SSAP services)
366367
* ``scs``, ``conesearch`` (synonymous for cone search services, prefer
367368
``scs``)
368369
* ``line`` (for SLAP services)
369370
* ``tap``, ``table`` (synonymous for TAP services, prefer ``tap``)
370-
* ``image`` (a to be deprecated alias for sia1)
371-
* ``spectrum`` (a to be deprecated alias for ssap)
371+
* ``image`` (a deprecated alias for sia)
372+
* ``spectrum`` (a deprecated alias for ssap)
372373
373374
You can also pass in the standards' ivoid (which
374375
generally looks like
@@ -380,6 +381,15 @@ class Servicetype(Constraint):
380381
Multiple service types can be passed in; a match in that case
381382
is for records having any of the service types passed in.
382383
384+
Contrary to what the names of the service types may suggest,
385+
“image” and "spectrum" do *not* select all resources serving images
386+
or spectra. For instance, at the moment you would have to search for
387+
images served in three different ways: SIAv1, SIAv2, and ObsTAP. Against
388+
that, “image” only selects SIAv1, and "spectrum" similarly omits ObsTAP. A
389+
global discovery module is under active development to provide global
390+
dataset discovery. When it is ready, these two misleading options may be
391+
removed.
392+
383393
The match is literal (i.e., no patterns are allowed); this means
384394
that you will not receive records that only have auxiliary
385395
services, which is what you want when enumerating all services
@@ -404,6 +414,13 @@ def __init__(self, *stds):
404414
self.extra_fragments = []
405415

406416
for std in stds:
417+
if std in ('image', 'spectrum'):
418+
warnings.warn(AstropyDeprecationWarning(
419+
f"The '{std}' servicetype is deprecated. See"
420+
" https://pyvo.readthedocs.io/en/latest/api/pyvo.registry"
421+
".Servicetype.html#pyvo.registry.Servicetype"
422+
" for more information."))
423+
407424
if std in SERVICE_TYPE_MAP:
408425
self.stdids.add(SERVICE_TYPE_MAP[std])
409426
elif "://" in std:

pyvo/registry/tests/test_rtcons.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from astropy.time import Time
1010
from astropy import units as u
1111
from astropy.coordinates import SkyCoord
12+
from astropy.utils.exceptions import AstropyDeprecationWarning
13+
1214
import numpy
1315
import pytest
1416

@@ -141,7 +143,7 @@ def test_fulluri(self):
141143
== "standard_id IN ('http://extstandards/invention')")
142144

143145
def test_multi(self):
144-
assert (rtcons.Servicetype("http://extstandards/invention", "image"
146+
assert (rtcons.Servicetype("http://extstandards/invention", "sia"
145147
).get_search_condition(FAKE_GAVO)
146148
== "standard_id IN ('http://extstandards/invention',"
147149
" 'ivo://ivoa.net/std/sia')")
@@ -179,6 +181,16 @@ def test_sia2_aux(self):
179181
" OR standard_id like 'ivo://ivoa.net/std/sia#query-2.%'"
180182
" OR standard_id like 'ivo://ivoa.net/std/sia#query-aux-2.%'"))
181183

184+
def test_image_deprecated(self):
185+
with pytest.warns(AstropyDeprecationWarning):
186+
assert (rtcons.Servicetype("image").get_search_condition(FAKE_GAVO)
187+
== "standard_id IN ('ivo://ivoa.net/std/sia')")
188+
189+
def test_spectrum_deprecated(self):
190+
with pytest.warns(AstropyDeprecationWarning):
191+
assert (rtcons.Servicetype("spectrum").get_search_condition(FAKE_GAVO)
192+
== "standard_id IN ('ivo://ivoa.net/std/ssa')")
193+
182194

183195
@pytest.mark.usefixtures('messenger_vocabulary')
184196
class TestWavebandConstraint:

0 commit comments

Comments
 (0)