ENH: add support for TAP's FORMAT parameter
- Dominant language
- Python
- Stars
- 88
- Forks
- 64
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
Original motivation:
This has been moved over from astroquery as I was running into pyvo limitations while I tried to address this problem. The issue I tried to address is to run a caom query to list all the possible `collection` values for an SIA query. The query, leaving the default return format, is expected to take long, but we do have some formats cached on server side (ipac table, HTML, and json at the time it came up). So the easy solution would have been to pass on the `FORMAT` keyword.
However, the pyvo machinery is not at all prepared for that, even though we have e.g. `execute_raw()` method to compliment `execute_votable()`, the mixin inheritances later on still assume to receive votables.
(e.g. `TAPResults` is eventually inherited from `AdhocServiceResultsMixin` that assumes votable inputs, etc. At that point I stopped investigating further and will ask on our server side to keep caching the default votable result, too.
However, I think it would be nice to eventually support other formats, even if it only means dumping the text stream back to the user without doing any parsing of it. (That was my intention before running into this multi-generation inheritance)
```
query = "SELECT DISTINCT collection from caom.observation ORDER by collection"
format = 'IPAC_TABLE'
result = Irsa.query_tap(query=query, format=format)
Traceback (most recent call last):
File "/Users/bsipocz/.pyenv/versions/3.11.0/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3433, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 3, in
result = Irsa.query_tap(query=query, format=format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bsipocz/munka/devel/astroquery/astroquery/ipac/irsa/core.py", line 85, in query_tap
return self.tap.search(query, language='ADQL', format=format, maxrec=maxrec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bsipocz/munka/devel/pyvo/pyvo/dal/tap.py", line 278, in run_sync
**keywords).execute()
^^^^^^^^^
File "/Users/bsipocz/munka/devel/pyvo/pyvo/dal/tap.py", line 1117, in execute
return TAPResults(self.execute_raw(), url=self.queryurl, session=self._session)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bsipocz/munka/devel/pyvo/pyvo/dal/adhoc.py", line 111, in __init__
super().__init__(votable, url=url, session=session)
File "/Users/bsipocz/munka/devel/pyvo/pyvo/dal/query.py", line 334, in __init__
self._status = self._findstatus(votable)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bsipocz/munka/devel/pyvo/pyvo/dal/query.py", line 376, in _findstatus
res = self._findresultsresource(votable)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bsipocz/munka/devel/pyvo/pyvo/dal/query.py", line 365, in _findresultsresource
if len(votable.resources) < 1:
^^^^^^^^^^^^^^^^^
AttributeError: 'TAPQuery' object has no attribute 'resources'
```
See here:
https://irsa.ipac.caltech.edu/docs/program_interface/TAP.html
(this will be needed to address astropy/astroquery#2940 )
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in pyvo/dal/tap.py at run_sync, execute, and execute_raw, then trace how TAPResults is constructed through pyvo/dal/adhoc.py and pyvo/dal/query.py. Determine how the FORMAT parameter should flow through these result classes, including non-VOTable responses. Done means a TAP query can request formats such as IPAC_TABLE and return the response without the current VOTable-parsing failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100