Repository navigation
Expand file tree
/
Copy pathinstall
More file actions
executable file
·158 lines (132 loc) · 6.47 KB
/
Copy pathinstall
File metadata and controls
executable file
·158 lines (132 loc) · 6.47 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# This script is shamelessly extended from https://github.com/saalfeldlab/n5-utils, thanks @axtimwalde & co!
USERTHREADS="-1"
USERMEM="-1"
while [[ $# -gt 0 ]]; do
case $1 in
-t|--threads)
USERTHREADS="$2"
shift # past argument
shift # past value
;;
-m|--mem)
USERMEM="$2"
shift # past argument
shift # past value
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
esac
done
if [ $USERTHREADS == "-1" ]; then
echo "You did not define the number of threads for Java/Spark can use, will be set automatically. You could do it by e.g.: './install -t 8' for 8 threads."
fi
if [ $USERMEM == "-1" ]; then
echo "You did not define the memory that Java/Spark can use, will be set automatically. You could do it by e.g.: './install -m 64' for 64GB of RAM."
fi
if [ $USERMEM == "-1" ]; then
# check for operating system
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Assuming on Linux operating system"
MEM=$(cat /proc/meminfo | grep MemTotal | sed s/^MemTotal:\\\s*\\\|\\\s\\+[^\\\s]*$//g)
MEMGB=$(($MEM/1024/1024))
MEM=$((($MEMGB/5)*4))
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Assuming on MacOS X operating system"
# sysctl returns total hardware memory size in bytes
MEM=$(sysctl hw.memsize | grep hw.memsize | sed s/hw.memsize://g)
MEMGB=$(($MEM/1024/1024/1024))
MEM=$((($MEMGB/5)*4))
else
echo "ERROR - Operating system (arg2) must be either linux or osx to determine max memory. Please specify max memory by e.g.: './install -m 64' for 64GB of RAM"
exit
fi
echo "Available memory:" $MEMGB "GB, setting Java memory limit to" $MEM "GB"
else
MEM=$USERMEM
echo "Setting Java memory limit to" $MEM "GB"
fi
if [ $USERTHREADS == "-1" ]; then
# check for operating system
if [[ "$OSTYPE" == "linux-gnu" ]]; then
if [ $USERMEM != "-1" ]; then
echo "Assuming on Linux operating system"
fi
THREADS=$(nproc --all)
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [ $USERMEM != "-1" ]; then
echo "Assuming on MacOS X operating system"
fi
# sysctl returns number of physical cores
THREADS=$(sysctl -n hw.ncpu)
else
echo "ERROR - Operating system (arg2) must be either linux or osx to determine number of physical cores. Please specify physical by e.g.: './install -t 8' to use 8 threads."
exit
fi
echo "Available threads:" $THREADS", setting Java/Sparks threads accordingly."
else
THREADS=$USERTHREADS
echo "Setting Java/Spark number of threads to" $THREADS
fi
# project version from the pom, so the shims keep pointing at the right jar after a release bump
VERSION=$(mvn -q -Denforcer.skip=true help:evaluate -Dexpression=project.version -DforceStdout)
echo "BigStitcher-Spark version: $VERSION"
INSTALL_DIR=$(pwd)
#INSTALL_DIR=${1:-$(pwd)}
echo ""
echo "Installing into $INSTALL_DIR (for local execution)"
echo 'Building the code'
# Requires Java 17 or 21 (Spark 4.0 dropped JDK 8/11). Set JAVA_HOME accordingly, e.g.:
# export JAVA_HOME=$(/usr/libexec/java_home -v 21) # macOS
sleep 2
mvn clean install
#echo 'Building a farjar, which can also be used for cluster/cloud execution'
#mvn clean install -P fatjar
# Spark is 'provided' for the cluster fatjar; the local shims need it on the classpath
mvn -Dspark.scope=compile -Dmdep.outputFile=cp.txt -Dmdep.includeScope=runtime dependency:build-classpath
# function that installs one command
# $1 - command name
# $2 - java class containing the functionality
install_command () {
echo "Installing '$1' command into" $INSTALL_DIR
echo '#!/bin/bash' > $1
echo '' >> $1
echo "JAR=\$HOME/.m2/repository/net/preibisch/BigStitcher-Spark/${VERSION}/BigStitcher-Spark-${VERSION}.jar" >> $1
echo 'java \' >> $1
echo " -Xmx${MEM}g -Dspark.master=local[${THREADS}] \\" >> $1
# echo ' -XX:+UseConcMarkSweepGC \' >> $1
# Spark 4.0 on Java 17/21 requires these JVM module-access flags (mirrors Spark's org.apache.spark.launcher.JavaModuleOptions)
echo ' -XX:+IgnoreUnrecognizedVMOptions \' >> $1
echo ' --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED \' >> $1
echo ' --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.cs=ALL-UNNAMED \' >> $1
echo ' --add-opens=java.base/sun.security.action=ALL-UNNAMED --add-opens=java.base/sun.util.calendar=ALL-UNNAMED --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED \' >> $1
echo ' -Djdk.reflect.useDirectMethodHandle=false -Dio.netty.tryReflectionSetAccessible=true \' >> $1
echo -n ' -cp $JAR:' >> $1
echo -n $(cat cp.txt) >> $1
echo ' \' >> $1
echo ' '$2' "$@"' >> $1
chmod a+x $1
}
echo 'Installing workflow tools ...'
install_command resave "net.preibisch.bigstitcher.spark.SparkResaveN5"
install_command detect-interestpoints "net.preibisch.bigstitcher.spark.SparkInterestPointDetection"
install_command match-interestpoints "net.preibisch.bigstitcher.spark.SparkGeometricDescriptorMatching"
install_command stitching "net.preibisch.bigstitcher.spark.SparkPairwiseStitching"
install_command solver "net.preibisch.bigstitcher.spark.Solver"
install_command match-intensities "net.preibisch.bigstitcher.spark.SparkIntensityMatching"
install_command solve-intensities "net.preibisch.bigstitcher.spark.IntensitySolver"
install_command create-fusion-container "net.preibisch.bigstitcher.spark.CreateFusionContainer"
install_command fusion "net.preibisch.bigstitcher.spark.SparkFusion"
install_command nonrigid-fusion "net.preibisch.bigstitcher.spark.SparkNonRigidFusion"
echo 'Installing utils ...'
install_command split-images "net.preibisch.bigstitcher.spark.SplitDatasets"
install_command filter-views "net.preibisch.bigstitcher.spark.Filter_Views"
install_command downsample "net.preibisch.bigstitcher.spark.SparkDownsample"
install_command clear-interestpoints "net.preibisch.bigstitcher.spark.ClearInterestPoints"
install_command clear-registrations "net.preibisch.bigstitcher.spark.ClearRegistrations"
install_command transform-points "net.preibisch.bigstitcher.spark.TransformPoints"
install_command overlay-landmarks "net.preibisch.bigstitcher.spark.OverlayLandmarks"
rm cp.txt
echo "Installation finished."