annotate manual_test.sh @ 0:426b0f85a311 draft

" master branch Updating"
author lain
date Tue, 19 Jul 2022 07:36:57 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
1 #!/bin/bash
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
2
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
3
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
4
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
5 ## **@AUTHOR**: Lain Pavot - lain.pavot@inrae.fr
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
6 ## **@DATE**: 22/06/2022
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
7
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
8
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
9 envs_directory=$(pwd)
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
10 envs_directory=/tmp/history_metadata_extractor-envs
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
11 mkdir -p ${envs_directory}
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
12
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
13 VENV=${envs_directory}/.manual-venv
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
14 CENV=${envs_directory}/.manual-conda
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
15
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
16 MAMBA_SOLVER=
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
17 ## comment to deactivate mamba solver
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
18 MAMBA_SOLVER="--experimental-solver libmamba"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
19
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
20 ENV_NAME=history_metadata_extractor
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
21 XML_PATH=./history_metadata_extractor.xml
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
22 SCRIPT_NAME=history_metadata_extractor.py
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
23 output_name=out.html
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
24 options=" \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
25 -d ./test-data/datasets_attrs.txt \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
26 -j ./test-data/jobs_attrs.txt \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
27 -o ./${output_name} \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
28 "
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
29 expected_result=test-data/out.html
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
30 runner=python3.10
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
31 dependencies=python=3.10.5
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
32 miniconda_version=py37_4.12.0-Linux-x86_64
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
33
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
34
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
35
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
36 if [ ! -e "${VENV}" ];then
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
37 echo "virtualenv not created yet, creating..."
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
38 python3 -m virtualenv "${VENV}"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
39 echo "venv created"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
40 else
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
41 echo "virtualenv already exist: ok"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
42 fi
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
43 . ${VENV}/bin/activate
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
44
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
45 if [ ! -e "${CENV}" ];then
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
46 echo "conda env not created yet, creating..."
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
47 if [ ! -e ./install_conda.sh ];then
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
48 wget \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
49 -O install_conda.sh \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
50 https://repo.anaconda.com/miniconda/Miniconda3-${miniconda_version}.sh \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
51 ;
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
52 fi
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
53 bash ./install_conda.sh -b -p "${CENV}"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
54
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
55 ${CENV}/bin/conda install -y -n base conda-libmamba-solver
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
56 ${CENV}/bin/conda create \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
57 -y \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
58 --quiet \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
59 --override-channels \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
60 --channel conda-forge \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
61 --channel bioconda \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
62 --channel defaults \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
63 --name "${ENV_NAME}" \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
64 ${MAMBA_SOLVER} \
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
65 ${dependencies}
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
66 echo "conda env created"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
67 fi
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
68
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
69 echo ""
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
70 echo "===== preparing ====="
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
71
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
72 oldwd=$(pwd)
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
73 tmp=$(mktemp -d)
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
74 echo "Working in ${tmp}"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
75 files=$(find . -maxdepth 1 -regex "./.+")
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
76 cd "${tmp}"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
77 echo "creating links..."
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
78 echo "${files}" | xargs -I file ln -s "${oldwd}"/file file
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
79 echo "ready to work"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
80
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
81 echo ""
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
82 echo "===== processing ====="
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
83
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
84 . "${CENV}/bin/activate" "${CENV}/envs/${ENV_NAME}" ;
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
85
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
86 ${runner} ./${SCRIPT_NAME} ${options};
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
87
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
88 echo ""
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
89 echo "Error code: ${?}" ;
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
90
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
91 lines=$(diff "${output_name}" "${expected_result}" 2>&1)
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
92
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
93 echo ""
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
94 echo "===== results ====="
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
95
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
96 if [ "${lines}" = "" ];then
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
97 echo "Result equal to expected."
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
98 else
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
99 echo "Some lines are different:"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
100 echo "${lines}"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
101 fi
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
102
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
103 echo ""
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
104 echo "===== cleaning ====="
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
105
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
106 echo "Removing ${tmp}..."
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
107 rm -rf "${tmp}"
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
108
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
109 echo ""
426b0f85a311 " master branch Updating"
lain
parents:
diff changeset
110 echo "Done."