#!/bin/bash
#SBATCH --ntasks 1
#SBATCH --time 02:00:00
#SBATCH --job-name NES-tutorial
#SBATCH --output log_NES-tutorial-%J.out
#SBATCH --error log_NES-tutorial-%J.err
#SBATCH --exclusive
#SBATCH --qos debug

# get tunneling info
XDG_RUNTIME_DIR=""
port=$(shuf -i8000-9999 -n1)
node=$(hostname -s)
user=$(whoami)

# print tunneling instructions jupyter-log
echo -e "

MacOS or linux terminal command to create your ssh tunnel
ssh -N -L ${port}:${node}:${port} ${user}@nord4.bsc.es

Use a Browser on your local machine to go to:
localhost:${port}  (prefix w/ https:// if using password)
"

# load modules or conda environments here
module load jupyterlab/3.0.9-foss-2019b-Python-3.7.4
# module load NES/1.1.3-nord3-v2-foss-2019b-Python-3.7.4

source /gpfs/projects/bsc32/software/suselinux/11/software/Miniconda3/4.7.10/etc/profile.d/conda.sh
conda deactivate
conda activate /gpfs/projects/bsc32/repository/apps/conda_envs/NES_dev
export PYTHONPATH=/gpfs/projects/bsc32/repository/apps/conda_envs/NES_dev/lib/python3.12/site-packages
export SLURM_CPU_BIND=none
export PYTHONPATH=/gpfs/scratch/bsc32/bsc032538/AC_PostProcess/NES:$PYTHONPATH


# DON'T USE ADDRESS BELOW.
# DO USE TOKEN BELOW
jupyter-lab --no-browser --port=${port} --ip=${node}
