Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install R packages? #26

Closed
guillaumecharbonnier opened this issue Jun 16, 2022 · 5 comments
Closed

Install R packages? #26

guillaumecharbonnier opened this issue Jun 16, 2022 · 5 comments

Comments

@guillaumecharbonnier
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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:

  • Ensure mamba is installing an R interpreter on its own, and it replaces the existing one.
  • If this is not possible because defaults paths are different, look up how Jupyter delegates the %%R calls and make sure that the interpreter called here is the one in the conda environment (you might need to patch or symlink files).

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 added a commit to guillaumecharbonnier/mw-lib that referenced this issue Jun 17, 2022
@guillaumecharbonnier
Copy link
Author

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants