|
13 | 13 |
|
14 | 14 | from .builder import Builder |
15 | 15 | from .context import RuntimeContext |
| 16 | +from .docker import DockerCommandLineJob |
16 | 17 | from .errors import WorkflowException |
17 | 18 | from .job import ContainerCommandLineJob |
18 | 19 | from .loghandler import _logger |
@@ -106,6 +107,14 @@ def is_version_3_4_or_newer() -> bool: |
106 | 107 | return v[0][0] >= 4 or (v[0][0] == 3 and v[0][1] >= 4) |
107 | 108 |
|
108 | 109 |
|
| 110 | +def is_version_3_9_or_newer() -> bool: |
| 111 | + """Detect if Singularity v3.9+ is available.""" |
| 112 | + if is_apptainer_1_or_newer(): |
| 113 | + return True # this is equivalent to singularity-ce > 3.9.5 |
| 114 | + v = get_version() |
| 115 | + return v[0][0] >= 4 or (v[0][0] == 3 and v[0][1] >= 9) |
| 116 | + |
| 117 | + |
109 | 118 | def _normalize_image_id(string: str) -> str: |
110 | 119 | return string.replace("/", "_") + ".img" |
111 | 120 |
|
@@ -297,13 +306,16 @@ def get_from_requirements( |
297 | 306 | @staticmethod |
298 | 307 | def append_volume(runtime: List[str], source: str, target: str, writable: bool = False) -> None: |
299 | 308 | """Add binding arguments to the runtime list.""" |
300 | | - runtime.append("--bind") |
301 | | - # Mounts are writable by default, so 'rw' is optional and not |
302 | | - # supported (due to a bug) in some 3.6 series releases. |
303 | | - vol = f"{source}:{target}" |
304 | | - if not writable: |
305 | | - vol += ":ro" |
306 | | - runtime.append(vol) |
| 309 | + if is_version_3_9_or_newer(): |
| 310 | + DockerCommandLineJob.append_volume(runtime, source, target, writable, skip_mkdirs=True) |
| 311 | + else: |
| 312 | + runtime.append("--bind") |
| 313 | + # Mounts are writable by default, so 'rw' is optional and not |
| 314 | + # supported (due to a bug) in some 3.6 series releases. |
| 315 | + vol = f"{source}:{target}" |
| 316 | + if not writable: |
| 317 | + vol += ":ro" |
| 318 | + runtime.append(vol) |
307 | 319 |
|
308 | 320 | def add_file_or_directory_volume( |
309 | 321 | self, runtime: List[str], volume: MapperEnt, host_outdir_tgt: Optional[str] |
|
0 commit comments