From e79572c6b8692e8ed466da10a6d9b2ebb4be3f82 Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Mon, 21 Feb 2022 21:52:48 +0100 Subject: [PATCH 1/3] Test that saving async Tap jobs respects `verbose` The added test reveals that for async jobs the `astroquery/utils/tap/model/job.Job.save_results()` method prints messages about having saved the results regardless of the `verbose` setting. --- astroquery/utils/tap/model/tests/test_job.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/astroquery/utils/tap/model/tests/test_job.py b/astroquery/utils/tap/model/tests/test_job.py index 6fc9e50863..1e01f5e8a1 100644 --- a/astroquery/utils/tap/model/tests/test_job.py +++ b/astroquery/utils/tap/model/tests/test_job.py @@ -35,7 +35,7 @@ def test_job_basic(): job.get_results() -def test_job_get_results(): +def test_job_get_results(capsys, tmpdir): job = Job(async_job=True) jobid = "12345" outputFormat = "votable" @@ -82,6 +82,14 @@ def test_job_get_results(): if cn not in res.colnames: pytest.fail(f"{cn} column name not found: {res.colnames}") + # Regression test for #2299; messages were printed even with `verbose=False` + capsys.readouterr() + job._Job__resultInMemory = False + job.save_results(verbose=False) + assert 'Saving results to:' not in capsys.readouterr().out + job.save_results(verbose=True) + assert 'Saving results to:' in capsys.readouterr().out + def test_job_phase(): job = Job(async_job=True) From 94aaeb22bae8d6eb4856fbe940dbec29b1a9579e Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Mon, 21 Feb 2022 21:57:46 +0100 Subject: [PATCH 2/3] Make async `Job.save_results()` obey `verbose` The `astroquery/utils/tap/model/job.Job.save_results()` method no longer ignores the `verbose` setting in async jobs. --- astroquery/utils/tap/model/job.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/astroquery/utils/tap/model/job.py b/astroquery/utils/tap/model/job.py index 4e74fb09c5..8dc1eb1986 100755 --- a/astroquery/utils/tap/model/job.py +++ b/astroquery/utils/tap/model/job.py @@ -299,7 +299,8 @@ def save_results(self, verbose=False): output = self.outputFile else: output = self.outputFileUser - print(f"Saving results to: {output}") + if verbose: + print(f"Saving results to: {output}") self.connHandler.dump_to_file(output, response) def wait_for_job_end(self, verbose=False): From 6f9c97feafcfe38d0cf2597fe76e60459dcd909e Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Mon, 21 Feb 2022 22:07:09 +0100 Subject: [PATCH 3/3] Add change log entry for #2299 --- CHANGES.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index d0c35e5b91..dfedaec0c4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -42,6 +42,10 @@ Infrastructure, Utility and Other Changes and Additions - Callback hooks are deleted before caching. Potentially all cached queries prior to this PR will be rendered invalid. [#2295] +- The modules that make use of the ``astroquery.utils.tap.model.job.Job`` class + (e.g. Gaia) no longer print messages about where the results of async queries + were written if the ``verbose`` setting is ``False``. [#2299] + 0.4.5 (2021-12-24) ==================