Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated during tests
pytestdebug.log
tmp/
*.sif
involucro

# Python temps
__pycache__/
Expand Down Expand Up @@ -59,4 +61,3 @@ cwltool/_version.py
cwltool_deps
docs/_build/
docs/autoapi/

4 changes: 2 additions & 2 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def bind_input(
and "itemSeparator" not in binding
):
st["inputBinding"] = {}
for k in ("secondaryFiles", "format", "streamable"):
for k in ("secondaryFiles", "format", "streamable", "loadContents"):
if k in schema:
st[k] = schema[k]
if value_from_expression:
Expand Down Expand Up @@ -349,7 +349,7 @@ def bind_input(
"type": schema["items"],
"inputBinding": b2,
}
for k in ("secondaryFiles", "format", "streamable"):
for k in ("secondaryFiles", "format", "streamable", "loadContents"):
if k in schema:
itemschema[k] = schema[k]
bindings.extend(
Expand Down
1 change: 1 addition & 0 deletions tests/load_contents-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
1 change: 1 addition & 0 deletions tests/load_contents-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
24 changes: 24 additions & 0 deletions tests/load_contents-array.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cwlVersion: "v1.2"
class: CommandLineTool
baseCommand: echo
requirements:
InlineJavascriptRequirement: {}
inputs:
files:
type:
type: array
items: File
loadContents: true
inputBinding:
valueFrom: |
${
return JSON.stringify({
"data": inputs.files.map(item => parseInt(item.contents))
});
}
outputs:
out:
type: File
outputBinding:
glob: "data.json"
stdout: "data.json"
5 changes: 5 additions & 0 deletions tests/load_contents-array.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
files:
- class: File
path: load_contents-1.txt
- class: File
path: load_contents-2.txt
22 changes: 22 additions & 0 deletions tests/test_load_contents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Test the loadContents feature."""

import json
from pathlib import Path

from cwltool.main import main

from .util import get_data


def test_load_contents_file_array(tmp_path: Path) -> None:
"""Ensures that a File[] input with loadContents loads each file."""
params = [
"--outdir",
str(tmp_path),
get_data("tests/load_contents-array.cwl"),
str(Path(__file__) / "../load_contents-array.yml"),
]
assert main(params) == 0
with open(tmp_path / "data.json") as out_fd:
data = json.load(out_fd)
assert data == {"data": [1, 2]}