18. Query the Registry

Iterate over all obscore services (here: see what data collections they house):

for svc_rec in pyvo.registry.search(datamodel="obscore"):
  svc = pyvo.dal.TAPService(svc_rec.access_url)
  result = svc.run_sync("SELECT DISTINCT obs_collection"
    " FROM ivoa.obscore")
  print("\n>>>>{}\n{}\n".format(
    svc_rec.short_name,
    "\n".join(
      r["obs_collection"] for r in result))

To “use ObsTAP”, just query the ivoa.obscore table; all (registred) ObsTAP services can be found by passing the data model name “obscore” to registry.search.

The selling point here is: we’re running the same database query on all the ObsTAP service, and we’re processing their results in the same way. That’s the power of uniform data models.

This script doesn’t come attached. That’s because on large services, the SELECT DISTINCT can actually be computationally expensive for the services. Do not run this script just for fun.


Markus Demleitner, Hendrik Heinl