-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathbidmat
executable file
·116 lines (108 loc) · 3.69 KB
/
bidmat
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
#!/bin/bash
# export JAVA_HOME="" # Set here if not set in environment
# set CUDA_HOME="" # set if desired, otherwise defaults to /usr/local/cuda
# note CUDA_PATH="" # Should be set to the latest toolkit in Windows
# Change these if needed
MEMSIZE="-Xmx14G"
BIDMAT_ROOT="${BASH_SOURCE[0]}"
if [ ! `uname` = "Darwin" ]; then
BIDMAT_ROOT=`readlink -f "${BIDMAT_ROOT}"`
else
while [ -L "${BIDMAT_ROOT}" ]; do
BIDMAT_ROOT=`readlink "${BIDMAT_ROOT}"`
done
fi
BIDMAT_ROOT=`dirname "$BIDMAT_ROOT"`
pushd "${BIDMAT_ROOT}" > /dev/null
BIDMAT_ROOT=`pwd -P`
BIDMAT_ROOT0="$( echo ${BIDMAT_ROOT} | sed 's+^/cygdrive/\(.\)+\1:+' )"
BIDMAT_ROOT="$( echo ${BIDMAT_ROOT0} | sed 's+^/mnt/\(.\)+\1:+' )"
LIBDIR=${BIDMAT_ROOT}/lib
LOGGING_CONF="${BIDMAT_ROOT}/conf/logging.conf"
if [ -e "${LOGGING_CONF}" ]; then
LOG_OPTS="-Djava.util.logging.config.file=${LOGGING_CONF}"
else
LOG_OPTS=""
fi
export JAVA_OPTS="${MEMSIZE} -Xms128M -Dfile.encoding=UTF-8 ${LOG_OPTS} ${JAVA_OPTS}" # Set as much memory as possible
BIDMAT_VERSION=`echo target/BIDMat-*.jar | sed 's/.*BIDMat-//' | sed 's/\.jar//'`
OSS=`uname -a`
if [ "$ARCH" = "" ]; then
ARCH=`arch`
fi
if [[ "$OSS" == Darwin* ]] ; then
if [[ "$OSS" == *x86_64 ]] ; then
ARCH="x86_64"
fi
OSS="apple"
JUPYTER_DIR="${HOME}/Library/Jupyter"
elif [[ "$OSS" == Linux* ]] ; then
WSL=`cat /proc/version | grep 'Microsoft'`
if [ ! "$WSL" = "" ]; then
OSS="WSL"
else
OSS="linux"
fi
JUPYTER_DIR="${HOME}/.local/share/jupyter"
elif [[ "$OSS" == CYGWIN* ]] ; then
if [[ "$OSS" == *WOW* ]] ; then
ARCH="x86_64"
fi
OSS="windows"
JUPYTER_DIR=`echo $APPDATA | sed 's_\\\\_/_g' | sed 's_^\([A-Z]\):_/cygdrive/\1_'`
JUPYTER_DIR="${JUPYTER_DIR}/jupyter"
else
echo "OS not supported" $OSS
exit 1
fi
if [ "$OSS" = "windows" ]; then
if [ ! "${JAVA_HOME}" = "" ]; then
JAVA_HOME=`${BIDMAT_ROOT}/shortpath.bat "${JAVA_HOME}"`
JAVA_HOME=`echo ${JAVA_HOME} | tr -d '\r'`
export JAVA_HOME=`echo ${JAVA_HOME} | sed 's_\\\\_/_g'`/bin
fi
fi
cd lib
BIDMAT_JARS=`echo *.jar`
BIDMAT_LIBS="${BIDMAT_ROOT}/target/BIDMat-${BIDMAT_VERSION}.jar"
for lib in ${BIDMAT_JARS}; do
BIDMAT_LIBS="${BIDMAT_LIBS};${LIBDIR}/${lib}"
done
popd > /dev/null
TOOL_LIBS="${JAVA_HOME}/lib/tools.jar"
ALL_LIBS="${TOOL_LIBS};${BIDMAT_LIBS}"
if [ "$OSS" = "windows" ]; then
if [ ! "${CUDA_PATH}" = "" ]; then
NEWPATH=`${BIDMAT_ROOT}/shortpath.bat "${CUDA_PATH}"`
NEWPATH=`echo $NEWPATH | sed 's_\\\\_/_g'`/bin
fi
elif [ ! "$OSS" = "WSL" ]; then
ALL_LIBS=`echo "${ALL_LIBS}" | sed 's/;/:/g'`
fi
if [ "$1" = "notebook" ]; then
shift 1
KERNEL_CMD="[\"java\", \"-Xms128M\", \"${MEMSIZE}\", \"-Dfile.encoding=UTF-8\", \"-cp\", \"${ALL_LIBS}\",
\"-Dcoursier.mainJar=jupyter.scala.JupyterScala\", \"jupyter.scala.JupyterScala\",
\"--id\", \"bidmat\", \"--name\", \"BIDMat\", \"--connection-file\", \"{connection_file}\"]"
KERNEL_JSON="{\"language\" : \"bidmat\", \"display_name\" : \"BIDMat\", \"argv\" : ${KERNEL_CMD} }"
mkdir -p "${JUPYTER_DIR}/kernels/bidmat"
echo "${KERNEL_JSON}" > ${JUPYTER_DIR}/kernels/bidmat/kernel.json
cp ${BIDMAT_ROOT}/logo-64x64.png ${JUPYTER_DIR}/kernels/bidmat
jupyter notebook --KernelManager.kernel_cmd=${KERNEL_CMD} $@
else
userargs=""
if [ "$2" != "" ]; then
userargs="-Duser.arg0=$2"
j=1;
for i in ${*:3}; do
userargs="$userargs -Duser.arg$j=$i"
j=$((j+1))
done
fi
runscript=""
if [ "$1" != "" ]; then
runscript="-I ${1}"
fi
${BIDMAT_ROOT0}/command/scala -Dscala.repl.maxprintstring=8000 ${userargs} -nobootcp -toolcp "${TOOL_LIBS}" \
-cp "${ALL_LIBS}" -Yrepl-sync -I ${LIBDIR}/bidmat_init.sc $runscript
fi