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.launch_job does not work when uploading tables on the fly #2884

Closed
ManonMarchand opened this issue Nov 23, 2023 · 6 comments · Fixed by #2892
Closed

Gaia.launch_job does not work when uploading tables on the fly #2884

ManonMarchand opened this issue Nov 23, 2023 · 6 comments · Fixed by #2892

Comments

@ManonMarchand
Copy link
Member

ManonMarchand commented Nov 23, 2023

I'm doing something very similar to the example in section 1.5 Synchronous query on an ‘on-the-fly’ uploaded table of the Gaia module. When calling Gaia.launch_job with an uploaded table I encounter a TypeError.

To reproduce

Here is a minimal non-working example

from astropy.table import Table
from astroquery.gaia import Gaia
xmm_to_upload = Table([[0, 0, 0], [0, 0, 0], ['a', 'b', 'c']], names=['RA_x', 'DEC_x', 'TARGET'])
query = """
SELECT TOP 1000 gaia.source_id, gaia.ra, gaia.dec, gaia.parallax, xmm.TARGET
FROM TAP_UPLOAD.xmm AS xmm
LEFT JOIN gaiadr3.gaia_source AS gaia
ON DISTANCE(POINT(xmm.RA_x, xmm.DEC_x),POINT(gaia.ra, gaia.dec)) < 0.2
"""
j = Gaia.launch_job(query=query, upload_resource=xmm_to_upload, upload_table_name='xmm')

Traceback of the error

And its output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/manon.marchand/.conda/envs/astroquery-dev/lib/python3.11/site-packages/astroquery/gaia/core.py", line 851, in launch_job
    return TapPlus.launch_job(self, query=query, name=name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/manon.marchand/.conda/envs/astroquery-dev/lib/python3.11/site-packages/astroquery/utils/tap/core.py", line 281, in launch_job
    response = self.__launchJobMultipart(query=query,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/manon.marchand/.conda/envs/astroquery-dev/lib/python3.11/site-packages/astroquery/utils/tap/core.py", line 615, in __launchJobMultipart
    response = self.__connHandler.execute_tappost(context,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: TapConn.execute_tappost() takes from 3 to 4 positional arguments but 5 were given

edit: and my astroquery version is the master branch on commit 8c15f2f

@stargaser
Copy link
Contributor

From trying different astroquery pre-releases, I have found that astroquery==0.4.7dev8479 (Feb 6, 2023) works. From astroquery==0.4.7dev8792 (Jun 29, 2023) onwards, it fails.

@bsipocz
Copy link
Member

bsipocz commented Dec 1, 2023

cc @esdc-esac-esa-int

@jespinosaar
Copy link
Contributor

Thanks for raising this issue @ManonMarchand , @stargaser and @bsipocz . We will check what is happening and let you know about the solution.

@cosmoJFH
Copy link
Contributor

cosmoJFH commented Dec 7, 2023

Hi @ManonMarchand, I've checked that the class astroquery/utils/tap/conn/tapconn.py was changed at the commit

Tsar Bomba Nick 18/3/23 1:15 Refactor: Made kwargs keyword only for astroquery/utils/tap/tapconn.py
rev number: e724f62

The method was changed from

def execute_tappost(self, subcontext, data,
                    content_type=CONTENT_TYPE_POST_DEFAULT,
                    content_type=CONTENT_TYPE_POST_DEFAULT, 
                    verbose=False):

to

def execute_tappost(self, subcontext, data,
                    content_type=CONTENT_TYPE_POST_DEFAULT,
                    content_type=CONTENT_TYPE_POST_DEFAULT, *,
                    verbose=False):

So the parameter verbose is now a keyword argument.

I have checked that if the method __launchJobMultipart in astroquery/utils/tap/core.py is changed to

    response = self.__connHandler.execute_tappost(context,
                                                  body,
                                                  contentType,
                                                  verbose=verbose)

the issue is not reproduced

@bsipocz
Copy link
Member

bsipocz commented Dec 7, 2023

@cosmoJFH - thanks for the investigation, and sorry for not spotting this in #2690.

Will you open an PR with the fix or shall I?

@cosmoJFH
Copy link
Contributor

cosmoJFH commented Dec 7, 2023

New PR #2892

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants