kind: Workflow
metadata:
  annotations:
    argo-connector/keywords: BIOCLIM,ERA5
    argo-connector/license: https://spdx.org/licenses/MIT
    argo-connector/notify: 'true'
    argo-connector/submitterId1: https://orcid.org/0000-0002-0487-2151
    argo-connector/submitterName1: Lena Perzlmaier
    workflows.argoproj.io/description: BIOCLIM data generation from ERA5 data via
      DestinEarth HDA Stac API. This workflow uses the DestinEarth HDA Stac API to
      retrieve the relevant ERA5 data.
    workflows.argoproj.io/pod-name-format: v2
    workflows.argoproj.io/title: BIOCLIM data generation from ERA5 data via DestinEarth
      HDA Stac API
spec:
  arguments:
    parameters:
    - description: Start year for bioclimatic data retrieval
      name: startYearBioclim
      value: '2022'
    - description: End year for bioclimatic data retrieval
      name: endYearBioclim
      value: '2022'
  artifactGC:
    forceFinalizerRemoval: true
  entrypoint: workflow
  onExit: exit-handler
  podGC:
    strategy: OnPodCompletion
  templates:
  - inputs: {}
    metadata: {}
    name: workflow
    outputs: {}
    steps:
    - - arguments:
          parameters:
          - name: startYearBioclim
            value: '{{ workflow.parameters.startYearBioclim }}'
          - name: endYearBioclim
            value: '{{ workflow.parameters.endYearBioclim }}'
        name: retrieve-bioclim-data
        template: retrieve-bioclim-data
  - container:
      command:
      - uv
      - run
      - main.py
      - --start-year
      - '{{ inputs.parameters.startYearBioclim }}'
      - --end-year
      - '{{ inputs.parameters.endYearBioclim }}'
      - --keep-raw
      - 'False'
      env:
      - name: DEDL_USER
        valueFrom:
          secretKeyRef:
            key: user
            name: dedl-secret
      - name: DEDL_PWD
        valueFrom:
          secretKeyRef:
            key: pwd
            name: dedl-secret
      image: ghcr.io/lenipe/bioclim/bioclim:v1
      name: retrieve-bioclim-data-container
      resources: {}
    inputs:
      artifacts:
      - archive:
          none: {}
        name: bioclim-raw-data
        optional: true
        path: /app/data
        s3:
          key: bioclim-raw-data
      parameters:
      - name: startYearBioclim
      - name: endYearBioclim
    metadata: {}
    name: retrieve-bioclim-data
    outputs:
      artifacts:
      - archive:
          none: {}
        name: bioclim-raw-data-updated
        path: /app/data
        s3:
          key: bioclim-raw-data
      - name: cache_cwr_dedl
        path: /app/data/bioclim/BV_{{ inputs.parameters.startYearBioclim }}-{{ inputs.parameters.endYearBioclim
          }}.nc
        s3:
          key: cache_cwr_dedl/Data/Environment/BV_{{ inputs.parameters.startYearBioclim
            }}-{{ inputs.parameters.endYearBioclim }}.nc
  - 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'
