Bugfix for tests#12
Merged
juanmcloaiza merged 2 commits intoJun 10, 2026
Merged
Conversation
Collaborator
|
@juanmcloaiza I included some of our new surveys to the |
Collaborator
applying these change fixes the failing tests on
_____________________________________________________________________________________________________________ test_retrieve_pyvo_table _____________________________________________________________________________________________________________
self = <astroquery.eso.core.EsoClass object at 0x10cb5a690>, query_str = 'select * from ivoa.ObsCore', tap = TAPService(baseurl : 'https://archive.eso.org/tap_obs', description : 'None')
def _try_retrieve_pyvo_table(self,
query_str: str,
tap: TAPService) -> Optional[Table]:
table_with_an_extra_row = Table()
def message(query_str):
try:
tap_endpoint = self._tap_endpoint(tap.baseurl)
except ValueError:
# Keep the original exception path stable for unrecognized/custom TAP URLs.
tap_endpoint = tap.baseurl
return (f"Error executing the following query:\n\n"
f"{query_str}\n\n"
"See examples here: https://archive.eso.org/tap_obs/examples\n\n"
f"For maximum query freedom use the query_tap method:\n\n"
f' >>> Eso().query_tap( "{query_str}", tap_endpoint="{tap_endpoint}")\n\n')
try:
row_limit_plus_one = self.ROW_LIMIT
if self.ROW_LIMIT < conf.MAX_ROW_LIMIT:
row_limit_plus_one = self.ROW_LIMIT + 1
table_with_an_extra_row = tap.search(query=query_str, maxrec=row_limit_plus_one).to_table()
> self._maybe_warn_about_table_length(table_with_an_extra_row, row_limit_plus_one)
../../.tox/test-online/lib/python3.12/site-packages/astroquery/eso/core.py:293:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astroquery.eso.core.EsoClass object at 0x10cb5a690>
table_rowlim_plus_one = <Table length=1001>
abmaglim access_estsize access_format ....org/ID?ADP.2014-01-20T10:01:43.637 Smartt et. al. (2014) ... 56385.3666987 2000.00448 -- LSQ13rd
row_limit_plus_one = 1001
def _maybe_warn_about_table_length(self, table_rowlim_plus_one, row_limit_plus_one):
"""
Issues a warning when a table is empty or when the
results are truncated
"""
if len(table_rowlim_plus_one) < 1:
warnings.warn("Query returned no results", NoResultsWarning)
if len(table_rowlim_plus_one) == row_limit_plus_one:
> warnings.warn(f"Results truncated to {self.ROW_LIMIT}. "
"To retrieve all the records set to None the ROW_LIMIT attribute",
MaxResultsWarning)
E astroquery.exceptions.MaxResultsWarning: Results truncated to 1000. To retrieve all the records set to None the ROW_LIMIT attribute
../../.tox/test-online/lib/python3.12/site-packages/astroquery/eso/core.py:266: MaxResultsWarning
The above exception was the direct cause of the following exception:
def test_retrieve_pyvo_table():
eso_instance = Eso()
dal = pyvo.dal.TAPService(eso_instance._tap_url())
q_str = "select * from ivoa.ObsCore"
table = None
with pytest.raises(pyvo.dal.exceptions.DALFormatError):
> table = eso_instance._try_retrieve_pyvo_table(q_str, dal)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.tox/test-online/lib/python3.12/site-packages/astroquery/eso/tests/test_eso.py:376:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astroquery.eso.core.EsoClass object at 0x10cb5a690>, query_str = 'select * from ivoa.ObsCore', tap = TAPService(baseurl : 'https://archive.eso.org/tap_obs', description : 'None')
def _try_retrieve_pyvo_table(self,
query_str: str,
tap: TAPService) -> Optional[Table]:
table_with_an_extra_row = Table()
def message(query_str):
try:
tap_endpoint = self._tap_endpoint(tap.baseurl)
except ValueError:
# Keep the original exception path stable for unrecognized/custom TAP URLs.
tap_endpoint = tap.baseurl
return (f"Error executing the following query:\n\n"
f"{query_str}\n\n"
"See examples here: https://archive.eso.org/tap_obs/examples\n\n"
f"For maximum query freedom use the query_tap method:\n\n"
f' >>> Eso().query_tap( "{query_str}", tap_endpoint="{tap_endpoint}")\n\n')
try:
row_limit_plus_one = self.ROW_LIMIT
if self.ROW_LIMIT < conf.MAX_ROW_LIMIT:
row_limit_plus_one = self.ROW_LIMIT + 1
table_with_an_extra_row = tap.search(query=query_str, maxrec=row_limit_plus_one).to_table()
self._maybe_warn_about_table_length(table_with_an_extra_row, row_limit_plus_one)
except DALQueryError:
log.error(message(query_str))
except DALFormatError as e:
raise DALFormatError(message(query_str) + f"cause: {e.cause}") from e
except Exception as e:
> raise type(e)(f"{e}\n" + message(query_str)) from e
E astroquery.exceptions.MaxResultsWarning: Results truncated to 1000. To retrieve all the records set to None the ROW_LIMIT attribute
E Error executing the following query:
E
E select * from ivoa.ObsCore
E
E See examples here: https://archive.eso.org/tap_obs/examples
E
E For maximum query freedom use the query_tap method:
E
E >>> Eso().query_tap( "select * from ivoa.ObsCore", tap_endpoint="tap_obs")
../../.tox/test-online/lib/python3.12/site-packages/astroquery/eso/core.py:299: MaxResultsWarning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This significantly changes the warning handling to fix test failures seen in astropy#3531.
I don't know for sure that they capture the intent of these tests correctly, they just turn the tests green. You should carefully review the remote test edits before accepting.
For the non-remote tests, something like my change is required: this test was changing behavior depending on whether
--remote-datawas enabled, which is not allowed.