Skip to content

Commit

Permalink
add the --shm-size parameter at runtime common-workflow-language#1821
Browse files Browse the repository at this point in the history
  • Loading branch information
lihl authored and mr-c committed Jan 31, 2024
1 parent 35eeab4 commit 043da28
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cwltool/cwlprov/provenance_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def declare_artefact(self, value: Any) -> ProvEntity:
self.research_object.add_uri(entity.identifier.uri)
return entity

if isinstance(value, (str, str)):
if isinstance(value, str):
(entity, _) = self.declare_string(value)
return entity

Expand Down
4 changes: 3 additions & 1 deletion cwltool/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ def create_runtime(
"assurance.",
self.name,
)

shm_size_od, shm_bool = self.builder.get_requirement("http://commonwl.org/cwltool#ShmSize")
if shm_bool:
runtime.append(f"--shm-size={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
2 changes: 1 addition & 1 deletion cwltool/singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def add_writable_file_volume(
if self.inplace_update:
try:
os.link(os.path.realpath(volume.resolved), host_outdir_tgt)
except os.error:
except OSError:
shutil.copy(volume.resolved, host_outdir_tgt)
else:
shutil.copy(volume.resolved, host_outdir_tgt)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,20 @@ 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 043da28

Please sign in to comment.