Skip to content

Addresses Issue #3138 - ESO - Enable Table Access Protocol (TAP) queries #3339

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

juanmcloaiza
Copy link
Contributor

@juanmcloaiza juanmcloaiza commented Jun 5, 2025

Closes #3138

Changes:

Switch querying interface from WDB to TAP in querying functions:

  • query_main
  • query_instruments
  • query_surveys
  • query_apex_quicklooks
  • list_instruments
  • list_surveys

Deprecate arguments:

  • open_form
  • cache

New functionality:

  • Allow plain ADQL queries via query_tap_service (with authentication as well)
  • Cone search using cone_ra, cone_dec, cone_radius arguments
  • Retrieve record count before querying the archive, via count_only argument
  • Ask query functions to print the underlying ADQL queries without issuing them

@juanmcloaiza juanmcloaiza force-pushed the feature/ISSUE-3138-TAP branch from 720fbd9 to 22d0c30 Compare June 5, 2025 12:55
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

❌ Patch coverage is 82.56228% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.67%. Comparing base (b81cecb) to head (685c807).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
astroquery/eso/core.py 75.00% 45 Missing ⚠️
astroquery/eso/utils.py 96.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3339      +/-   ##
==========================================
+ Coverage   70.07%   70.67%   +0.59%     
==========================================
  Files         232      233       +1     
  Lines       19893    19839      -54     
==========================================
+ Hits        13940    14021      +81     
+ Misses       5953     5818     -135     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@juanmcloaiza juanmcloaiza force-pushed the feature/ISSUE-3138-TAP branch 2 times, most recently from 76675d2 to c32f348 Compare June 5, 2025 13:18
@juanmcloaiza juanmcloaiza force-pushed the feature/ISSUE-3138-TAP branch from a987745 to 4b775f8 Compare June 5, 2025 13:49
@juanmcloaiza juanmcloaiza mentioned this pull request Jun 5, 2025
8 tasks
@juanmcloaiza
Copy link
Contributor Author

Hi @bsipocz , could you please give us a time estimate of the review process? No pressure at all though, we only need to plan our activities internally. Thanks a lot in advance.

@bsipocz
Copy link
Member

bsipocz commented Jul 21, 2025

@juanmcloaiza - sorry for the delay. I'll try to get to the review this week.

@bsipocz bsipocz added the eso label Jul 31, 2025
@bsipocz bsipocz added this to the v0.4.11 milestone Jul 31, 2025
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry to have this many comments and thank you for your patience while waiting for this review.

I acknowledge that this seems to a lot, but most of them are minor and/or helping API consistency with the other modules and/or making the code cleaner and easier to read and follow; which will be helpful for the future maintenance.


import astropy.table
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L28 explicitly imports from here, remove this one add to that list as necessary

import astropy.utils.data
import keyring
import requests.exceptions
from astropy.table import Table, Column
from astropy.utils.decorators import deprecated_renamed_argument
from bs4 import BeautifulSoup
from pyvo.dal import TAPService
import pyvo.dal.exceptions as pde
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you directly import the classes here? It's quite obvious reading the code that those are coming from pyvo (and this alias is not helping to make it more obvious anyway)

"problem; the service may be offline.")
elif b"# No data returned !" not in content:
return True
__doctest_skip__ = ['EsoClass.*']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we skip doctesting?

Copy link
Contributor Author

@juanmcloaiza juanmcloaiza Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not a valid answer, but "because it was so in the main branch, L30", so I left it like that. I'll address this comment later, when I have a valid answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I removed the flag __doctest_skip__.

"problem; the service may be offline.")
elif b"# No data returned !" not in content:
return True
__doctest_skip__ = ['EsoClass.*']


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have an explicit __all__ with listing the public API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__all__ is present in eso/__init__.py (L28):

__all__ = ['Eso', 'EsoClass',
           'Conf', 'conf',
           ]

Is this what you're referring to? Perhaps I'm missing the point.

