-
Notifications
You must be signed in to change notification settings - Fork 19
/
.travis.yml
244 lines (231 loc) · 9.5 KB
/
.travis.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
language: generic
os:
- linux
virtualenv:
system_site_packages: true
#python:
# - "3.6"
# - "2.7"
env:
- TOOL=xspec
# - TOOL=xspec-docker
# - TOOL=sherpa
- TOOL=sherpa-conda
cache:
directories:
- $HOME/Downloads/sherpa
- $HOME/Downloads/sherpa-conda
- $HOME/Downloads/xspec
- $HOME/Downloads/models
- $HOME/Downloads/ciao-install
before_cache:
- rm -f $HOME/Downloads/sherpa/ciao-install-*
- rm -rf $HOME/Downloads/xspec/heasoft*/
- rm -rf $HOME/Downloads/sherpa-conda/miniconda/envs
install:
- sudo apt-get install -y python3-numpy python-numpy python3-dev python-tk python3-pip python3-setuptools ghostscript
- sudo pip3 install --upgrade pip==20.3.4
# allow convert to read PDF files:
- sudo sed -i '/PDF/s/none/read|write/' /etc/ImageMagick-6/policy.xml
- which python || true
- which python3 || true
- export MYCACHE=$HOME/Downloads/$TOOL
- mkdir -p $MYCACHE
- STARTTIME=$(date +%s)
- pushd $MYCACHE
- |
if [[ "$TOOL" == "sherpa-conda" ]]; then
if ! conda activate ciaoenv; then
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
CONDADIR=$MYCACHE/miniconda;
rm -rf $CONDADIR/envs;
bash miniconda.sh -b -p $CONDADIR;
source "$CONDADIR/etc/profile.d/conda.sh";
hash -r;
conda config --set always_yes yes --set changeps1 no;
conda update -q conda;
conda info -a;
conda create -n ciaoenv -c https://cxc.cfa.harvard.edu/conda/ciao ciao sherpa;
conda activate ciaoenv;
conda install -c conda-forge ultranest coverage coveralls scipy matplotlib h5py astropy requests cython tqdm;
fi
fi
################ CIAO/Sherpa #####################
- |
if [[ "$TOOL" == "sherpa" ]]; then
echo "getting latest ciao installer url";
CIAO_INSTALL_URL=$(wget -q -O - https://cxc.cfa.harvard.edu/ciao/download/ciao_install.html|grep -o '[^"]*_install.cgi?standard=true');
echo "it is at: $CIAO_INSTALL_URL";
fi
- |
if [[ "$TOOL" == "sherpa" ]]; then
echo "getting latest ciao installer";
wget -O ./ciao-install https://cxc.cfa.harvard.edu/$CIAO_INSTALL_URL;
fi
- |
if [[ "$TOOL" == "sherpa" ]]; then
if ! ls -d $HOME/Downloads/ciao-install/ciao-*/bin/ciao_setup.sh; then
echo "running ciao installer";
echo $MYCACHE > ciao-installer-input;
rm -rf $HOME/Downloads/ciao-install/;
mkdir -vp $HOME/Downloads/ciao-install;
echo $HOME/Downloads/ciao-install >> ciao-installer-input;
echo n >> ciao-installer-input;
echo n >> ciao-installer-input;
echo n >> ciao-installer-input;
echo n >> ciao-installer-input;
echo n >> ciao-installer-input;
cat ciao-installer-input;
bash ciao-install < ciao-installer-input;
fi
ls $HOME/Downloads/ciao-install/;
CIAO_INSTALL_DIR=`ls -d $HOME/Downloads/ciao-install/ciao-*/`;
echo "install dir is: $CIAO_INSTALL_DIR";
fi
- |
if [[ "$TOOL" == "sherpa" ]]; then
echo "loading ciao";
source $CIAO_INSTALL_DIR/bin/ciao.sh;
source $CIAO_INSTALL_DIR/bin/ciao_setup.sh;
fi
################ HEASOFT/Xspec #####################
- |
if [[ "$TOOL" == "xspec" ]]; then
echo "getting latest heasoft bundle";
#tar -tzf heasoft.tar.gz >/dev/null || wget -O heasoft.tar.gz 'https://heasarc.gsfc.nasa.gov/cgi-bin/Tools/tarit/tarit.pl?mode=download&src_other_specify=&arch=ubuntu_2004&general=heasptools&general=heagen&xanadu=xspec' --header 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0' --header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' --header 'Accept-Language: en-US' --header 'DNT: 1' --header 'Connection: keep-alive' --header 'Referer: https://heasarc.gsfc.nasa.gov/lheasoft/download.html' --header 'Upgrade-Insecure-Requests: 1' --header 'Sec-GPC: 1' --progress=dot:giga
if tar -tzf heasoft-src.tar.gz >/dev/null
then
DID_DOWNLOAD=0;
else
wget -O heasoft-src.tar.gz 'https://heasarc.gsfc.nasa.gov/cgi-bin/Tools/tarit/tarit.pl?mode=download&arch=src&src_pc_linux_ubuntu=Y&src_other_specify=&general=heasptools&general=heagen&xanadu=xspec' --header 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0' --header 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' --header 'Accept-Language: en-US' --header 'DNT: 1' --header 'Connection: keep-alive' --header 'Referer: https://heasarc.gsfc.nasa.gov/lheasoft/download.html' --header 'Upgrade-Insecure-Requests: 1' --header 'Sec-GPC: 1' --progress=dot:giga
DID_DOWNLOAD=1;
fi
fi
- |
if [[ "$TOOL" == "xspec" ]] && [[ $DID_DOWNLOAD == "0" ]]; then
echo "unpacking heasoft";
if ! ls -d $MYCACHE/xspec-install/x86_64-pc-linux-gnu-libc*/; then
rm -rf heasoft*/;
tar -xzf heasoft-src.tar.gz;
ls heasoft*;
ls;
echo "compiling xspec";
sudo apt-get install -y gfortran build-essential cmake liblapack3 liblapack-dev libatlas3-base libatlas-base-dev libblas3 libblas-dev libreadline-dev;
ls heasoft*;
XSPEC_BUILD_DIR=`ls -d heasoft-*/BUILD_DIR`;
#XSPEC_BUILD_DIR=`ls -d heasoft-*/x86_64-pc-linux-gnu-libc*/BUILD_DIR`;
pushd $XSPEC_BUILD_DIR;
mkdir -p $MYCACHE/xspec-install/;
./configure --prefix=$MYCACHE/xspec-install/ --with-components="Xspec" && make && make install | grep -v hd_install;
ls $MYCACHE/xspec-install/x86_64-pc-linux-gnu-libc*/;
#./configure;
#export HEADAS=`ls -d $MYCACHE/heasoft-*/x86_64-pc-linux-gnu-libc*/`;
popd;
fi
fi
- |
if [[ "$TOOL" == "xspec" ]] && [[ $DID_DOWNLOAD == "0" ]]; then
export HEADAS=`ls -d $MYCACHE/xspec-install/x86_64-pc-linux-gnu-libc*/`;
ls $HEADAS;
echo "loading xspec from " $HEADAS;
source ${HEADAS}/headas-init.sh;
echo "PYTHONPATH: $PYTHONPATH";
echo "PATH: $PATH";
python -c 'import xspec' || true;
fi
- popd
################ Spectral Models #####################
- |
if [[ "$TOOL" != "sherpa-conda" ]]; then
sudo pip3 install requests "corner<2.2" astropy h5py cython coveralls coverage scipy tqdm;
sudo pip3 install ultranest;
fi
- which coveralls
- ENDTIME=$(date +%s)
- echo "setup took $((ENDTIME - STARTTIME))s"
- mkdir -p $HOME/Downloads/models
- pushd $HOME/Downloads/models
- |
if [[ $((ENDTIME - STARTTIME)) -lt 1200 ]]
then
wget -q -nc https://zenodo.org/record/1169181/files/uxclumpy-cutoff.fits https://zenodo.org/record/1169181/files/uxclumpy-cutoff-omni.fits;
export MODELDIR=$PWD;
else
echo "skipping model download, setup was slow";
fi
- popd
script:
# testing scripts
- cp .coveragerc docker/testsrc
- cp .coveragerc examples/sherpa
- cp .coveragerc examples/xspec
- pushd docker/testsrc
- 'echo "backend: Agg" > matplotlibrc'
- ls
- rm *.nh
- coverage run -p ../../fixkeywords.py combined_src.pi combined_bkg.pi combined_src.rmf combined_src.arf
- coverage run -p ../../gal.py combined_src.pi
- ls combined_src.pi.nh
- if [[ "$TOOL" == "xspec" ]]; then coverage run -p ../../autobackgroundmodel/fitbkg.py combined_bkg.pi combined_src.pi || exit 1; fi
- if [[ "$TOOL" == "xspec" ]]; then coverage run -p ../../autobackgroundmodel/fitbkg.py combined_bkg.pi || exit 1; fi
- if [[ "$TOOL" == "xspec" ]]; then coverage run -p ../../autobackgroundmodel/fitbkg.py || true; fi
- if [[ "$TOOL" == "xspec" ]]; then coverage run -p ../../gal.py || true; fi
- if [[ "$TOOL" == "xspec" ]]; then coverage run -p ../../fixkeywords.py || true; fi
- git checkout .
- popd
# testing xspec examples
- |
if [[ "$TOOL" == "xspec" ]] && [[ $DID_DOWNLOAD == "0" ]]; then
pushd examples/xspec;
if [[ $((ENDTIME - STARTTIME)) -lt 1200 ]]
then
PYTHONPATH=../../:$PYTHONPATH bash -v runall.sh || exit 1;
ls;
else
echo "skipping tests, setup was slow";
fi
popd;
fi
# testing sherpa examples
- |
if [[ "$TOOL" == "sherpa" ]] || [[ "$TOOL" == "sherpa-conda" ]]; then
pushd examples/sherpa;
# install interpolation code first
ls -d /usr/local/lib/python*;
sudo ln -s /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy /usr/include/numpy;
ls /usr/include/numpy/;
git clone https://github.com/JohannesBuchner/npyinterp.git;
pushd npyinterp; make; popd;
# run examples
if [[ $((ENDTIME - STARTTIME)) -lt 1200 ]]
then
PYTHONPATH=../../:${PYTHONPATH}:npyinterp/ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:npyinterp/ bash -v runall.sh || exit 1;
ls;
else
echo "skipping tests, setup was slow";
fi
popd;
fi
- |
if [[ "$TOOL" == "sherpa" ]] || [[ "$TOOL" == "sherpa-conda" ]]; then
pushd docker/testsrc;
if [[ $((ENDTIME - STARTTIME)) -lt 1200 ]]
then
PYTHONPATH=../../:$PYTHONPATH WITHAPEC=0 coverage run -p ../../examples/sherpa/xagnfitter.py || exit 1;
ls;
else
echo "skipping tests, setup was slow";
fi
popd;
fi
# upload coverage results
- python3 setup.py install --user
- wc -l examples/sherpa/.cover* examples/xspec/.cover* docker/testsrc/.cover* .cover* || true
- coverage combine examples/sherpa examples/xspec docker/testsrc .
- coverage report || true
after_success:
- |
if [[ "$TOOL" == "sherpa-conda" ]]; then
conda activate ciaoenv;
fi
- coveralls