Skip to content

add the --shm-size parameter at runtime #1972

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
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,
)

shm_size_od, shm_bool = self.builder.get_requirement("http://commonwl.org/cwltool#ShmSize")
if shm_bool:
shm_size = cast(CWLObjectType, shm_size_od)["shmSize"]
runtime.append(f"--shm-size={shm_size}")
return runtime, cidfile_path


Expand Down
18 changes: 18 additions & 0 deletions cwltool/extensions-v1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,21 @@ $graph:
doc: |
Maximum number of GPU devices to request. If not specified,
same as `cudaDeviceCountMin`.
- 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 default is
bytes. If you omit the size entirely, the value is `64m`."
19 changes: 18 additions & 1 deletion cwltool/extensions-v1.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,21 @@ $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 default is
bytes. If you omit the size entirely, the value is `64m`."
19 changes: 19 additions & 0 deletions cwltool/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$base: http://commonwl.org/cwltool#
$namespaces:
cwl: "https://w3id.org/cwl/cwl#"
cwltool: "http://commonwl.org/cwltool#"
$graph:
- $import: https://w3id.org/cwl/CommonWorkflowLanguage.yml

Expand Down Expand Up @@ -229,3 +230,21 @@ $graph:
doc: |
Maximum number of GPU devices to request. If not specified,
same as `cudaDeviceCountMin`.
- 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 default is
bytes. If you omit the size entirely, the value is `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) ]