Skip to content

Commit 53d415c

Browse files
authored
Merge pull request #70 from common-workflow-language/cwl_example
Example of programmatic CWL creation
2 parents 3387a34 + 6519118 commit 53d415c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

create_cwl_from_objects.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: Apache-2.0
3+
import cwl_utils.parser_v1_2 as cwl
4+
5+
from ruamel import yaml
6+
7+
def main() -> None:
8+
"""Generate a CWL object to match "cat-tool.cwl"."""
9+
inputs = [cwl.CommandInputParameter(id="file1", type="File")]
10+
outputs = [
11+
cwl.CommandOutputParameter(
12+
id="output",
13+
type="File",
14+
outputBinding=cwl.CommandOutputBinding(glob="output"),
15+
)
16+
]
17+
cat_tool = cwl.CommandLineTool(
18+
inputs=inputs,
19+
outputs=outputs,
20+
cwlVersion="v1.2",
21+
baseCommand="cat",
22+
stdin="$(inputs.file1.path)",
23+
stdout="output",
24+
)
25+
print(yaml.main.round_trip_dump(cat_tool.save()))
26+
27+
28+
if __name__ == "__main__":
29+
main()

0 commit comments

Comments
 (0)