【9.3.1】cwl 概况
两个主要的教程,还没完全整理
- https://docs.sixoclock.net/dev_guide/CWL/CommandlineTool-description-specification.html#%E6%91%98%E8%A6%81
- https://www.commonwl.org/user_guide/topics/best-practices.html
一. 简介
Common Workflow Language简称CWL
官网:https://www.commonwl.org
github:https://github.com/common-workflow-language/common-workflow-language
二. 安装
方式1
gitclone https://github.com/common-workflow-language/cwltool.git # clone cwltool repo
cd cwltool# Switch to source directory
pip install .# Install `cwltool` from source
cwltool--version# Check if the installation works correctly
方式2
pip install cwltool
三 使用方法
user guide:https://www.commonwl.org/user_guide/
cwltool [tool-or-workflow-description] [input-job-settings]
cwl文件需要写成json或yaml格式,或者两者的混合。YAML文件编写格式参考YAML Guide。
需要两个cwl文件,一个进行流程说明,一个设置输入输出和参数。
示例:
hello_world.cwl
cwlVersion: v1.2
# What type of CWL process we have in this document.
class: CommandLineTool
# This CommandLineTool executes the linux "echo" command-line tool.
baseCommand: echo
# The inputs for this process.
inputs:
message:
type: string
# A default value that can be overridden, e.g. --message "Hola mundo"
default: "Hello World"
# Bind this message value as an argument to "echo".
inputBinding:
position: 1
outputs: []
运行:
$ cwltool hello_world.cwl
INFO /opt/hostedtoolcache/Python/3.9.14/x64/bin/cwltool 3.1.20221008225030
INFO Resolved 'hello_world.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/hello_world.cwl'
INFO [job hello_world.cwl] /tmp/_aziq13k$ echo \
'Hello World'
Hello World
INFO [job hello_world.cwl] completed success
{}
INFO Final process status is success
传参方式1:
$ cwltool hello_world.cwl --message="Hola mundo"
INFO /opt/hostedtoolcache/Python/3.9.14/x64/bin/cwltool 3.1.20221008225030
INFO Resolved 'hello_world.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/hello_world.cwl'
INFO [job hello_world.cwl] /tmp/uwridbjx$ echo \
'Hola mundo'
Hola mundo
INFO [job hello_world.cwl] completed success
{}
INFO Final process status is success
传参方式2:
hello_world-job.json
{
"message": "test"
}
运行命令:
$ cwltool hello_world.cwl hello_world-job.json
INFO /opt/hostedtoolcache/Python/3.9.14/x64/bin/cwltool 3.1.20221008225030
INFO Resolved 'hello_world.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/hello_world.cwl'
INFO [job hello_world.cwl] /tmp/vmuqlnt8$ echo \
INFO [job hello_world.cwl] completed success
{}
INFO Final process status is success
3.1 YAML Guide
(1)Key-Value Pairs
冒号分割,比如first_key: value1, value2
key不能有空格,value可以有
需注意数字,如果是integer可以写123,如果要strings要写"123"。在CWL中所有的baseCommand都需要是strings,所以必须加引号:baseCommand: [echo, “42”]
(2)Commemts
用#可注释掉右侧内容
(3)Maps
在编写流程时,会建立一个复杂的map,用YAML格式进行分级,下一级“children”属于上一级“parent”,用两个空格进行缩进,不能用tab。
(4)Arrays
用-来为一个key提供多个value或objects(key-value对)。
参考资料
这里是一个广告位,,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn