-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathrunscript.sh
More file actions
executable file
·136 lines (106 loc) · 3.69 KB
/
runscript.sh
File metadata and controls
executable file
·136 lines (106 loc) · 3.69 KB
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
#!/bin/bash
# stops script if a command fails
# set -e
## TO-DO:
## - automate rebuilding container when there is an update in fre-cli
## - checks for the status of the workflow (before installation step)
# Initialize ppp-setup
# Set environment variables
export TMPDIR=/mnt/temp
export HOME=/mnt
#Not sure if needed
#export CYLC_CONF_PATH=/mnt
### WHAT IS NEEDED ON THE CLOUD VS NOT for conda set-up
# Initializations for conda environment in container
conda init --all
source /opt/conda/etc/profile.d/conda.sh
conda deactivate
conda activate /app/cylc-flow-tools
# update fre-cli env with specific branch development
cd fre-cli
pip install .
export PATH=/mnt/.local/bin:$PATH
cd -
get_user_input () {
echo Please Enter Experiment Name:
echo "Experiment name: test_pp"
echo Please Enter Platform:
echo "Platform: ptest"
echo Please Enter Target:
echo "Target: ttest"
echo Please Enter Path to model yaml file:
echo "Model yaml: ./for_gh_runner/yaml_workflow/model.yaml"
expname="test_pp"
plat="ptest"
targ="ttest"
yamlfile="./for_gh_runner/yaml_workflow/model.yaml"
name=${expname}__${plat}__${targ}
}
create_dirs () {
echo "Creating necessary paths used in workflow"
paths=("${HOME}/pp" "${HOME}/ptmp" "${HOME}/temp")
for p in ${paths[@]}; do
if [ -d $p ]; then
echo -e "Path $p previously created. Removing..."
rm -rf $p
echo -e " Creating new $p\n"
mkdir -p $p
else
mkdir -p $p
fi
done
}
check_exit_status () {
if [ $? -ne 0 ]; then
echo "$1 failed"
exit 1
fi
}
fre_pp_steps () {
set -x
echo "experiment cleaning, if it was previously installed"
if [ -d /mnt/cylc-run/${name} ]; then
echo -e "\n${name} previously installed"
echo " Removing ${name}..."
cylc clean ${name}
fi
## Checkout
echo -e "\nCreating $name directory in ${HOME}/cylc-src/${name} ..."
rm -rf /mnt/cylc-src/${name}
mkdir -p /mnt/cylc-src/${name}
echo -e "\nCopying fre-workflows directory in ${HOME}/cylc-src/${name} ..."
cp -r ./* /mnt/cylc-src/${name}
check_exit_status "MOCK CHECKOUT (cp)"
#Not sure if needed because if no global.cylc found, cylc uses default, which utilizes background jobs anyway ...
#export CYLC_CONF_PATH=/mnt/cylc-src/${name}/generic-global-config/
## Configure the rose-suite file for the workflow
echo -e "\nRunning fre pp configure-yaml, combining separate yaml configs into one, then writing rose-suite config file ..."
fre -vv pp configure-yaml -e ${expname} -p ${plat} -t ${targ} -y ${yamlfile}
check_exit_status "CONFIGURE-YAML"
## Validate the configuration files
echo -e "\nRunning fre pp validate, validating rose-suite config file ..."
fre -vv pp validate -e ${expname} -p ${plat} -t ${targ}
check_exit_status "VALIDATE"
# Install
echo -e "\nRunning fre pp install, installing workflow in ${HOME}/cylc-run/${name} ..."
fre -vv pp install -e ${expname} -p ${plat} -t ${targ}
check_exit_status "INSTALL"
## RUN
echo -e "\nRunning the workflow with cylc play ..."
cylc play --no-detach --debug -s 'STALL_TIMEOUT="PT0S"' ${name}
#check_exit_status "PLAY" # if cylc play fails and this is not commented, log uploading does not work
## SUMMARY
echo -e "\nWorkflow ended, final task states from workflow-state are ..."
cylc workflow-state -v ${name}
}
main () {
# Run set-up and fre-cli post-processing steps #
# Set user-input
get_user_input
#Create directories needed for post-processing
create_dirs
# Run the post-processing steps
fre_pp_steps
}
# Run main function
main