Skip to content

Commit

Permalink
Merge pull request #2299 from eerovaher/tap-silent-write
Browse files Browse the repository at this point in the history
Make `astroquery/utils/tap/model/job.Job.save_results()` obey `verbose` setting
  • Loading branch information
bsipocz authored Feb 22, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents bb92dd1 + 6f9c97f commit 5e9b817
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
==================
3 changes: 2 additions & 1 deletion astroquery/utils/tap/model/job.py
Original file line number Diff line number Diff line change
@@ -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):
10 changes: 9 additions & 1 deletion astroquery/utils/tap/model/tests/test_job.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5e9b817

Please sign in to comment.