Comment on lines +123 to +124
@property
def maxrec(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does maxrec need to be a class properly rather than a parameter for the query functions? After all it should be specific to individual queries rather than being set on the instance. (See the other modules)

Copy link
Contributor Author

@juanmcloaiza juanmcloaiza Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also discussed this point internally. While both maxrec and top limit the number of results, their intent is different. top is part of the ADQL query, used limit the result size from a logical/scientific standpoint. maxrec, on the other hand, is a TAP server parameter used as a safety cap regardless of the query’s intent. For example, I'd use maxrec to avoid system overload when I'm on my laptop, and for quickly testing the notebook’s logic and plots before the "real-thing-run" that could last some hours.

Since maxrec reflects user's environment rather than query logic, it makes more sense to have it as a configurable property, rather than a per-query argument (as top). Regarding other modules: if they don’t yet distinguish between maxrec and top, I’d warmly suggest they do, since it’s an important conceptual separation.

Please let me know your thoughts on this, before I proceed to make any changes. I'd very much appreciate if we can leave maxrec as an instance property, though :)

Comment on lines 918 to 919
@deprecated_renamed_argument(('request_all_objects', 'request_id'), (None, None),
since=['0.4.7', '0.4.7'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unrelated so no need to do it in this PR, but 0.4.7 was a while ago, so these deprecations can be now removed.

return where_constraints


def reorder_columns(table: Table,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have multiple questions here:

  • is this really necessary? Why the default column order is not suffucient?
  • but if this is necessary, then please just go by suggested way for table column reordering from the astropy docs, "Select or reorder columns" on this page: https://docs.astropy.org/en/stable/table/modify_table.html

Also, minor nitpicking, but all the other functions here are private, why is this one not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... but the function is already doing exactly what the docs suggest (isn't it?)...

From the docs:

new_order = ['a', 'c', 'b']  # List or tuple
t_acb = t[new_order]

From the ESO module:

[...]
last_cols = first_cols + last_cols  # this is a list of column names
table = table[last_cols]

The code above those two lines is just computing the list of column names.

Other than that,

  • the function is now private, good point.
  • yes, the reordering is necessary, because the default is alphabetical order and the first fields are long urls and other info that is not legible and take much space. The reorder was suggested by several beta testers, which were expecting the columns in the order that this function generates.

Comment on lines +92 to +93
if not isinstance(table, Table):
return table
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an expected case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, table may be a string or an int, depending on the user parameters query_str_only only and count_only.

I admit this is not the best software design at this point, but a complete refactoring would have taken more time from both developers and reviewers. We will come with better encapsulation, separation of concerns, etc in the next pull request. Our aim for now was to switch to TAP with as little impact as possible to the API and to the overall code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed the tests, but running them returned 77 failures, so please have a look.

pytest -P eso -R should work if you have all the test dependencies installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests were passing originally, but now I updated the fork from upstream and indeed, they are failing. I'll have a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests are passing again ✅

@@ -4,6 +4,33 @@
ESO Queries (`astroquery.eso`)
******************************

.. warning::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very good! Thanks for adding.

@juanmcloaiza juanmcloaiza force-pushed the feature/ISSUE-3138-TAP branch from 3742bb9 to d3be2af Compare August 5, 2025 12:15
@juanmcloaiza
Copy link
Contributor Author

@bsipocz, thanks a lot for your comments, I have addressed most of them (the easy ones); for the rest, I'd still need some feedback from you. If you can give me feedback today, I can work immediately on it and push and update by tomorrow. Afterwards, I won't be able to work on Astroquery for the next couple of weeks. Just so you know, in case you can squeeze this review in your day 🤓 Thanks again! 👍

@bsipocz
Copy link
Member

bsipocz commented Aug 5, 2025

@juanmcloaiza - I'm sorry, it's very unlikely that I can get back to this today, but I'll try to do it soon so you can pick it up again in a few weeks time.

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

Successfully merging this pull request may close these issues.

ESO - Enable Table Access Protocol (TAP) queries
2 participants