Skip to content

Commit d82e8d7

Browse files
committed
required outputs with secondaryFiles fix for containers
1 parent 263a554 commit d82e8d7

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

cwltool/command_line_tool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,10 @@ def collect_output(
14541454
continue
14551455
if isinstance(sfitem, str):
14561456
sfitem = {"path": pathprefix + sfitem}
1457-
if not fs_access.exists(sfitem["path"]) and sf_required:
1457+
if (
1458+
not fs_access.exists(revmap(sfitem)["location"])
1459+
and sf_required
1460+
):
14581461
raise WorkflowException(
14591462
"Missing required secondary file '%s'"
14601463
% (sfitem["path"])
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
cwlVersion: v1.2
4+
class: CommandLineTool
5+
hints:
6+
DockerRequirement:
7+
dockerPull: docker.io/alpine:latest
8+
9+
baseCommand:
10+
- sh
11+
- -c
12+
- touch file.ext1 && touch file.ext2
13+
14+
inputs: []
15+
16+
outputs:
17+
output:
18+
type: File
19+
secondaryFiles:
20+
- pattern: ^.ext2
21+
required: true
22+
outputBinding:
23+
glob: file.ext1
24+

tests/test_docker.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
"""Tests for docker engine."""
2+
import json
23
import re
34
from pathlib import Path
45
from shutil import which
56

67
from cwltool.main import main
78

8-
from .util import get_data, get_main_output, needs_docker
9+
from .util import (
10+
get_data,
11+
get_main_output,
12+
needs_docker,
13+
needs_podman,
14+
needs_singularity,
15+
)
916

1017

1118
@needs_docker
@@ -136,3 +143,53 @@ def test_docker_strict_memory_limit_warning(tmp_path: Path) -> None:
136143
stderr = re.sub(r"\s\s+", " ", stderr)
137144
assert result_code == 0
138145
assert "Skipping Docker software container '--memory' limit" in stderr
146+
147+
148+
@needs_docker
149+
def test_docker_required_secfile(tmp_path: Path) -> None:
150+
result_code, stdout, stderr = get_main_output(
151+
[
152+
"--outdir",
153+
str(tmp_path),
154+
get_data("tests/secondary-files-required-container.cwl"),
155+
]
156+
)
157+
assert result_code == 0, stderr
158+
assert (
159+
json.loads(stdout)["output"]["secondaryFiles"][0]["checksum"]
160+
== "da39a3ee5e6b4b0d3255bfef95601890afd80709"
161+
)
162+
163+
164+
@needs_podman
165+
def test_podman_required_secfile(tmp_path: Path) -> None:
166+
result_code, stdout, stderr = get_main_output(
167+
[
168+
"--outdir",
169+
"--podman",
170+
str(tmp_path),
171+
get_data("tests/secondary-files-required-container.cwl"),
172+
]
173+
)
174+
assert result_code == 0, stderr
175+
assert (
176+
json.loads(stdout)["output"]["secondaryFiles"][0]["checksum"]
177+
== "da39a3ee5e6b4b0d3255bfef95601890afd80709"
178+
)
179+
180+
181+
@needs_singularity
182+
def test_singularity_required_secfile(tmp_path: Path) -> None:
183+
result_code, stdout, stderr = get_main_output(
184+
[
185+
"--outdir",
186+
"--singularity",
187+
str(tmp_path),
188+
get_data("tests/secondary-files-required-container.cwl"),
189+
]
190+
)
191+
assert result_code == 0, stderr
192+
assert (
193+
json.loads(stdout)["output"]["secondaryFiles"][0]["checksum"]
194+
== "da39a3ee5e6b4b0d3255bfef95601890afd80709"
195+
)

0 commit comments

Comments
 (0)