AlexsLemonade / OpenScPCA-analysis

An open, collaborative project to analyze data from the Single-cell Pediatric Cancer Atlas (ScPCA) Portal
Other
5 stars 14 forks source link

Packages not found in hello-r docker image #542

Closed sjspielman closed 3 months ago

sjspielman commented 3 months ago

While working on #538, I went to test out running the hello-python and hello-R docker images, and had difficulty running the analysis in the the hello-R image. The image built fine, but there were issues with renv -

I built the image and launched a container with:

docker buildx build --platform linux/amd64 --tag hello-r:latest .

docker run --rm -it --platform linux/amd64 --mount type=bind,source=/Users/sjspielman/ALSF/open-scpca/OpenScPCA-analysis,target=/OpenScPCA-analysis hello-r:latest bash

Then in the container:

cd OpenScPCA-analysis/analyses/hello-R

bash run_hello.R

Which led to:

- One or more packages recorded in the lockfile are not installed.
- Use `renv::status()` for more details.
Error in loadNamespace(x) : there is no package called ‘rmarkdown’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted

Packages were indeed installed from the renv.lock file as expected, but because of this line in the Dockerfile, there is no renv cache that knows about it. https://github.com/AlexsLemonade/OpenScPCA-analysis/blob/8ec8fa0dde4670bc440fefa58cf8d3e75aa6b984/analyses/hello-R/Dockerfile#L12-L13 As a consequence, when this script tries to load up the renv environment since we still have .Rprofile activating it, we end up with errors that packages aren't installed.

Off the top of my head, here's one not-awful idea and one bad idea, and one idea whose quality I'm unsure of, to address this...

jashapiro commented 3 months ago

The docker image should be configured to install packages at the system level (not in an renv). So another option is to modify .Rorofile to not run the activate() function if an environment variable (say OPENSCPCA_DOCKER) is set and then set that variable in the Dockerfile.