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

复杂依赖任务(DAG)

如果有四个任务,a/b/c/d 我们希望首先执行 任务 a,然后执行 b/c,b/c 同时完成后,最后执行 d,如下图所示:

为了实现这个目标,需要引入 depends 字段。以任务 d为例,完成任务 d 需要首先完成任务 b/c,则depends 字段为:

    depends:
      - target: b
        type: whole
      - target: c
        type: whole

完整代码如下:

version: genecontainer_0_1
inputs:
  memory:
    default: 1g
    type: string
  cpu:
    default: 0.5c
    type: string
  tool:
    default: bwa:0.7.12
    type: string
  shell:
    default: sh
    type: string

workflow:
  a:
    tool: bwa:0.7.12
    type: GCS.Job
    resources:
      memory: 1g
      cpu: 0.5c
    commands:
      - echo "A"
  b:
    tool: bwa:0.7.12
    type: GCS.Job
    resources:
      memory: 1g
      cpu: 0.5c
    commands:
      - echo "B"
    depends:
      - target: a
        type: whole
  c:
    tool: bwa:0.7.12
    type: GCS.Job
    resources:
      memory: 1g
      cpu: 0.5c
    commands:
      - echo "C"
    depends:
      - target: a
        type: whole
  d:
    tool: bwa:0.7.12
    type: GCS.Job
    resources:
      memory: 1g
      cpu: 0.5c
    commands:
      - echo "D"
    depends:
      - target: b
        type: whole
      - target: c
        type: whole
volumes:
  sample-data:
    mount_path: /obs
    mount_from:
      pvc: ${GCS_DATA_PVC}
  temp-data:
    mount_path: /sfs
    mount_from:
      pvc: ${GCS_SFS_PVC}
  ref-data:
    mount_path: /ref
    mount_from:
      pvc: ${GCS_REF_PVC}

相关文档