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

Add R language support #9

Closed
Jean-Baptiste-Lasselle opened this issue Mar 9, 2024 · 7 comments
Closed

Add R language support #9

Jean-Baptiste-Lasselle opened this issue Mar 9, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@Jean-Baptiste-Lasselle
Copy link
Contributor

@Jean-Baptiste-Lasselle
Copy link
Contributor Author

Jean-Baptiste-Lasselle commented Mar 9, 2024

@Jean-Baptiste-Lasselle
Copy link
Contributor Author

After R kernel works, I want to add an example of using Polars with R language:

https://github.com/pola-rs/r-polars

I'll just do the exact same notebook, in typescript, and R language (perhaps later in python the others interested in python could do it

@Jean-Baptiste-Lasselle
Copy link
Contributor Author

Jean-Baptiste-Lasselle commented Mar 9, 2024

jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash -c 'source ~/.bashrc && conda --version'                                                              conda 24.1.2
jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash -c 'source ~/.bashrc && Rscript --version'
R scripting front-end version 3.5.0 (2018-04-23)
jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash -c 'source ~/.bashrc && R --version'
R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.

Oh how to install ikernel but with the github repo instructions, to register the kernel to jupyter :

jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash

pwd
/usr/dataviz/notebooks/decoderleco
bash
ls -alh
total 32K
drwxr-xr-x 7 1000 1000 4.0K Mar  9 16:54 .
drwxr-xr-x 3 root root 4.0K Mar  5 21:20 ..
drwx------ 4 root root 4.0K Mar  8 22:27 .Trash-0
drwxr-xr-x 2 root root 4.0K Mar  8 22:27 .ipynb_checkpoints
drwxr-xr-x 3 1000 1000 4.0K Mar  5 21:15 data
drwxr-xr-x 3 1000 1000 4.0K Mar  8 11:50 first-examples
-rw-r--r-- 1 root root   70 Mar  9 16:55 install.ikernel.r
drwxr-xr-x 3 1000 1000 4.0K Mar  9 15:56 jb
cat install.ikernel.r
install.packages(IRkernel)
IRkernel --version
IRkernel::installspec()
echo "install.packages('IRkernel')" | tee -a ./install.ikernel.r
install.packages('IRkernel')

cat install.ikernel.r
install.packages(IRkernel)
IRkernel --version
IRkernel::installspec()
install.packages('IRkernel')
echo "install.packages('IRkernel')" | tee ./install.ikernel.r
install.packages('IRkernel')


cat install.ikernel.r
install.packages('IRkernel')
echo "IRkernel::installspec()" | tee -a ./install.ikernel.r
IRkernel::installspec()
cat install.ikernel.r
install.packages('IRkernel')
IRkernel::installspec()
Rscript ./install.ikernel.r
bash: line 12: Rscript: command not found
Rscript --version
bash: line 13: Rscript: command not found
exit
exit
jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash -c 'source ~/.bashrc && Rscript ./install.ikernel.r'
Error in contrib.url(repos, type) :
  trying to use CRAN without setting a mirror
Calls: install.packages -> grep -> contrib.url
Execution halted
jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash
cat ./install.ikernel.r
install.packages('IRkernel')
IRkernel::installspec()
echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' > ~/.Rprofile
exit
jbl@pokus2:~/poc-data-visualization$ docker-compose exec -T jupyter_deno bash -c 'source ~/.bashrc && Rscript ./install.ikernel.r'
trying URL 'https://cloud.r-project.org/src/contrib/IRkernel_1.3.2.tar.gz'
Content type 'application/x-gzip' length 45172 bytes (44 KB)
==================================================
downloaded 44 KB

* installing *source* package ‘IRkernel’ ...
** package ‘IRkernel’ successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
code for methods in class “CommManager” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
code for methods in class “Comm” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
code for methods in class “Executor” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
code for methods in class “Kernel” was not checked for suspicious field assignments (recommended package ‘codetools’ not available?)
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (IRkernel)

The downloaded source packages are in
        ‘/tmp/Rtmpd8UdHc/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
jbl@pokus2:~/poc-data-visualization$

yeahhhhhhhhh :D :

image

@Jean-Baptiste-Lasselle
Copy link
Contributor Author

ok we have the feature of R language support, plus some good sweeties, only left to do :

