Skip to content

How to create nested workflows

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cwlVersion: v1.0

$graph:
- class: Workflow

  id: main

  requirements: 
  - class: ScatterFeatureRequirement
  - class: SubworkflowFeatureRequirement

  inputs:

    red: 
      type: string
    green: 
      type: string
    blue: 
      type: string
    product:
      type: string[]

  outputs:

    preview: 
      outputSource: node_clip/preview
      type:
        type: array
        items:
          type: array
          items: File

  steps:

    node_clip:

      run: "#clipper"

      in:
        red: red
        green: green
        blue: blue
        product: product

      out:
      - preview

      scatter: product
      scatterMethod: dotproduct 

- class: Workflow

  id: clipper

  requirements: 
  - class: MultipleInputFeatureRequirement
  - class: ScatterFeatureRequirement

  inputs:

    red: 
      type: string
    green: 
      type: string
    blue: 
      type: string
    product:
      type: string

  outputs:

    preview: 
      outputSource: node_gdal/preview
      type: File[]

  steps:

    node_gdal:

      in: 
        band: [red, green, blue]
        product: product

      out: 
      - preview

      run:
        "#gdal"

      scatter: band
      scatterMethod: dotproduct 


- class: CommandLineTool

  id: gdal

  requirements:
    InlineJavascriptRequirement: {}
    EnvVarRequirement:
      envDef:
        PROJ_LIB: /srv/conda/envs/notebook/share/proj
  hints:
    DockerRequirement: 
      dockerPull: docker.io/osgeo/gdal  
  baseCommand: gdal_translate

  arguments: 
  - -of
  - PNG
  - -ot 
  - Byte
  - -srcwin 
  - "1000"
  - "1000"
  - "500"
  - "500"
  - valueFrom: $( inputs.product + "/" + inputs.band + ".tif")
  - valueFrom: $(  inputs.product.split("/").slice(-1)[0] + "_" + inputs.band + ".png" )

  inputs:

    product: 
      type: string
    band:
      type: string

  outputs:

    preview: 
      type: File
      outputBinding:
        glob: "*.png"
product: 
- 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/10/T/FK/2021/7/S2B_10TFK_20210713_0_L2A'
- 'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/10/T/FK/2021/7/S2B_10TFK_20210723_0_L2A'
red: "B04"
green: "B03"
blue: "B02"