[ESS] Emacs/ESS using Singularity container

Gavin Kelly G@v|n@Ke||y @end|ng |rom cr|ck@@c@uk
Tue Nov 19 18:26:42 CET 2024


I decided to force myself to select the correct inferior-ess-r-program with the (probably embarrassing) elisp below. My bash scripts are named either `R-4.x.y` or` my-R-4.3.2`  ... so the first function picks those from a directory.  The second uses that to swoop up the directory tree until it finds one, and the final one is the one I call interactively that offers me a 'menu' of R to use  - there's probably a way to have it non-interactive, but I might have multiple R versions in the same directory!

 As an aside, my actual R-4.x.y script contains an expanded version of the bash script sent previously - if there's a softlink to it beginning my-R, calling it adds the extra 'interactive' binds. Softlinks to it called 'shiny' or 'rstudio' (I haven't been successful in convincing colleagues of the one true way!) do what you'd hope (either on the login node or submitting it) - I'll try to tidy that up a bit as it's proving quite useful.

  (defun gpk-rscripts (path)
    "Get a list of potential R-calling scripts in path"
    (append (file-name-all-completions "R-" path) (file-name-all-completions "my-R" path))
    )

  (defun gpk-findr ()
    (mapcan (lambda (path)
              (mapcar (lambda (r) (concat path r)) (gpk-rscripts path))
              )
            (list (locate-dominating-file default-directory (lambda(d) (gpk-rscripts d))))
            )
    )

  (defun gpk-r-set ()
    "Find R executables"
    (interactive)
    (setq inferior-ess-r-program (completing-read "R version: "  (gpk-findr)) )
    )



-----Original Message-----
From: ESS-help <ess-help-bounces using r-project.org> On Behalf Of James W. MacDonald via ESS-help
Sent: 19 November 2024 16:00
To: ess-help using r-project.org
Subject: Re: [ESS] Emacs/ESS using Singularity container


External Sender: Use caution.


That's very helpful! One more question if you don't mind. In Lionel Henry's solution, he changes ess-customize-alist to map inferior-ess-r-program to the shell script that starts the container. If you have individual shell scripts in each analysis directory, I assume you are not doing that? Or do I misunderstand how ess-r-customize-alist works?

defun R-docker ()
  (interactive)
  (let ((ess-r-customize-alist
         (append ess-r-customize-alist
                 '((inferior-ess-r-program . <shell script location goes here>))))
                 (ess-R-readline t))
                 (R)))

Thanks so much,

Jim

-----Original Message-----
From: ESS-help <ess-help-bounces using r-project.org> On Behalf Of Gavin Kelly via ESS-help
Sent: Tuesday, November 19, 2024 5:57 AM
To: ess-help using r-project.org
Subject: Re: [ESS] Emacs/ESS using Singularity container

I'm running ESS in similar HPC circumstances, and have adopted a similar solution to the one in Lionel Henry's post.  I tend to keep a shell script along the lines of the following in every project, and it works 'fine'. It's singularity, but I think apptainer is equivalent.  Just in case it helps.



```
pwd=$(realpath ${PWD})
project_root=$(realpath $(git rev-parse --show-toplevel || echo ${pwd)) extra=--bind $HOME/.Xauthority,$HOME/.Xdefaults,$HOME/.Xresources,$HOME/.emacs.d,$HOME/.ssh --env DISPLAY=$DISPLAY # in real life, $extra is defined in elsewhere and is only used in interactive sessions, not in e.g. makefiles.
cmd=R
image=bioconductor_docker_3.18-R-4.3.2.sif
singularity exec --bind ${project_root},/tmp --pwd ${pwd} --containall --cleanenv  --env SQLITE_TMPDIR=/tmp,BIOCPARALLEL_WORKER_NUMBER=2,GITHUB_PAT=${GITHUB_PAT} ${extra} ${image} ${cmd} $@ ``` The Francis Crick Institute Limited is a registered charity in England and Wales no. 1140062 and a company registered in England and Wales no. 06885462, with its registered office at 1 Midland Road London NW1 1AT

______________________________________________
ESS-help using r-project.org mailing list
https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/ess-help__;!!K-Hz7m0Vt54!kZsw4QAGEjvgcvGm2yIOYXWL9HXVCyZ_xygq22RiCXRtb6Q4IJz1MNikuNEZm29gn1PWPusW0iaf79DkTx1U5wmJIpk$

______________________________________________
ESS-help using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help
The Francis Crick Institute Limited is a registered charity in England and Wales no. 1140062 and a company registered in England and Wales no. 06885462, with its registered office at 1 Midland Road London NW1 1AT



More information about the ESS-help mailing list