-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·163 lines (152 loc) · 6.19 KB
/
run_ops.yml
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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_post:
description: 'do the postprocessing?'
required: true
type: boolean
default: true
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
default: None
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
default: None
type: string
# 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
# 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]
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: 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 }}
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: 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 }}
run_GFS_HYCOM:
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: GFS
OGCM: HYCOM
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 }}
run_SAWS_HYCOM:
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: SAWS
OGCM: HYCOM
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
# maybe we need a check to see if more than 1 run was actually successful?
combine_output:
needs: [envs,run_SAWS_MERCATOR,run_GFS_MERCATOR,run_SAWS_HYCOM,run_GFS_HYCOM]
if: ${{ always() && github.event.inputs.do_post == 'true' }}
uses: ./.github/workflows/combine_output.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
EXTENTS: ${{ github.event.inputs.extents }}