Skip to content

Commit

Permalink
DOC: enabling testing for all-VO example
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Jan 28, 2023
1 parent 547bda6 commit 4ac94d6
Showing 1 changed file with 35 additions and 24 deletions.
59 changes: 35 additions & 24 deletions docs/registry/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,27 +356,38 @@ query all obscore services; remove the ``break`` at the end of the loop
to actually do the global query (it's there so that you don't blindly
run all-VO queries without reading at least this sentence)::

from astropy import table
from pyvo import registry

QUERY = "SELECT TOP 1 s_ra, s_dec from ivoa.obscore"

results = []
for svc_rec in registry.search(
datamodel="obscore", servicetype="tap"):
print("Querying {}".format(svc_rec.res_title))
try:
svc = svc_rec.get_service("tap")
results.append(
svc.run_sync(QUERY).to_table())
except KeyboardInterrupt:
# someone lost their patience with a service. Query next.
pass
except Exception as msg:
# some service is broken; you *should* complain, but
print(" Broken: {} ({}). Complain to {}.\n".format(
svc_rec.ivoid, msg, svc_rec.get_contact()))
break

total_result = table.vstack(results)
print(total_result)
.. doctest-remote-data::

>>> from astropy.table import vstack
>>> from pyvo import registry
>>>
>>> QUERY = "SELECT TOP 1 s_ra, s_dec from ivoa.obscore"
>>>
>>> results = []
>>> for i, svc_rec in enumerate(registry.search(datamodel="obscore", servicetype="tap")):
... #print("Querying {}".format(svc_rec.res_title))
... try:
... svc = svc_rec.get_service("tap")
... results.append(
... svc.run_sync(QUERY).to_table())
... except KeyboardInterrupt:
... # someone lost their patience with a service. Query next.
... pass
... except Exception as msg:
... # some service is broken; you *should* complain, but
... #print(" Broken: {} ({}). Complain to {}.\n".format(
... pass # svc_rec.ivoid, msg, svc_rec.get_contact()))
... if i == 5:
... break
>>> total_result = vstack(results) # doctest: +IGNORE_WARNINGS
>>> total_result # doctest: +IGNORE_OUTPUT
<Table length=5>
s_ra s_dec
deg deg
float64 float64
------------------ -------------------
350.4619 -9.76139
208.360833592735 52.3611106494996
148.204840298431 29.1690999975089
243.044008 -51.778222
321.63278049999997 -54.579285999999996

0 comments on commit 4ac94d6

Please sign in to comment.