astropy / astropy/astroquery

DOC: add notes around preference for pyvo's TAP over external usage of tapplus

Open
#3,262 8 comments 0 reactions 0 assignees View on GitHub
Documentation query utils.tap
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

Sorry in advance if this is a newbie problem. I was encouraged by the noirlab data lab help desk folks to submit this issue.

I'm trying to develop python code to extract largish amounts of data from noirlab ls_dr10 to help with star/galaxy separation of brown dwarf candidates. I have a test script that uses either the launch_job method or the launch_job async method. The synchronus method works fine but is limited to 2k records. The asynchronous method just fails with a 400ish error code which leads me to think that I've done something wrong. Here is the response from using the asynchronous method.

```
bruceballer@mac plan9 % test.py
Launched query: '
SELECT TOP 10 ra, dec, type FROM ls_dr9.tractor
WHERE ra BETWEEN 83 AND 84
AND dec BETWEEN -22 AND -21
'
------>https
host = datalab.noirlab.edu:443
context = /tap/async
Content-type = application/x-www-form-urlencoded
400 Bad Request
[('Date', 'Mon, 17 Mar 2025 19:07:20 GMT'), ('Server', 'Restlet-Framework/2.0.2'), ('Accept-Ranges', 'bytes'), ('Content-Type', 'text/plain;charset=UTF-8'), ('Content-Length', '107'), ('Connection', 'close')]
ERROR: 400: Bad Request
Saving error to: async_20250317150720.vot.error
Traceback (most recent call last):
File "/Users/bruceballer/Documents/plan9/test.py", line 20, in
job = tap_service.launch_job_async(query,dump_to_file=True,verbose=True,autorun=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/astroquery/utils/tap/core.py", line 440, in launch_job_async
raise requests.exceptions.HTTPError(response.reason)
requests.exceptions.HTTPError: Bad Request

Here's the error file:

bruceballer@mac plan9 % cat async_20250317150720.vot.error
Errors found during Job Creation:
Errors found during Job Creation:

PHASE: Execution Phase is mandatory.%
```

And here is the test script, test.py:

```
#!/usr/local/bin/python3.12

from astroquery.utils.tap.core import TapPlus

## Point TAP service to Astro Data Lab URL
datalab_tap_url = "https://datalab.noirlab.edu/tap"
## Create TAP service object
tap_service = TapPlus(url=datalab_tap_url)

# Example query
query = """
SELECT TOP 10 ra, dec, type FROM ls_dr9.tractor
WHERE ra BETWEEN 83 AND 84
AND dec BETWEEN -22 AND -21
"""
# try it both ways
asynch = True
if asynch:
job = tap_service.launch_job_async(query,dump_to_file=True,verbose=True,autorun=True)
print(job)
r = job.get_results()
print(r)
else:
# Run the query to create an xml file
job = tap_service.launch_job(query,dump_to_file=True)
print(job)

```

FWIW, I'm running this on a macbook M1 Pro using Sequoia 15.3.2.

Contributor guide

Open the contributing guide

Research direction

Start with the test.py example and the TapPlus launch_job and launch_job_async entry points described in the issue. Review the existing TAP documentation, then add notes explaining the preference for pyvo's TAP over external TapPlus usage and cover the reported asynchronous workflow. Done means the guidance addresses the Data Lab example and its 400 error context.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.