Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gaia: Fix the astroquery method launch_job to retrieve the Table from the job when a json format is used #2947

Conversation

cosmoJFH
Copy link
Contributor

@cosmoJFH cosmoJFH commented Feb 9, 2024

If the Table is extracted from the job returned after the execution of the function launch_job, the following exception is thrown

>>> from astroquery.gaia import Gaia

>>> r=Gaia.launch_job("select top 10 * from gaiadr3.gaia_source order by source_id", output_format="json",dump_to_file=False)

Traceback (most recent call last):
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astroquery/utils/tap/xmlparser/utils.py", line 35, in read_http_response
    result = APTable.read(io.BytesIO(gzip.decompress(data.read())), format=astropy_format)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/gzip.py", line 601, in decompress
    if _read_gzip_header(fp) is None:
       ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/gzip.py", line 428, in _read_gzip_header
    raise BadGzipFile('Not a gzipped file (%r)' % magic)
gzip.BadGzipFile: Not a gzipped file (b'{"')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astropy/io/misc/pandas/connect.py", line 56, in _pandas_read
    import pandas
ModuleNotFoundError: No module named 'pandas'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astroquery/gaia/core.py", line 971, in launch_job
    return TapPlus.launch_job(self, query=query, name=name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astroquery/utils/tap/core.py", line 358, in launch_job
    results = utils.read_http_response(response, output_format)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astroquery/utils/tap/xmlparser/utils.py", line 38, in read_http_response
    result = APTable.read(data, format=astropy_format)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astropy/table/connect.py", line 62, in __call__
    out = self.registry.read(cls, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astropy/io/registry/core.py", line 221, in read
    data = reader(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfernandez/anaconda3/envs/test_astroquery/lib/python3.11/site-packages/astropy/io/misc/pandas/connect.py", line 58, in _pandas_read
    raise ImportError("pandas must be installed to use pandas table reader")
ImportError: pandas must be installed to use pandas table reader

We found this issue in astroquery version

>>> import astroquery
>>> print(astroquery.__version__)
0.4.7.dev9137

jira ticket GAIAPCR-1308

cc @esdc-esac-esa-int

@pep8speaks
Copy link

pep8speaks commented Feb 9, 2024

Hello @cosmoJFH! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-02-09 22:39:27 UTC

Copy link

codecov bot commented Feb 9, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (ab7fdaa) 66.77% compared to head (edeed3a) 66.79%.

Files Patch % Lines
astroquery/utils/tap/xmlparser/utils.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2947      +/-   ##
==========================================
+ Coverage   66.77%   66.79%   +0.01%     
==========================================
  Files         237      237              
  Lines       18303    18317      +14     
==========================================
+ Hits        12222    12235      +13     
- Misses       6081     6082       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bsipocz bsipocz added this to the v0.4.7 milestone Feb 10, 2024
@bsipocz
Copy link
Member

bsipocz commented Feb 15, 2024

Thanks @cosmoJFH!

@bsipocz bsipocz merged commit d2373a5 into astropy:main Feb 15, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants