-
Notifications
You must be signed in to change notification settings - Fork 100
feat(copy): add exclude_from parameter for rsync-based copy in Singularity builds #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
samcmill
requested changes
Oct 20, 2025
…tring alphabetically Renamed the parameter `exclude_from` to `_exclude_from` to follow HPCCM convention that container framework-specific options begin with an underscore (e.g., `_chown`, `_mkdir`, `_post`). Also reordered the parameter documentation block in `copy.py` to maintain alphabetical order within the class docstring for consistency.
Removes the redundant `logging.info()` statement in the rsync exclusion branch of the copy primitive to keep logging output minimal and consistent with other primitives.
Refactors the _exclude_from tests to use assertEqual() with full expected recipe strings instead of multiple substring checks. This aligns the test style with other HPCCM copy primitive tests. Note: When `_exclude_from` is used, an empty %files section is still emitted after the rsync-based %setup block. This is intentional to preserve compatibility with the existing copy control flow. The extra section is harmless and may be removed in a future cleanup.
samcmill
reviewed
Oct 21, 2025
|
Thanks for the contribution! If you would please respond to the last minor comment. Otherwise, LGTM! |
|
All updates have been applied and verified. All tests are passing successfully. |
samcmill
approved these changes
Oct 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
Add
exclude_fromparameter tocopyprimitiveSummary
This PR adds an optional
exclude_fromparameter to thecopyprimitive to enable rsync-based selective file copying for Singularity and Apptainer builds.It allows users to exclude specific files and directories during image construction — analogous to Docker’s
.dockerignore— improving flexibility for large data or codebases.Motivation
When building complex scientific or HPC images, users often need to avoid copying:
Previously, the
copyprimitive always performed a full copy.This enhancement introduces optional filtering using
rsync --exclude-from, eliminating the need for pre-cleanup scripts.New Behavior
When
exclude_fromis specified, HPCCM now emits the copy logic inside the%setupsection usingrsync:%setup mkdir -p ${SINGULARITY_ROOTFS}/opt/app rsync -av --exclude-from=.apptainerignore ./ ${SINGULARITY_ROOTFS}/opt/app/ %filesOtherwise, the behavior remains unchanged and continues to use the
%filesdirective.Example Usage
Implementation Details
exclude_fromargument inhpccm/primitives/copy.py.rsync --exclude-from=<file>emitted in%setup.copyusage.logging.infodiagnostic whenexclude_fromis used.Testing
Added three new unit tests in
test/test_copy.py:test_exclude_from_single_singularitytest_exclude_from_multiple_singularitytest_exclude_from_docker_ignoredVerified that:
rsyncand%setupsections are generated for Singularity.%filesremains present but only as an empty trailing section.Results:
Backward Compatibility
exclude_fromis explicitly set_app,_mkdir,_post, and_fromChecklist
Related Discussions / References
.dockerignoreconcept.