-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·113 lines (105 loc) · 4.18 KB
/
run_model.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
name: run the model
on:
workflow_call:
inputs:
MODEL_TYPE:
description: 'what kind of model are we running e.g. oil - a user defined input in run_ops.yml'
required: true
type: string
BRANCH_REF:
description: 'what branch are we on - defined dynamically in run_ops.yml'
required: true
type: string
CONFIG_NAME:
description: 'configuration name - defined dynamically in run_ops.yml'
required: true
type: string
RUN_DATE:
description: 'time of T0 of the croco workflow in format YYYYMMDD_HH - defined dynamically in run_ops.yml'
required: true
type: string
RUNNER_NAME:
description: 'specify the runner name to determine what server we are running on'
required: true
type: string
WIND:
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
DATE_DIR: /home/somisana/ops/${{ inputs.BRANCH_REF }}/${{ inputs.RUN_DATE }}
# path to the run directory, as seen inside the running docker container
RUN_DIR_DOCKER: /mnt/tmp/opendrift_${{ inputs.MODEL_TYPE }}/${{ inputs.CONFIG_NAME }}/${{ inputs.OGCM }}_${{ inputs.WIND }}
# path to the run directory, as seen inside the local server
RUN_DIR: /home/somisana/ops/${{ inputs.BRANCH_REF }}/${{ inputs.RUN_DATE }}/opendrift_${{ inputs.MODEL_TYPE }}/${{ inputs.CONFIG_NAME }}/${{ inputs.OGCM }}_${{ inputs.WIND }}
jobs:
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
uses: actions/checkout@main
with:
ref: ${{ inputs.BRANCH_REF }}
- name: create the directory
run: |
rm -rf ${{ env.RUN_DIR }}
mkdir -p ${{ env.RUN_DIR }}
- name: Copy config file to the local server to run the model
run: |
OGCM=${{ inputs.OGCM }}
WIND=${{ inputs.WIND }}
sed -e 's/OGCM/'$OGCM'/g' -e 's/WIND/'$WIND'/g' < configs/config_${{ github.event.inputs.model_type }}.py > ${{ env.RUN_DIR }}/config.py
- name: add permissions to the config file
run: |
chmod -R 774 ${{ env.RUN_DIR }}
continue-on-error: true
- name: run the model
run: |
# we're specifying --user root due to permission issues I wasn't clever enough to solve
docker run \
--rm \
--user root \
-v ${{ env.DATE_DIR }}:/mnt/tmp \
ghcr.io/saeon/somisana-opendrift_${{ inputs.BRANCH_REF }}:latest \
run_model \
--model_type ${{ inputs.MODEL_TYPE }} \
--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 }}