Skip to content
Snippets Groups Projects
Commit e11ad094 authored by Jiangtao Wang's avatar Jiangtao Wang
Browse files

allow to force enable venv on given paltform

parent 2ec80be9
No related branches found
No related tags found
No related merge requests found
......@@ -6,38 +6,53 @@ SOURCE_PATH="${BASH_SOURCE[0]:-${(%):-%x}}"
RELATIVE_PATH="$(dirname "$SOURCE_PATH")"
ABSOLUTE_PATH="$(realpath "${RELATIVE_PATH}")"
####################################
###===================
### User Configuration
YOUR_ENV_NAME="venv"
suffix=""
# Check if SLURM_JOB_PARTITION is set
if [ -n "$SLURM_JOB_PARTITION" ]; then
# Check if SLURM_JOB_PARTITION is 'dc-wai'
if [ "$SLURM_JOB_PARTITION" = "dc-wai" ]; then
suffix="_wai"
fi
if [ "$SLURM_JOB_PARTITION" = "dc-gh" ]; then
suffix="_gh"
fi
if [ "$SLURM_JOB_PARTITION" = "dc-hwai" ]; then
# From 16.Oct.2024, the dc-wai partiion will be renamed to dc-hwai, to adapt the users who
# already has *_wai venv folder, we need to point the suffix to `wai`
# Check if the original '_wai' environment exists
case "$SLURM_JOB_PARTITION" in
"dc-wai") suffix="_wai" ;;
"dc-gh") suffix="_gh" ;;
"dc-hwai")
# If old "_wai" environment exists, keep the suffix as "_wai", otherwise use "_hwai"
if [ -d "${ABSOLUTE_PATH}/${YOUR_ENV_NAME}_${SYSTEMNAME}_wai" ]; then
suffix="_wai"
else
suffix="_hwai"
fi
;;
esac
fi
YOUR_ENV_NAME="${YOUR_ENV_NAME}_$SYSTEMNAME$suffix"
#==================
# overwrite $YOUR_ENV_NAME if we want to force acitvate an enviroment
declare -A FORCE_MAP=(
[force_booster]="juwelsbooster"
[force_juwels]="juwels"
[force_jurecadc]="jurecadc"
[force_hwai]="hwai"
[force_jedi]="jedi"
)
for key in "${!FORCE_MAP[@]}"; do
declare "$key=false"
done
# Parse arguments dynamically
for ARG in "$@"; do
VAR_NAME="${ARG#--}" # Remove "--" prefix
if [[ -n "${FORCE_MAP[$VAR_NAME]}" ]]; then
declare "$VAR_NAME=true"
YOUR_ENV_NAME="${YOUR_ENV_NAME}_${FORCE_MAP[$VAR_NAME]}" # Set environment name immediately
break # Stop checking after the first match
fi
done
YOUR_ENV_NAME="${YOUR_ENV_NAME}_$SYSTEMNAME$suffix"
export ENV_NAME="$(basename "$ABSOLUTE_PATH")" # Default Name of the venv is the directory that contains this file
export ENV_DIR="${ABSOLUTE_PATH}/${YOUR_ENV_NAME}" # Default location of this VENV is "./venv"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment