Skip to content

Commit 29ddc69

Browse files
committed
refactor(copy): rename exclude_from to _exclude_from and reorder docstring 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.
1 parent 8e5c203 commit 29ddc69

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

hpccm/primitives/copy.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ class copy(object):
4444
4545
dest: Path in the container image to copy the file(s)
4646
47+
_exclude_from: String or list of strings. One or more filenames
48+
containing rsync-style exclude patterns (e.g., `.apptainerignore`).
49+
Only used when building for Singularity or Apptainer. If specified,
50+
the copy operation is emitted in the `%setup` section using
51+
`rsync --exclude-from=<file>` rather than the standard `%files`
52+
copy directive. This enables selective exclusion of files and
53+
directories during the image build, for example to omit large data
54+
files, caches, or temporary artifacts. Multiple exclusion files may
55+
be provided as a list or tuple. The default is an empty list
56+
(Singularity specific).
57+
4758
files: A dictionary of file pairs, source and destination, to copy
4859
into the container image. If specified, has precedence over
4960
`dest` and `src`.
@@ -66,17 +77,6 @@ class copy(object):
6677
6778
src: A file, or a list of files, to copy
6879
69-
exclude_from: String or list of strings. One or more filenames
70-
containing rsync-style exclude patterns (e.g., `.apptainerignore`).
71-
Only used when building for Singularity or Apptainer. If specified,
72-
the copy operation is emitted in the `%setup` section using
73-
`rsync --exclude-from=<file>` rather than the standard `%files`
74-
copy directive. This enables selective exclusion of files and
75-
directories during the image build, for example to omit large data
76-
files, caches, or temporary artifacts. Multiple exclusion files may
77-
be provided as a list or tuple. The default is an empty list
78-
(Singularity specific).
79-
8080
# Examples
8181
8282
```python
@@ -92,7 +92,7 @@ class copy(object):
9292
```
9393
9494
```python
95-
copy(src='.', dest='/opt/app', exclude_from='.apptainerignore')
95+
copy(src='.', dest='/opt/app', _exclude_from='.apptainerignore')
9696
```
9797
9898
"""
@@ -111,7 +111,7 @@ def __init__(self, **kwargs):
111111
self._post = kwargs.get('_post', '') # Singularity specific
112112
self.__src = kwargs.get('src', '')
113113

114-
ef = kwargs.get('exclude_from', None)
114+
ef = kwargs.get('_exclude_from', None)
115115
if ef is None:
116116
self.__exclude_from = []
117117
elif isinstance(ef, (list, tuple)):

test/test_copy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ def test_from_temp_staging(self):
258258

259259
@singularity
260260
def test_exclude_from_single_singularity(self):
261-
"""rsync-based copy with exclude_from (single source)"""
262-
c = copy(src='.', dest='/opt/app', exclude_from='.apptainerignore')
261+
"""rsync-based copy with _exclude_from (single source)"""
262+
c = copy(src='.', dest='/opt/app', _exclude_from='.apptainerignore')
263263
recipe = str(c)
264264
self.assertIn('%setup', recipe)
265265
self.assertIn('rsync -av', recipe)
@@ -270,9 +270,9 @@ def test_exclude_from_single_singularity(self):
270270

271271
@singularity
272272
def test_exclude_from_multiple_singularity(self):
273-
"""rsync-based copy with multiple exclude_from files"""
273+
"""rsync-based copy with multiple _exclude_from files"""
274274
c = copy(src='data', dest='/opt/data',
275-
exclude_from=['.ignore1', '.ignore2'])
275+
_exclude_from=['.ignore1', '.ignore2'])
276276
recipe = str(c)
277277
self.assertIn('%setup', recipe)
278278
self.assertIn('rsync -av', recipe)
@@ -284,8 +284,8 @@ def test_exclude_from_multiple_singularity(self):
284284

285285
@docker
286286
def test_exclude_from_docker_ignored(self):
287-
"""exclude_from ignored in Docker context"""
288-
c = copy(src='.', dest='/opt/app', exclude_from='.apptainerignore')
287+
"""_exclude_from ignored in Docker context"""
288+
c = copy(src='.', dest='/opt/app', _exclude_from='.apptainerignore')
289289
recipe = str(c)
290290
self.assertIn('COPY', recipe)
291291
self.assertNotIn('rsync', recipe)

0 commit comments

Comments
 (0)