conda-incubator / condacolab

Install Conda and friends on Google Colab, easily
MIT License
341 stars 49 forks source link

Install R packages? #26

Closed guillaumecharbonnier closed 2 years ago

guillaumecharbonnier commented 2 years ago

Is it possible to install R packages using condacolab, then load these packages inside %%R cells?

If I try it I get this error:

RRuntimeError: Error in (function (filename = "Rplot%03d.png", width = 480, height = 480,  : 
  Graphics API version mismatch
jaimergp commented 2 years ago

I am not doing anything R-specific in the setup. Does Colab ship their own R runtime too? I guess we need to do some patching in that case so it uses conda's R?

guillaumecharbonnier commented 2 years ago

Yes, Colab ships their own R runtime. But what I always use is the default runtime with the Rmagic. Most packages can be installed the R way, but mamba is way faster. Here is an example with the issue at the bottom of the notebook: https://colab.research.google.com/drive/17qG00WaqIPCrRtwYeC7omKUMAi4v1xMj?usp=sharing

jaimergp commented 2 years ago

I see. We might need to install R from scratch using conda/mamba too, and hope it replaces everything already in Colab.

I am planning a refactor where we stop depending on the shipped packages though, so everything is added by us and we don't have to cross our fingers for ABI compatibility. This would make the R case way simpler.

That said, I don't have an ETA for that. Let's leave this open for now so we can target it in the future.


If you want to debug this in the meantime, this is what I would do:

Also, take into account that a current limitation is that we can't add new environments. If you want to use an environment file, you should use conda env update -n base -f environment.yml.

guillaumecharbonnier commented 2 years ago

Thanks for your tips, it is actually super easy to fix this issue by ensuring mamba also install and overwrite rpy2 in the base environment. I have updated the notebook linked above accordingly. Most of my colab notebooks have just got a ~30-minute computation time decrease. \o/

jaimergp commented 2 years ago

Awesome! I'll add a note to the README.