Skip to content

Commit

Permalink
add the --shm-size parameter at runtime #1821
Browse files Browse the repository at this point in the history
  • Loading branch information
lihl authored and lihl2014 committed Jan 31, 2024
1 parent 35eeab4 commit 6cda4db
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cwltool/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ def create_runtime(
"assurance.",
self.name,
)

# add ShmSize parameter to docker
(shm_size_od, shm_bool) = self.builder.get_requirement("http://commonwl.org/cwltool#ShmSize")
if shm_bool:
runtime.append("--shm-size=%s" % shm_size_od["shmSize"])
return runtime, cidfile_path


Expand Down
14 changes: 14 additions & 0 deletions cwltool/extensions-v1.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,18 @@ $graph:
- Specify the desired method of dealing with loop outputs
- Default. Propagates only the last computed element to the subsequent steps when the loop terminates.
- Propagates a single array with all output values to the subsequent steps when the loop terminates.
- name: ShmSize
type: record
extends: cwl:ProcessRequirement
inVocab: false
fields:
class:
type: string
doc: 'cwltool:ShmSize'
jsonldPredicate:
"_id": "@type"
"_type": "@vocab"
shmSize:
type: string
doc: "Size of /dev/shm. The format is <number><unit>. number must be greater than 0. Unit is optional and can be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes). If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses 64m."

1 change: 1 addition & 0 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def filter(self, record: logging.LogRecord) -> bool:
"http://commonwl.org/cwltool#LoadListingRequirement",
"http://commonwl.org/cwltool#InplaceUpdateRequirement",
"http://commonwl.org/cwltool#CUDARequirement",
"http://commonwl.org/cwltool#ShmSize",
]

cwl_files = (
Expand Down
18 changes: 18 additions & 0 deletions tests/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,21 @@ def test_singularity_required_missing_secfile(
"tests/secondary-files-required-missing-container.cwl:16:5: Missing required secondary file"
)
assert "file.ext3" in stderr


@needs_docker
def test_docker_shm_size(tmp_path: Path) -> None:
result_code, stdout, stderr = get_main_output(
[
"--enable-ext",
"--default-container",
"docker.io/debian:stable-slim",
"--outdir",
str(tmp_path),
get_data("tests/wf/shm_size.cwl"),
]
)
stderr = re.sub(r"\s\s+", " ", stderr)
assert result_code == 0
assert "--shm-size=128m" in stderr

17 changes: 17 additions & 0 deletions tests/wf/shm_size.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env cwl-runner
class: CommandLineTool
cwlVersion: v1.2
requirements:
cwltool:ShmSize:
shmSize: 128m
inputs: []

outputs:
output:
type: stdout

baseCommand: echo

stdout: shm-size.txt

arguments: [ $(runtime) ]

0 comments on commit 6cda4db

Please sign in to comment.