Skip to content

Commit

Permalink
add SAWS forced workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GilesFearon committed Sep 19, 2024
1 parent c54bdda commit 547643f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 28 deletions.
39 changes: 34 additions & 5 deletions .github/workflows/run_model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,26 @@ on:
description: 'name of wind forcing e.g. GFS'
required: true
type: string
RUN_MODEL:
description: 'run the model?'
required: true
type: string
DO_POST:
description: 'do the postprocessing?'
required: true
type: string
OGCM:
description: 'name of boundary forcing e.g. MERCATOR'
required: true
type: string
EXTENTS:
description: 'spatial extent of the gridded output and plot, in format lon0,lon1,lat0,lat1. If None, then this is dynamically determined from the geographic extent of the particles'
required: true
type: string
DX_M:
description: 'grid size (m) used to grid particle output. If None, If None, then a 50 x 50 regular grid is generated'
required: true
type: string

env:
# the directory to get mounted when running the docker image
Expand All @@ -41,7 +57,8 @@ env:
RUN_DIR: /home/somisana/ops/${{ inputs.BRANCH_REF }}/${{ inputs.RUN_DATE }}/opendrift_${{ inputs.MODEL_TYPE }}/${{ inputs.CONFIG_NAME }}/${{ inputs.OGCM }}_${{ inputs.WIND }}

jobs:
setup-run-dir:
run-model:
if: ${{ inputs.RUN_MODEL == 'true' }}
runs-on: ${{ inputs.RUNNER_NAME }}
steps:
- name: Check out source code so have access to the files in the repo
Expand All @@ -65,10 +82,6 @@ jobs:
chmod -R 774 ${{ env.RUN_DIR }}
continue-on-error: true

run-model:
needs: [setup-run-dir]
runs-on: ${{ inputs.RUNNER_NAME }}
steps:
- name: run the model
run: |
# we're specifying --user root due to permission issues I wasn't clever enough to solve
Expand All @@ -82,3 +95,19 @@ jobs:
--config_dir ${{ env.RUN_DIR_DOCKER }}
# change ownership to somisana user
sudo chown -R somisana:somisana ${{ env.RUN_DIR }}
# do some postprocessing and plotting
postprocess:
needs: [run-model]
if: ${{ always() && inputs.DO_POST == 'true' }}
uses: ./.github/workflows/postprocess.yml # Path to your reusable workflow
with:
MODEL_TYPE: ${{ inputs.MODEL_TYPE }}
BRANCH_REF: ${{ inputs.BRANCH_REF }}
CONFIG_NAME: ${{ inputs.CONFIG_NAME }}
RUN_DATE: ${{ inputs.RUN_DATE }}
RUNNER_NAME: ${{ inputs.RUNNER_NAME }}
WIND: ${{ inputs.WIND }}
OGCM: ${{ inputs.OGCM }}
EXTENTS: ${{ inputs.EXTENTS }}
DX_M: ${{ inputs.DX_M }}
42 changes: 19 additions & 23 deletions .github/workflows/run_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
id: BRANCH_REF
run: |
echo "value=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
# set some environment variables
envs:
needs: [branch-ref]
Expand Down Expand Up @@ -80,44 +81,39 @@ jobs:
build_image:
uses: ./.github/workflows/build_image.yml # Path to your reusable workflow

run_model:

# I thought about using the matrix strategy to run models in parallel, but if one job fails, then they all get called off so it's better run them as separate jobs, which still get run in parallel

run_GFS_MERCATOR:
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 }}
WIND: GFS
OGCM: MERCATOR
RUN_MODEL: ${{ github.event.inputs.run_model }}
DO_POST: ${{ github.event.inputs.do_post }}
EXTENTS: ${{ github.event.inputs.extents }}
DX_M: ${{ github.event.inputs.dx_m }}

# do some postprocessing and plotting
postprocess:
needs: [envs,run_model]
if: ${{ always() && github.event.inputs.do_post == 'true' }}
strategy:
matrix:
# matrix strategy allows us to run different model forcings in parallel
wind: ['GFS']
ogcm: ['MERCATOR']
uses: ./.github/workflows/postprocess.yml # Path to your reusable workflow
run_SAWS_MERCATOR:
needs: [envs,build_image]
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 }}
WIND: SAWS
OGCM: MERCATOR
RUN_MODEL: ${{ github.event.inputs.run_model }}
DO_POST: ${{ github.event.inputs.do_post }}
EXTENTS: ${{ github.event.inputs.extents }}
DX_M: ${{ github.event.inputs.dx_m }}

# get some combined output from runs with different forcings?

0 comments on commit 547643f

Please sign in to comment.