Skip to content

Commit

Permalink
Ignore DALOverflowWarning in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmcloaiza committed Feb 13, 2025
1 parent 94c2b38 commit 71d4681
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
11 changes: 6 additions & 5 deletions astroquery/eso/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EsoClass(QueryWithLogin):
DOWNLOAD_URL = "https://dataportal.eso.org/dataPortal/file/"
AUTH_URL = "https://www.eso.org/sso/oidc/token"
GUNZIP = "gunzip"
USE_DEV_TAP = True
USE_DEV_TAP = False

def __init__(self, timeout=None):
super().__init__()
Expand Down Expand Up @@ -254,7 +254,8 @@ def query_tap_service(self,

tap = pyvo.dal.TAPService(EsoClass.tap_url())
table_to_return = None
log.debug(f"querystr = {query_str}")
logmsg = f"querystr = {query_str}"
log.debug(logmsg)
try:
if not cache:
with cache_conf.set_temp("cache_active", False):
Expand All @@ -274,9 +275,9 @@ def query_tap_service(self,
except Exception as e:
raise RuntimeError(
f"Unhandled exception {type(e)}\n"
"While executing the following query:\n\n"
f"{query_str}\n\n"
"See examples here: https://archive.eso.org/tap_obs/examples\n\n") from e
"While executing the following query:\n\n"
f"{query_str}\n\n"
"See examples here: https://archive.eso.org/tap_obs/examples\n\n") from e

if len(table_to_return) < 1:
warnings.warn("Query returned no results", NoResultsWarning)
Expand Down
11 changes: 11 additions & 0 deletions astroquery/eso/tests/test_eso_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

@pytest.mark.remote_data
class TestEso:
@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_query_tap_service(self):
eso = Eso()
eso.ROW_LIMIT = 7
Expand All @@ -53,6 +54,7 @@ def test_query_tap_service(self):
assert len(t) > 0, "Table length is zero"
assert len(t) == eso.ROW_LIMIT, f"Table length is {lt}, expected {eso.ROW_LIMIT}"

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_row_limit(self):
eso = Eso()
eso.ROW_LIMIT = 5
Expand All @@ -73,6 +75,7 @@ def test_row_limit(self):
n = len(table)
assert n == eso.ROW_LIMIT, f"Expected {eso.ROW_LIMIT}; Obtained {n}"

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_top(self):
eso = Eso()
top = 5
Expand All @@ -91,6 +94,7 @@ def test_top(self):
n = len(table)
assert n == top, f"Expected {top}; Obtained {n}"

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_SgrAstar(self):
eso = Eso()
eso.ROW_LIMIT = 1
Expand Down Expand Up @@ -130,6 +134,7 @@ def test_SgrAstar(self):
assert 'target_name' in result_s.colnames
assert 'b319' in result_s['target_name']

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_multicollection(self, tmp_path):

eso = Eso()
Expand All @@ -151,6 +156,7 @@ def test_multicollection(self, tmp_path):
for tc in test_collections:
assert counts[tc] > 0, f"{tc} : collection not present in results"

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_empty_return(self):
# test for empty return with an object from the North
eso = Eso()
Expand All @@ -164,6 +170,7 @@ def test_empty_return(self):

assert len(result_s) == 0

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_SgrAstar_remotevslocal(self, tmp_path):
eso = Eso()
# TODO originally it was 'gravity', but it is not yet ready in the TAP ISTs
Expand Down Expand Up @@ -236,6 +243,7 @@ def test_apex_retrieval(self):

assert np.all(tbl == tblb)

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_each_instrument_SgrAstar(self, tmp_path):
eso = Eso()
eso.cache_location = tmp_path
Expand Down Expand Up @@ -272,6 +280,7 @@ def test_each_instrument_SgrAstar(self, tmp_path):
assert result is not None, f"query_instrument({instrument}) returned None"
assert len(result) > 0, f"query_instrument({instrument}) returned no records"

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_each_collection_and_SgrAstar(self, tmp_path):
eso = Eso()
eso.cache_location = tmp_path
Expand Down Expand Up @@ -301,6 +310,7 @@ def test_each_collection_and_SgrAstar(self, tmp_path):
assert len(generic_result) > 0, \
f"query_collection({collection}) returned no records"

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_mixed_case_instrument(self, tmp_path):
eso = Eso()
eso.cache_location = tmp_path
Expand All @@ -314,6 +324,7 @@ def test_mixed_case_instrument(self, tmp_path):

assert all(result1.values_equal(result2))

@pytest.mark.filterwarnings("ignore::pyvo.dal.exceptions.DALOverflowWarning")
def test_main_SgrAstar(self):
eso = Eso()
eso.ROW_LIMIT = 5
Expand Down
1 change: 0 additions & 1 deletion astroquery/eso/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def py2adql(table: str, columns: Union[List, str] = None,
if count_only:
columns = ['count(*)']


# Build the query
query_string = ', '.join(columns) + ' from ' + table
if len(wc) > 0:
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ filterwarnings =
ignore:The upstream SHA API has been changed:UserWarning
# CDMS triggers this, but we don't use it directly
ignore: The 'strip_cdata' option of HTMLParser:DeprecationWarning
# TAP triggers DALOverflowWarning when the maxrec of the queries is set
ignore:Partial result set:pyvo.dal.exceptions.DALOverflowWarning

markers =
bigdata: marks tests that are expected to trigger a large download (deselect with '-m "not bigdata"')
Expand Down

0 comments on commit 71d4681

Please sign in to comment.