SINGULARITY_* variables are not visible in the R Session but only on the terminal
Closed this issue · 3 comments
After the recent changes in #12 it became apparent that while the SINGULARITY_* (and SLURM_*) variables are visible in the terminal within the RStudio session, they are not set in the R Console.
It turns out that at the time when the R Session starts and /etc/profile
is being executed, there is no information about RS_SESSION_URL available just yet - RS_SESSION_URL was used in the earlier implementation to determine the SLURM Job ID and eventually to source /tmp/.slurm-$USER-$JOBID.env
.
Since this approach does not work, we are now using the last file created with name /tmp/.slurm-$USER-*.env
to determine the SLURM Job ID. it is maybe not as safe as the previous solution, but given the fact that between the creating of /tmp/.slurm-$USER-$JOBID.env
and the read of the same very little time has elapsed, the approach is safe.
The final solution however will use a combined approach where it will still try to detect the SLURM JOB ID via RS_SESSION_URL as before and if and only if that fails it will use the above approach. This will ensure that opening Terminals during the lifetime of an RStudio Session will still properly detect the SLURM JobID.
From the R console:
> system("env | grep SING")
SINGULARITY_COMMAND=start
SLURM_SINGULARITY_ARGS=
SINGULARITY_ENVIRONMENT=/.singularity.d/env/91-environment.sh
SINGULARITY_INSTANCE=singularity-7a8c57a5c9a44f338884416c14555059
SINGULARITY_CONTAINER=/opt/apptainer/containers/r-session-new2-centos7.simg
> system("env | grep SLURM")
SLURM_NODELIST=all-st-rstudio-1
SLURM_TOPOLOGY_ADDR=all-st-rstudio-1
SLURM_PRIO_PROCESS=0
SLURM_RLIMIT_CORE=0
SLURM_TOPOLOGY_ADDR_PATTERN=node
SLURM_SPANK__SLURM_SPANK_OPTION_singularity_exec_singularity_container=r-session-new2-centos7.simg
SLURM_NNODES=1
SLURM_GPUS=v100:0
SLURM_RLIMIT_STACK=8388608
SLURM_JOBID=295
SLURM_RLIMIT_MEMLOCK=65536
SLURM_NTASKS=1
SLURM_TASKS_PER_NODE=1
SLURM_CONF=/opt/slurm/etc/slurm.conf
SLURM_WORKING_CLUSTER=demo-sol-eng-demo:172.31.31.209:6820:9728:109
SLURM_SINGULARITY_ARGS=
SLURM_JOB_ID=295
SLURM_CPUS_PER_TASK=1
SLURM_JOB_USER=rstudio
SLURM_JOB_UID=8787
SLURM_NODEID=0
SLURM_SUBMIT_DIR=/
SLURM_TASK_PID=292087
SLURM_NPROCS=1
SLURM_CPUS_ON_NODE=1
SLURM_PROCID=0
SLURM_RLIMIT_NPROC=63935
SLURM_JOB_NODELIST=all-st-rstudio-1
SLURM_LOCALID=0
SLURM_JOB_GID=8787
SLURM_JOB_CPUS_PER_NODE=1
SLURM_SUBMIT_HOST=ip-172-31-31-209
SLURM_GTIDS=0
SLURM_JOB_PARTITION=all
SLURM_RLIMIT_DATA=18446744073709551615
SLURM_JOB_NUM_NODES=1
SLURM_RLIMIT_FSIZE=18446744073709551615
SLURM_RLIMIT_RSS=18446744073709551615
SLURM_RLIMIT_AS=18446744073709551615
SLURM_RLIMIT_CPU=18446744073709551615
SLURM_RLIMIT_NOFILE=1024
SLURM_MEM_PER_NODE=4500
Closing for now