Moved all singularity-related download functions into a new file
Closes #3019 Supersedes #3163
Ongoing work part of the "Workflows to go" hackathon project. I've started moving all singularity functions into a new file.
Overview of the moves from nf_core/pipelines/download.py
| Object or function | New file | New name |
|---|---|---|
| DownloadError | downloads/utils | (same name) |
| DownloadProgress | downloads/utils | (same name) |
| ContainerError | downloads/singularity | (same name) |
| symlink_singularity_images | downloads/singularity | symlink_registries |
| singularity_image_filenames | downloads/singularity | get_container_filename |
| singularity_copy_cache_image | downloads/singularity | SingularityFetcher.copy_image |
| singularity_download_image | downloads/utils | FileDownloader.download_file |
| singularity_pull_image | downloads/singularity | SingularityFetcher.pull_image |
| get_singularity_images (part of) | downloads/singularity | SingularityFetcher.fetch_containers, SingularityFetcher.pull_images, SingularityFetcher.download_images |
| get_singularity_images (part of) | downloads/utils | FileDownloader.download_files_in_parallel |
In this move, I wanted to have clean copy/download/pull_image functions that know nothing about a "cache" or a "library". They're just given a path they need to put their file into. I was also able to decouple things and move code from methods to functions when access to class variables etc wasn't really needed. Or in the case of the file downloads, I've introduced a dedicated class where only the necessary state is tracked.
So far, we've got this functionality in downloads.utils:
intermediate_fileis a context manager for getting download/copy operations done in a temporary file that is deleted if there is a problem. This is to avoid polluting the cache/output directories with partial files (the question was raised in https://github.com/nf-core/tools/pull/3163#discussion_r1768694798) and I've rolled it out across all three source methods.DownloadProgressis the extension ofrich.progress. I've added helper methods to deal with the "main task" and "sub tasks"FileDownloadercan download files in parallel. I've reviewed the handling of errors and exceptions to make sure that no state if left behind.
and in downloads.singularity:
get_container_filenamereturns the name a container will have on disk, taking into consideration a set of registry prefixes to ignore.symlink_registriescreates symlinks for a container so that the same image file can be used across registries.
That's all completely covered in unit tests.
At this minute, I'm not 100% settled on this SingularityFetcher class. I want to look into decoupling it a bit more.
PR checklist
- [ ] This comment contains a description of changes (with reason)
- [ ]
CHANGELOG.mdis updated - [ ] If you've fixed a bug or added code that should be tested, add tests!
- [ ] Documentation in
docsis updated
Codecov Report
:x: Patch coverage is 63.17204% with 137 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 77.45%. Comparing base (33830f9) to head (ea4bc89).
:warning: Report is 840 commits behind head on dev.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Thank you very much for your contribution! Your commits have been merged into #3634 and will be added through this branch. If you have time to test and review, this would be amazing!