Persistent Python environment for RStudio Cloud projects

I created an RStudio Cloud project at https://rstudio.cloud/project/931550 and installed TensorFlow via tensorflow::install_tensorflow(). When I create a temporary copy in another Cloud account, the tensorflow R package is still there, but my Python environment is gone. Apparently, the Miniconda PREFIX variable was /home/rstudio-user/.local/share/r-miniconda, which did not get shipped to the new project. What is the easiest way to set up a local Python environment that Cloud will ship with the rest of the project's files?

Possibly related: Trouble setting up tensorflow on RStudio Cloud

Update: when I install Miniconda + packages locally into the project folder itself, RStudio Cloud preserves those files when I copy the project. Remaining problems:

  1. Trouble setting up tensorflow on RStudio Cloud.
  2. I need to set the WORKON_HOME env var to "virtualenvs" before doing anything in TensorFlow. My use case has several sub-projects, so I need multiple copies of the same .Renviron file.
install.packages("keras")
reticulate::install_miniconda("miniconda")
Sys.setenv(WORKON_HOME = "virtualenvs")
reticulate::virtualenv_create("r-reticulate", python = "miniconda/bin/python")
tensorflow::install_tensorflow(
  method = "virtualenv",
  conda = "miniconda/bin/conda",
  envname = "r-reticulate",
  restart_session = FALSE
)
keras::install_keras(
  method = "virtualenv",
  conda = "miniconda/bin/conda",
  envname = "r-reticulate"
)

Good to hear!! This is definitely an interesting use case to keep in mind, thanks for sharing!!

I was hopeful that .Renviron and .Rprofile might get you where you need to go. You could always have a .Rprofile in each directory that sources the parent .Renviron / etc.

None of these are particularly elegant solutions though :grimacing:

Just wrote this setup script to write an .Renviron at the top level and each subdirectory. And it seems to work great when I copy the project to other Cloud accounts. I am so close! All I need is for https://github.com/rstudio/rstudio/issues/6049 to be fixed an a new version of the IDE to go to Cloud. Then I will have complete control over the perfect drake workshop solution.

2 Likes

Update: problem solved! I needed to downgrade TensorFlow in install_keras(). Setup script here, related comment here.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.