Skip to content

operational opendrift #17

operational opendrift

operational opendrift #17

Workflow file for this run

name: operational opendrift
on:
workflow_dispatch:
inputs:
model_type:
description: 'The kind of model to run'
required: true
default: 'oceandrift'
type: choice
options:
- oceandrift
- oil
- leeway
run_model:
description: 'run the model?'
required: true
type: boolean
default: true
do_plots:
description: 'do the plots?'
required: true
type: boolean
default: true
# Many of the env variables reference the current branch,
# which is set dynamically in the branch-ref job below
# So the env variables are mostly set in the envs job below the branch-ref job
env:
REGISTRY: ghcr.io
jobs:
# Dynamically set the branch ref to the currently executing branch
branch-ref:
runs-on: ubuntu-latest
outputs:
value: ${{ steps.BRANCH_REF.outputs.value }}
steps:
- name: Set the BRANCH_REF
id: BRANCH_REF
run: |
echo "value=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
# set some environment variables
envs:
needs: [branch-ref]
runs-on: ubuntu-latest
outputs:
BRANCH_REF: ${{ needs.branch-ref.outputs.value }}
RUN_DATE: ${{ steps.run_date.outputs.value }}
CONFIG_NAME: ${{ steps.config_name.outputs.value }}
steps:
- name: Check out source code so have access to the files in the repo
uses: actions/checkout@main
with:
ref: ${{ needs.branch-ref.outputs.value }}
- name: configuration name
id: config_name
run: |
# Use grep to find the line where the variable is defined
line=$(grep -m 1 -w config_name configs/config_${{ github.event.inputs.model_type }}.py)
# Use awk to extract the value of the variable from the line (thanks chatgpt)
echo "value=$(echo "$line" | awk -F "=" '{print $2}' | sed -e 's/^[[:space:]]*//')" >> $GITHUB_OUTPUT
- name: run date
id: run_date
run: |
# Use grep to find the line where the variable is defined
line=$(grep -m 1 -w run_date configs/config_${{ github.event.inputs.model_type }}.py)
# Use awk to extract the value of the variable from the line (thanks chatgpt)
echo "value=$(echo "$line" | awk -F "=" '{print $2}' | sed -e 's/^[[:space:]]*//')" >> $GITHUB_OUTPUT
build_image:
uses: ./.github/workflows/build_image.yml # Path to your reusable workflow
run_model:
needs: [envs,build_image]
if: ${{ github.event.inputs.run_model == 'true' }}
strategy:
matrix:
# matrix strategy allows us to run different model forcings in parallel
wind: ['GFS']
ogcm: ['MERCATOR']
uses: ./.github/workflows/run_model.yml # Path to your reusable workflow
with:
MODEL_TYPE: ${{ github.event.inputs.model_type }}
BRANCH_REF: ${{ needs.envs.outputs.BRANCH_REF }}
CONFIG_NAME: ${{ needs.envs.outputs.CONFIG_NAME }}
RUN_DATE: ${{ needs.envs.outputs.RUN_DATE }}
RUNNER_NAME: mims1
WIND: ${{ matrix.wind }}
OGCM: ${{ matrix.ogcm }}
# do some postprocessing and plotting
post_plot:
needs: [envs,run_model]
if: ${{ always() && github.event.inputs.do_plots == 'true' }}
strategy:
matrix:
# matrix strategy allows us to run different model forcings in parallel
wind: ['GFS']
ogcm: ['MERCATOR']
uses: ./.github/workflows/post_plot.yml # Path to your reusable workflow
with:
MODEL_TYPE: ${{ github.event.inputs.model_type }}
BRANCH_REF: ${{ needs.envs.outputs.BRANCH_REF }}
CONFIG_NAME: ${{ needs.envs.outputs.CONFIG_NAME }}
RUN_DATE: ${{ needs.envs.outputs.RUN_DATE }}
RUNNER_NAME: mims1
WIND: ${{ matrix.wind }}
OGCM: ${{ matrix.ogcm }}
# Archive output