Skip to content

Commit 5e9b817

Browse files
authored
Merge pull request #2299 from eerovaher/tap-silent-write
Make `astroquery/utils/tap/model/job.Job.save_results()` obey `verbose` setting
2 parents bb92dd1 + 6f9c97f commit 5e9b817

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ Infrastructure, Utility and Other Changes and Additions
4242
- Callback hooks are deleted before caching. Potentially all cached queries
4343
prior to this PR will be rendered invalid. [#2295]
4444

45+
- The modules that make use of the ``astroquery.utils.tap.model.job.Job`` class
46+
(e.g. Gaia) no longer print messages about where the results of async queries
47+
were written if the ``verbose`` setting is ``False``. [#2299]
48+
4549

4650
0.4.5 (2021-12-24)
4751
==================

astroquery/utils/tap/model/job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ def save_results(self, verbose=False):
299299
output = self.outputFile
300300
else:
301301
output = self.outputFileUser
302-
print(f"Saving results to: {output}")
302+
if verbose:
303+
print(f"Saving results to: {output}")
303304
self.connHandler.dump_to_file(output, response)
304305

305306
def wait_for_job_end(self, verbose=False):

astroquery/utils/tap/model/tests/test_job.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_job_basic():
3535
job.get_results()
3636

3737

38-
def test_job_get_results():
38+
def test_job_get_results(capsys, tmpdir):
3939
job = Job(async_job=True)
4040
jobid = "12345"
4141
outputFormat = "votable"
@@ -82,6 +82,14 @@ def test_job_get_results():
8282
if cn not in res.colnames:
8383
pytest.fail(f"{cn} column name not found: {res.colnames}")
8484

85+
# Regression test for #2299; messages were printed even with `verbose=False`
86+
capsys.readouterr()
87+
job._Job__resultInMemory = False
88+
job.save_results(verbose=False)
89+
assert 'Saving results to:' not in capsys.readouterr().out
90+
job.save_results(verbose=True)
91+
assert 'Saving results to:' in capsys.readouterr().out
92+
8593

8694
def test_job_phase():
8795
job = Job(async_job=True)

0 commit comments

Comments
 (0)