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 (and Tap/TapPlus?) .search_async_jobs() broken #2458

Open
adrn opened this issue Jul 5, 2022 · 6 comments
Open

Gaia (and Tap/TapPlus?) .search_async_jobs() broken #2458

adrn opened this issue Jul 5, 2022 · 6 comments

Comments

@adrn
Copy link
Member

adrn commented Jul 5, 2022

I was trying to use the Gaia.load_async_job() method to retrieve a job by name, but I get an AttributeError caused by this line because Filter (jobfilter) does not have a createUrlRequest() method (it instead has .create_url_data_request()). I tried fixing the method name in a local clone, but then I still get an error:

full traceback here
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-117-439c23e3fa7d> in <module>
----> 1 Gaia.load_async_job(name='pw1_dr3_region')

~/projects/astropy-all/astroquery/astroquery/utils/tap/core.py in load_async_job(self, jobid, name, verbose, load_results)
    483             jobfilter = Filter()
    484             jobfilter.add_filter('name', name)
--> 485             jobs = self.search_async_jobs(jobfilter)
    486             if jobs is None or len(jobs) < 1:
    487                 log.info(f"No job found for name '{name}'")

~/projects/astropy-all/astroquery/astroquery/utils/tap/core.py in search_async_jobs(self, jobfilter, verbose)
   1298             data = jobfilter.create_url_data_request()
   1299             if data is not None:
-> 1300                 subContext = f"{subContext}?{self.__appendData(data)}"
   1301         connHandler = self.__getconnhandler()
   1302         response = connHandler.execute_tapget(subContext, verbose=verbose)
AttributeError: 'GaiaClass' object has no attribute '_TapPlus__appendData'
AttributeError: 'GaiaClass' object has no attribute '_TapPlus__appendData'

I'm confused because the line of code is calling self.__appendData() but the attribute error is for _TapPlus__appendData -- any ideas?

Thanks!

@eerovaher
Copy link
Member

The attribute name getting modified like that is the result of name mangling. The __appendData() method is defined in the Tap class, so it can be accessed as _Tap__appendData().

@adrn
Copy link
Member Author

adrn commented Jul 5, 2022

Ah, thanks -- I've never used this before. In this case, GaiaClass subclasses TapPlus, which subclasses Tap where the method lives. It doesn't seem to like that the method lives in a grandparent class -- do we need to implement a custom search_async_jobs() on GaiaClass?

@eerovaher
Copy link
Member

It is not obvious to me that overwriting search_async_jobs() would be the best solution. I would say the problem is that __appendData() is defined in Tap, but only used in TapPlus, which is especially confusing because of the name mangling. Does moving __appendData() from Tap to TapPlus help fixing GaiaClass.load_async_job()?

@adrn
Copy link
Member Author

adrn commented Jul 6, 2022

That might also be a path forward but I'm not really familiar with the source code in astroquery.utils.tap or where it's used (in jwst and gaia, at least)!

@eerovaher
Copy link
Member

git grep appendData finds two matches in all of astroquery. One of them is the method definition in Tap, the other is included in your traceback. Moving the method to TapPlus should therefore not break anything.

@cosmoJFH
Copy link

A possible solution to the issue described by @adrn has been implemented in the PR #2967

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

No branches or pull requests

4 participants