Skip to content

Commit f0168ae

Browse files
committed
introduce verbosity environment variable
1 parent fd439d5 commit f0168ae

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

juhpc

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# - optionally executing a site-specific post installation julia script, using the project where preferences were set (e.g, to modify preferences or to create an uenv view equivalent to the activation script).
99

1010

11-
# Define info, error, cleanup and check functions
11+
# Define info, error, cleanup, check functions and julia call for setting preferences
1212

1313
export JUHPC="\e[1;34m[\e[0m \e[1;35mJ\e[0m\e[1;32mU\e[0m\e[1;31mH\e[0m\e[1;31mP\e[0m\e[1;31mC\e[0m\e[1;34m:\e[0m"
1414

@@ -28,7 +28,11 @@ print_logo() {
2828

2929
info() {
3030
local message="$1"
31-
echo -e "$JUHPC $message" >&2
31+
local verbosity="${2:-0}" # Default to 0 if not provided
32+
if [[ "$JUHPC_VERBOSE" -ge "$verbosity" ]]; then
33+
echo -e "$JUHPC $message" >&2
34+
fi
35+
echo -e "$JUHPC $message" >> "$TMP_JULIAUP_LOG"
3236
}
3337

3438
cleanup() {
@@ -61,7 +65,11 @@ check_dir() {
6165

6266
julia_pref() {
6367
local cmd="$1"
64-
julia --project="$JULIA_PREFDIR" -e "$cmd" >> "$TMP_JULIAUP_LOG" 2>&1
68+
if [[ "$JUHPC_VERBOSE" -gt 1 ]]; then
69+
julia --project="$JULIA_PREFDIR" -e "$cmd" 2>&1 | tee -a "$TMP_JULIAUP_LOG"
70+
else
71+
julia --project="$JULIA_PREFDIR" -e "$cmd" >> "$TMP_JULIAUP_LOG" 2>&1
72+
fi
6573
}
6674

6775

@@ -72,6 +80,15 @@ export JULIAUP_INSTALLDIR="$2"
7280
export JUHPC_POST_INSTALL_JL="$3"
7381

7482

83+
# Check/set environment variable defining verbosity of output
84+
85+
if [[ -z "$JUHPC_VERBOSE" ]]; then
86+
export JUHPC_VERBOSE=0
87+
elif ! [[ "$JUHPC_VERBOSE" =~ ^[0-2]$ ]]; then
88+
error "JUHPC_VERBOSE must be between 0 and 2."
89+
fi
90+
91+
7592
# Set (derived) general environment variables
7693

7794
export JULIAUP_BINDIR="$JULIAUP_INSTALLDIR/bin" # juliaup and julia binaries
@@ -173,6 +190,8 @@ fi
173190

174191
if [ ! -s "$JULIA_PREFS" ]; then error "preferences file is missing or empty."; fi
175192

193+
info "Preferences:\n$(cat "$JULIA_PREFS")" 1
194+
176195
info "... done: preferences created."
177196

178197

@@ -223,7 +242,7 @@ fi
223242
if [ ! -s "$JULIAUP_WRAPPER" ]; then error "Juliaup wrapper is missing or empty."; fi
224243
chmod +x "$JULIAUP_WRAPPER"
225244

226-
info "... done."
245+
info "... done: wrapper created."
227246

228247

229248
# Create an activation script that sets environment variables for juliaup, julia and HPC key packages
@@ -266,7 +285,9 @@ $(haskey(ENV,"JUHPC_ADIOS2_HOME") && ENV["JUHPC_ADIOS2_HOME"] != "" ? """
266285

267286
if [ ! -s "$ACTIVATE_SCRIPT" ]; then error "Activate script is missing or empty."; fi
268287

269-
info "... done."
288+
info "Environment variables:\n$(grep '^export ' "$ACTIVATE_SCRIPT")" 1
289+
290+
info "... done: activate script created."
270291

271292

272293
# Optionally execute a site-specific post installation julia script (if passed a third argument)

0 commit comments

Comments
 (0)