Skip to content

Commit daefa87

Browse files
c-dilksbaltzell
authored andcommitted
feat: optionally download fieldmaps from xrootd or cvmfs (#689)
* feat: optionally download fieldmaps from xrootd * fix: install xrootd client * fix: uri * test: build single-threaded * do not download maps on --clean * might as well support cvmfs too * fix: cleanup PR diff * fix: re-enable macOS in CI * feat: how to rm fieldmaps --------- Co-authored-by: Nathan Baltzell <baltzell@gmx.com>
1 parent ef1975e commit daefa87

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@ jobs:
4747
with:
4848
java-version: ${{ env.java_version }}
4949
distribution: ${{ env.java_distribution }}
50-
- uses: cvmfs-contrib/github-action-cvmfs@v5
50+
- name: install xrootd-client (linux)
51+
if: ${{ matrix.runner == 'ubuntu-latest' }}
52+
run: |
53+
sudo apt -y update
54+
sudo apt -y upgrade
55+
sudo apt -y install xrootd-client
56+
- name: install xrootd-client (macos)
57+
if: ${{ matrix.runner == 'macos-latest' }}
58+
run: brew install xrootd
59+
- name: setup cvmfs
60+
uses: cvmfs-contrib/github-action-cvmfs@v5
5161
with:
5262
cvmfs_repositories: 'oasis.opensciencegrid.org'
5363
- name: cvmfs
@@ -56,7 +66,7 @@ jobs:
5666
if: ${{ github.ref_type == 'tag' }}
5767
run: libexec/version-bump.sh ${{ github.ref_name }}
5868
- name: build
59-
run: ./build-coatjava.sh --no-progress -T${{ env.nthreads }}
69+
run: ./build-coatjava.sh --xrootd --no-progress -T${{ env.nthreads }}
6070
- name: tar # tarball to preserve permissions
6171
run: tar czvf coatjava.tar.gz coatjava
6272
- uses: actions/upload-artifact@v4
@@ -76,11 +86,16 @@ jobs:
7686
with:
7787
java-version: ${{ env.java_version }}
7888
distribution: ${{ env.java_distribution }}
89+
- name: install xrootd-client
90+
run: |
91+
sudo apt -y update
92+
sudo apt -y upgrade
93+
sudo apt -y install xrootd-client
7994
- uses: cvmfs-contrib/github-action-cvmfs@v5
8095
with:
8196
cvmfs_repositories: 'oasis.opensciencegrid.org'
8297
- name: unit tests and spotbugs
83-
run: ./build-coatjava.sh --spotbugs --unittests --no-progress -T${{ env.nthreads }}
98+
run: ./build-coatjava.sh --xrootd --spotbugs --unittests --no-progress -T${{ env.nthreads }}
8499
- name: collect jacoco report
85100
run: validation/jacoco-aggregate.sh
86101
- name: publish jacoco report

build-coatjava.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ usage='''build-coatjava.sh [OPTIONS]... [MAVEN_OPTIONS]...
1919
--quiet run more quietly
2020
--no-progress no download progress printouts
2121
22+
--xrootd use xrootd to download field maps
23+
--cvmfs use cvmfs to download field maps
24+
2225
--help show this message
2326
2427
MAVEN_OPTIONS
@@ -30,6 +33,8 @@ cleanBuild="no"
3033
runSpotBugs="no"
3134
downloadMaps="yes"
3235
runUnitTests="no"
36+
useXrootd=false
37+
useCvmfs=false
3338
mvnArgs=()
3439
wgetArgs=()
3540
for xx in $@
@@ -48,6 +53,8 @@ do
4853
mvnArgs+=(--no-transfer-progress)
4954
wgetArgs+=(--no-verbose)
5055
;;
56+
--xrootd) useXrootd=true ;;
57+
--cvmfs) useCvmfs=true ;;
5158
-h|--help)
5259
echo "$usage"
5360
exit 2
@@ -72,7 +79,13 @@ command_exists () {
7279
}
7380
download () {
7481
ret=0
75-
if command_exists wget ; then
82+
if $useXrootd; then
83+
xrdcp $1 ./
84+
ret=$?
85+
elif $useCvmfs; then
86+
cp $1 ./
87+
ret=$?
88+
elif command_exists wget ; then
7689
$wget $1
7790
ret=$?
7891
elif command_exists curl ; then
@@ -91,12 +104,14 @@ download () {
91104
# download the default field maps, as defined in libexec/env.sh:
92105
# (and duplicated in etc/services/reconstruction.yaml):
93106
source libexec/env.sh --no-classpath
94-
if [ $downloadMaps == "yes" ]; then
107+
magfield_dir=$src_dir/etc/data/magfield
108+
if [ $cleanBuild == "no" ] && [ $downloadMaps == "yes" ]; then
95109
echo 'Retrieving field maps ...'
96110
webDir=https://clasweb.jlab.org/clas12offline/magfield
97-
locDir=etc/data/magfield
98-
mkdir -p $locDir
99-
cd $locDir
111+
if $useXrootd; then webDir=xroot://sci-xrootd.jlab.org//osgpool/hallb/clas12/coatjava/magfield; fi
112+
if $useCvmfs; then webDir=/cvmfs/oasis.opensciencegrid.org/jlab/hallb/clas12/sw/noarch/data/magfield; fi
113+
mkdir -p $magfield_dir
114+
cd $magfield_dir
100115
for map in $COAT_MAGFIELD_SOLENOIDMAP $COAT_MAGFIELD_TORUSMAP $COAT_MAGFIELD_TORUSSECONDARYMAP
101116
do
102117
download $webDir/$map
@@ -119,8 +134,11 @@ if [ $cleanBuild == "yes" ]; then
119134
for target_dir in $(find $src_dir -type d -name target); do
120135
echo "WARNING: target directory '$target_dir' was not removed! JAR files within may be accidentally installed!" >&2
121136
done
122-
echo '''DONE CLEANING.
123-
Now re-run without `--clean` to build.'''
137+
echo """DONE CLEANING.
138+
NOTE: if you want to remove locally downloaded magnetic field maps, run:
139+
rm $magfield_dir/*.dat
140+
141+
Now re-run without \`--clean\` to build."""
124142
exit
125143
fi
126144

0 commit comments

Comments
 (0)