@Jean-Baptiste-Lasselle
Copy link
Contributor Author

Jean-Baptiste-Lasselle commented Mar 10, 2024

Big issue with the R Kernel

Here is the issue I got :

jupyter_deno_1       | Error in dev.control(displaylist = "enable") :
jupyter_deno_1       |   dev.control() called without an open graphics device
jupyter_deno_1       | Calls: <Anonymous> ... tryCatch -> tryCatchList -> evaluate -> dev.control
jupyter_deno_1       | In addition: Warning messages:
jupyter_deno_1       | 1: In ok_device(filename, ...) :
jupyter_deno_1       |   unable to load shared object '/root/anaconda3/lib/R/library/grDevices/libs//cairo.so':
jupyter_deno_1       |   libXrender.so.1: cannot open shared object file: No such file or directory
jupyter_deno_1       | 2: In ok_device(filename, ...) : failed to load cairo DLL
jupyter_deno_1       | Execution halted

Sources of infos I found while googling that:

First try at fixing issue

Ok, i read a bit the issues comment I and soon found that lots of libraries were installed, in the official jupyter nootebooks docker container image for r-notebook (some apt-get installed, and some conda installed):

# R pre-requisites
RUN apt-get update --yes && \
    apt-get install --yes --no-install-recommends \
    fonts-dejavu \
    unixodbc \
    unixodbc-dev \
    r-cran-rodbc \
    gfortran \
    gcc && \
    apt-get clean && rm -rf /var/lib/apt/lists/*
RUN mamba install --yes \
    'r-base' \
    'r-caret' \
    'r-crayon' \
    'r-devtools' \
    'r-e1071' \
    'r-forecast' \
    'r-hexbin' \
    'r-htmltools' \
    'r-htmlwidgets' \
    'r-irkernel' \
    'r-nycflights13' \
    'r-randomforest' \
    'r-rcurl' \
    'r-rmarkdown' \
    'r-rodbc' \
    'r-rsqlite' \
    'r-shiny' \
    'r-tidymodels' \
    'r-tidyverse' \
    'unixodbc' && \

I did not install mamba, so i will just install the above libs, using conda directly, just like i did install r and r-ikernel libs, followed by a global conda update. I will also install first the apt-get installed linux packages:

apt-get update --yes && \
    apt-get install --yes --no-install-recommends \
    fonts-dejavu \
    unixodbc \
    unixodbc-dev \
    r-cran-rodbc \
    gfortran \
    gcc && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

conda install --yes \
    'r-base' \
    'r-caret' \
    'r-crayon' \
    'r-devtools' \
    'r-e1071' \
    'r-forecast' \
    'r-hexbin' \
    'r-htmltools' \
    'r-htmlwidgets' \
    'r-irkernel' \
    'r-nycflights13' \
    'r-randomforest' \
    'r-rcurl' \
    'r-rmarkdown' \
    'r-rodbc' \
    'r-rsqlite' \
    'r-shiny' \
    'r-tidymodels' \
    'r-tidyverse' \
    'unixodbc' && \
    conda clean --all -f -y && \
    conda update --all -y 

 #    mamba clean --all -f -y && \
 #    fix-permissions "${CONDA_DIR}" && \
 #    fix-permissions "/home/${NB_USER}

Yet, before trying the above huge changes, even if they make sense, I will do something that makes just as much sense, and brigns a much smaller change:

Test 1: installing libxrender with apt-get package manager

  • I run the blow, and then wait that the VM boots back up, and the whole docker-compose stack gets back up n running:
docker-compose exec -T jupyter_deno bash -c "source ~/.bashrc && apt-get install -y libxrender1"
sudo reboot -h now
  • results:

it worksssssssssssssss ❤️ !!!! so manyyy thanks https://github.com/jfpuget !!!

image

I may consider later to add the above huge list of packages, but for now, I iwll stick to the KISS principle and the (why updating something that already works ?)

@Jean-Baptiste-Lasselle Jean-Baptiste-Lasselle added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Mar 12, 2024
@Jean-Baptiste-Lasselle Jean-Baptiste-Lasselle removed bug Something isn't working documentation Improvements or additions to documentation labels Mar 12, 2024
@Jean-Baptiste-Lasselle
Copy link
Contributor Author

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

No branches or pull requests

3 participants