kind: Workflow
metadata:
  annotations:
    argo-connector/keywords: SDM,Workflow,BMD,Biodiversity Meets Data
    argo-connector/license: https://spdx.org/licenses/CC-BY-SA-4.0
    argo-connector/notify: 'true'
    argo-connector/submitterId1: https://orcid.org/0000-0002-0487-2151
    argo-connector/submitterName1: Lena Perzlmaier
    argo-connector/webhookURL: http://bmd-bat-app:8080/api/workflows/webhook/{workflow_id}
    workflows.argoproj.io/description: This is an R-script demonstrating a SDM modeling
      workflow. The purpose of the script is to demonstrate (in a simplified way)
      what a workflow could look like based on bats species.
    workflows.argoproj.io/last-seen-version: '21437708'
    workflows.argoproj.io/pod-name-format: v2
    workflows.argoproj.io/title: Species distribution modeling for bats example workflow
spec:
  arguments:
    parameters:
    - description: Species scientific name
      name: target_species
      value: Heracleum mantegazzianum Sommier & Levier
    - description: Time period selection
      name: climate_periods
      value: 1981-2010;2041-2070
    - description: Geometry in WKT
      name: aoi_wkt
      value: POLYGON ((10.568848 50.847573, 10.568848 53.014783, 13.271484 53.014783,
        13.271484 50.847573, 10.568848 50.847573))
  artifactGC:
    forceFinalizerRemoval: true
  entrypoint: main-workflow
  onExit: exit-handler
  podGC:
    strategy: OnWorkflowCompletion
  templates:
  - inputs: {}
    metadata: {}
    name: main-workflow
    outputs: {}
    steps:
    - - arguments:
          parameters:
          - name: target_species
            value: '{{workflow.parameters.target_species}}'
        name: download-occurrences
        template: download-occurrences
    - - arguments:
          artifacts:
          - from: '{{steps.download-occurrences.outputs.artifacts.gbif-occurrences}}'
            name: gbif-occurrences
          parameters:
          - name: target_species
            value: '{{workflow.parameters.target_species}}'
          - name: climate_periods
            value: '{{workflow.parameters.climate_periods}}'
          - name: aoi_wkt
            value: '{{workflow.parameters.aoi_wkt}}'
        name: run-sdm
        template: run-sdm
  - container:
      args:
      - --target_species={{inputs.parameters.target_species}}
      command:
      - Rscript
      - /app/scripts/01_download.R
      image: taimurhk/gbif-maxent:v5
      name: ''
      resources: {}
      workingDir: /app/scripts
    inputs:
      parameters:
      - name: target_species
    metadata: {}
    name: download-occurrences
    outputs:
      artifacts:
      - archive:
          none: {}
        name: gbif-occurrences
        path: /app/scripts/outputs/
  - container:
      args:
      - --target_species={{inputs.parameters.target_species}}
      - --climate_periods={{inputs.parameters.climate_periods}}
      - --aoi_wkt={{inputs.parameters.aoi_wkt}}
      command:
      - Rscript
      - /app/scripts/02_sdm.R
      image: taimurhk/gbif-maxent:v5
      name: ''
      resources: {}
      workingDir: /app/scripts
    inputs:
      artifacts:
      - name: gbif-occurrences
        path: /app/scripts/outputs/
      parameters:
      - name: target_species
      - name: climate_periods
      - name: aoi_wkt
    metadata: {}
    name: run-sdm
    outputs:
      artifacts:
      - archive:
          none: {}
        name: sdm-results
        path: /app/scripts/outputs/
  - inputs: {}
    metadata: {}
    name: exit-handler
    outputs: {}
    steps:
    - - arguments: {}
        inline:
          http:
            headers:
            - name: Authorization
              valueFrom:
                secretKeyRef:
                  key: token
                  name: argo-connector-auth-secret
            insecureSkipVerify: true
            successCondition: response.statusCode == 202
            timeoutSeconds: 10
            url: https://workflow.earth/connector/notify/{{ workflow.namespace }}/{{workflow.name
              }}
          inputs: {}
          metadata: {}
          outputs: {}
          retryStrategy:
            backoff:
              duration: 1m
              factor: '2'
              maxDuration: 30m
            limit: '10'
        name: notify-argo-connector
        when: '{{ workflow.status }} == Succeeded && {{ workflow.annotations.argo-connector/notify
          }} == true'
