Skip to content

cvanvelt/rstudio-server-conda_cy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repo cloned from https://github.com/grst/rstudio-server-conda and adjusted for easier use with singularity

Running Rstudio Server in a Conda Environment

I usually rely on the conda package manager to manage my environments during development. Thanks to conda-forge and bioconda most R packages are now also available through conda. For production, I convert them to containers as these are easier to share.

Unfortunately, there seems to be no straightforward way to use conda envs in Rstudio server. This repository provides three approaches to make rstudio server work with conda envs.

Running Rstudio Server with Singularity

With this approach Rstudio Server runs in a Singularity container (any based on rocker/rstudio).
The conda environment gets mounted into the container - like that there's no need to rebuild the container to add a package and install.packages can be used without issues. The container-based approach has the following benefits:

  • Authentication works (#3)
  • Several separate instances of Rstudio server can run in parallel, even without the Pro version.
  • R version can easily be switched by mounting different conda environment.

Prerequisites

Usage

  1. Clone this repository

  2. Activate the target conda env or set the environment variable CONDA_PREFIX to point to the location of the conda env.

  3. Check the '/singularity/init.sh' script. You need to adjust the path to miniconda.

  4. Check the run_singularity.sh script. In particular, you may need to add additional bind mounts (e.g. a global data directory), add path to your favorite container, add path to your favority conda prefix.

  5. Execute the run_singularity.sh script. It will automatically build the container if it is not available.

    PORT=8585 PASSWORD=rstudio CONDA_PREFIX="./my_Tools/myPY/envs/r43_env"  CONTAINER="./tidyverse_latest.sif"  ./singularity/run_singularity.sh
  6. Open a tunnel to the compute server running the container

    ssh -N -L 8585:{node}:8585 {user}@hpc-login
  7. Log into Rstudio

    • open rstudio server at http://localhost:8585 (or whatever port you specified)
    • login with your default username and the password you specified via the PASSWORD environment variable.
    • Sometimes, running multiple sessions from the same IP adress using the same browser can result in different sessions using the same secure-cookie-key. This causes sessions to disconnect and converge into 1 session. A work-around is using Firefox container tabs; https://support.mozilla.org/en-US/kb/how-use-firefox-containers. Follow the description in the link and assign each session to its own container. Now you should be able to run multiple rstudio sessions simultaneously without sessions interfering with each other.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published