Skip to content

Bugfix for tests#12

Merged
juanmcloaiza merged 2 commits into
eso:develop-cataloguesfrom
keflavich:eso-develop-catalogues
Jun 10, 2026
Merged

Bugfix for tests#12
juanmcloaiza merged 2 commits into
eso:develop-cataloguesfrom
keflavich:eso-develop-catalogues

Conversation

@keflavich

Copy link
Copy Markdown

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-data was enabled, which is not allowed.

@ashleythomasbarnes

Copy link
Copy Markdown
Collaborator

@juanmcloaiza I included some of our new surveys to the ONE_RECORD_SURVEYS and SGRA_SURVEYS

@ashleythomasbarnes

Copy link
Copy Markdown
Collaborator

@juanmcloaiza

@juanmcloaiza I included some of our new surveys to the ONE_RECORD_SURVEYS and SGRA_SURVEYS

applying these change fixes the failing tests on test_eso_remote

test_eso fails with the below error running without @keflavich updates:

_____________________________________________________________________________________________________________ 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

@juanmcloaiza juanmcloaiza merged commit 1cbc2bc into eso:develop-catalogues Jun 10, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants