Skip to content

Make simpeg.utils.download respect the verbose argument - #1777

Merged
santisoler merged 2 commits into
simpeg:mainfrom
manduinca:fix-download-verbose
Aug 31, 2026
Merged

santisoler merged 2 commits into
simpeg:mainfrom
manduinca:fix-download-verbose

Conversation

@manduinca

@manduinca manduinca commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

simpeg.utils.download printed its progress messages regardless of the verbose argument.

PR Checklist

  • Linted my code according to the style guides.
  • Added tests to verify changes to the code.

Reference issue

Closes #629

What does this implement/fix?

Only the messages about preexisting files were guarded by verbose. The "Downloading ...", " saved to: ..." and "Download completed!" messages were printed unconditionally, so verbose=False did not silence the function. I put the three remaining prints behind the same check.

Additional information

The new tests mock urllib.request.urlretrieve so they don't hit the network, and use capsys to check the output. They live in a separate pytest class because the existing TestDownload is a unittest.TestCase, which can't take the capsys fixture. Both fail on main and pass with the change.

I kept the verbose flag instead of moving these messages to the SimPEG logger, to keep the change scoped to the issue. Happy to do that instead if you prefer.

Squash and Merge Summary

Make simpeg.utils.download to only print out messages to stdout if verbose is True. Test the bugfix by mocking urllib to avoid requiring network connection.

The download progress messages were printed unconditionally, so
verbose=False only silenced the messages about preexisting files.
@codecov

codecov Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.75%. Comparing base (41727cb) to head (0ff5384).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1777   +/-   ##
=======================================
  Coverage   81.74%   81.75%           
=======================================
  Files         425      425           
  Lines       55748    55773   +25     
  Branches     5295     5298    +3     
=======================================
+ Hits        45572    45598   +26     
  Misses       8762     8762           
+ Partials     1414     1413    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@santisoler santisoler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @manduinca a lot for taking the time to work on this PR. I left a few comments below. Let me know what do you think!

Comment thread tests/base/test_utils.py Resolved
Comment thread tests/base/test_utils.py Resolved
Comment thread tests/base/test_utils.py Resolved
Comment thread tests/base/test_utils.py Resolved
@manduinca

Copy link
Copy Markdown
Contributor Author

Thanks for the review @santisoler! I applied all your suggestions: f-strings in the two prints and the explicit mock_urlretrieve fixture in the three tests. I ran tests/base/test_utils.py locally (29 passed) and black/flake8 come back clean.

@santisoler

Copy link
Copy Markdown
Member

Thanks a lot @manduinca! I'm merging this! 🚀

@santisoler
santisoler merged commit e203ecf into simpeg:main Aug 31, 2026
22 checks passed
@santisoler santisoler changed the title Make download respect the verbose argument Make simpeg.utils.download respect the verbose argument Aug 31, 2026
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.

SimPEG.Utils.download "verbose" switch does not control all the output

2 participants