更新时间:2022-05-05 GMT+08:00
分享

单一步骤(并发执行)

其次,再看一下任务并发的情况。假如用户之前脚本是这样:

#run.sh
var1=$1
var2=$2
echo "$var1\t$var2"

# 执行该脚本
sh run.sh 1 a
sh run.sh 2 a
sh run.sh 1 b
sh run.sh 2 b

则这里模板有两种写法。第一种是写出所有可能情况。为了简化,这里只展示 workflow 部分:

workflow:
  splitfq:
    tool: zsplit:0.2
    type: GCS.Job
    resources:
      memory: 1g
      cpu: 0.5c
    commands:
      - sh /obs/gcscli/run-xxx/run.sh 1 a
      - sh /obs/gcscli/run-xxx/run.sh 2 a
      - sh /obs/gcscli/run-xxx/run.sh 1 b
      - sh /obs/gcscli/run-xxx/run.sh 2 b

第二种是使用并发变量:

inputs:
  var1:
    default:
       - 1
       - 2
    description: var1
    type: array
    label: basic
  var2:
    default:
       - a
       - b
    description: var2
    type: array
    label: basic
workflow:
  splitfq:
    tool: zsplit:0.2
    type: GCS.Job
    resources:
      memory: 1g
      cpu: 0.5c
    commands_iter:
      command: >
        sh /obs/gcscli/run-xxx/run.sh ${1} ${2}
      vars_iter:
        - '${var1}'
        - '${var2}'

相关文档