-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall-checker-suite.sh
95 lines (75 loc) · 3.01 KB
/
install-checker-suite.sh
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
#!/bin/bash
# Installs checker with everything required to run.
#
# Usage:
# ------
#
# ./install-checker-suite.sh <base_directory>
#
CHECKS_BASE_DIR=${1:-${PWD}/checks-work-dir}
CHECKS_BASE_DIR=$(realpath $CHECKS_BASE_DIR)
ENV_NAME=amf-checks-env
pdir=$(dirname $CHECKS_BASE_DIR)
if [ ! -d "$pdir" ]; then
echo "[ERROR] Parent directory of base directory must exist: $pdir"
exit
fi
echo "[INFO] Making/checking base directory: $CHECKS_BASE_DIR"
mkdir -p $CHECKS_BASE_DIR
echo "[INFO] Installing miniconda and python..."
cd $CHECKS_BASE_DIR/
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh -p ${CHECKS_BASE_DIR}/miniconda3 -b
rm -f Miniconda3-latest-Linux-x86_64.sh
export PATH=$PATH:${CHECKS_BASE_DIR}/miniconda3/bin
echo "[INFO] Creating environment: $ENV_NAME"
conda create --name $ENV_NAME python=3.9 -y
source activate $ENV_NAME
echo "[INFO] Install the third-party compliance-checker framework..."
conda install -c conda-forge compliance-checker pip -y
echo "[INFO] Install and/or clone the relevant repositories..."
pip install git+https://github.com/cedadev/compliance-check-lib
pip install git+https://github.com/cedadev/cc-yaml
pip install git+https://github.com/ncasuk/amf-check-writer
CV_VERSIONS=2.0.0
PACKAGES="AMF_CVs amf-compliance-checks"
for pkg in $PACKAGES; do
zfile=v${CV_VERSIONS}.zip
wget https://github.com/ncasuk/${pkg}/archive/refs/tags/${zfile}
unzip $zfile
rm -f $zfile
done
echo "[INFO] Define PYESSV_ARCHIVE_HOME directory..."
for dir_candidate in pyessv-vocabs amf-pyessv-vocabs ; do
PYESSV_ARCHIVE_HOME=$CHECKS_BASE_DIR/AMF_CVs-${CV_VERSIONS}/${dir_candidate}
if [ -d $CHECKS_DIR ]; then
break
fi
done
echo "[INFO] Define CHECKS_DIR directory..."
for dir_candidate in checks amf-checks ; do
CHECKS_DIR=$CHECKS_BASE_DIR/amf-compliance-checks-${CV_VERSIONS}/${dir_candidate}
if [ -d $CHECKS_DIR ]; then
break
fi
done
echo "[INFO] Create setup file..."
setup_file=${CHECKS_BASE_DIR}/setup-checks-env.sh
echo "export CHECKS_BASE_DIR=$CHECKS_BASE_DIR" >> $setup_file
echo "export PATH=\$PATH:\${CHECKS_BASE_DIR}/miniconda3/bin" >> $setup_file
echo " " >> $setup_file
echo "source activate amf-checks-env" >> $setup_file
echo "export PYESSV_ARCHIVE_HOME=$PYESSV_ARCHIVE_HOME" >> $setup_file
echo "export CHECKS_DIR=$CHECKS_DIR" >> $setup_file
echo "export VERSION=v2.0" >> $setup_file
echo "[INFO] To setup environment, do:"
echo "source $setup_file"
echo "[INFO] Installation complete..."
echo "[INFO] You can test it with:"
echo "source $setup_file"
echo "TEST_FILE_NAME=ncas-anemometer-1_ral_29001225_mean-winds_v0.1.nc"
echo 'TEST_FILE_URL="https://github.com/cedadev/compliance-check-lib/blob/main/tests/example_data/nc_file_checks_data/${TEST_FILE_NAME}?raw=true"'
echo "wget -O \$TEST_FILE_NAME \$TEST_FILE_URL"
echo "amf-checker --yaml-dir \$CHECKS_DIR --version \$VERSION \$TEST_FILE_NAME"
echo "[INFO] Or more generally:"
echo "amf-checker --yaml-dir $CHECKS_DIR --version <version> <test_file>"