forked from CFD-GO/TCLB_docker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
activate.template
169 lines (140 loc) · 6.02 KB
/
activate.template
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
case $1 in
"workspace_cpu" | "buildkit_cpu" | "buildkit_gpu" | "buildkit_graphics_gpu")
echo "Activating $1 TCLB Environment"
WD=$(pwd)
echo $WD
cd $ENVDIR
if make $1;
then
. .local/config_all
. .local/config_$1
export PYTHONPATH="$PYTHONPATH:$TCLB_TOOLS_PATH/Python"
if [[ $1 == *"_gpu"* ]]; then
SHELLCMD="singularity exec --nv $SIF "
else
SHELLCMD="singularity exec $SIF "
fi
if [[ "$1" == "workspace_cpu" ]];
then
function jupyterlab() {
. $ENVDIR/workSpace/bash_shortcuts.sh
exec $SHELLCMD jupyter-lab --port=8888 --no-browser --allow-root
deactivate
}
fi
function scmd {
eval $SHELLCMD $@
}
function tclbmake {
MYPATH=$(pwd)
echo "TCLB_PATH: " $TCLB_PATH
eval cd $TCLB_PATH
eval scmd make $@
eval cd $MYPATH
}
function tclb() {
scmd $TCLB_PATH/CLB/$1/main $2
}
# function tclbmpi() { automade version is OPENMP-based, this does not work
# scmd mpirun $TCLB_PATH/CLB/$1/main $2
# }
function R() {
scmd R "$0"
}
function tclb_help() {
echo ""
echo "scmd COMMAND - run COMMAND inside TCLB singularity environment"
echo "tclb MODEL FILE ARGS - run CLB/MODEL/main FILE ARGS inside TCLB singularity environment"
#echo "tclbmpi MODEL FILE ARGS - run mpirun CLB/MODEL/main FILE ARGS inside TCLB singularity environment"
echo "R ARGS - run R inside TCLB singularity environment"
echo "tclbmake ARGS - run make ARGS inside singularity environment in TCLB path (current path is ignored)"
echo "deactivate - clear environment"
echo "tclb_help - print this message"
}
# Begin of Environment script, after Python VENV/bin/activate
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly
deactivate () {
# # reset old environment variables
# if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
# PATH="${_OLD_VIRTUAL_PATH:-}"
# export PATH
# unset _OLD_VIRTUAL_PATH
# fi
# if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
# PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
# export PYTHONHOME
# unset _OLD_VIRTUAL_PYTHONHOME
# fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
PS1="${_OLD_VIRTUAL_PS1:-}"
export PS1
unset _OLD_VIRTUAL_PS1
fi
#unset VIRTUAL_ENV
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
# unset -f tclb_setup
unset -f scmd
unset -f tclbmake
unset -f tclb
unset -f tclb_help
#unset -f tclbmpi
unset -f R
fi
}
# unset irrelevant variables
deactivate nondestructive
export -f deactivate
#export -f tclb_setup
export -f scmd
export -f tclbmake
export -f tclb
export -f tclb_help
#export -f tclbmpi
export -f R
#VIRTUAL_ENV="/home/mdzik/icm/coldfront-icm/venv/"
#export VIRTUAL_ENV
#_OLD_VIRTUAL_PATH="$PATH"
#PATH="$VIRTUAL_ENV/bin:$PATH"
#export PATH
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
#if [ -n "${PYTHONHOME:-}" ] ; then
# _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
# unset PYTHONHOME
#fi
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="(TCLB:$TCLB_ENV) ${PS1:-}"
export PS1
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r 2> /dev/null
fi
echo "======================================================================="
echo "Remember to put path to TCLB source code into .local/config_all file!!!"
echo "======================================================================="
if [[ "$1" == "workspace_cpu" ]];
then
echo "======================================================================"
echo "This is WorkSpace edition: jupyterlab command is available"
echo "--> jupyter-lab is your OS version"
echo "======================================================================"
fi
tclb_help
cd $WD
fi
;;
*)
echo "Options: workspace_cpu, buildkit_cpu, buildkit_gpu, buildkit_graphics_gpu"
esac