Skip to content

Commit 0fd68f0

Browse files
Bidek56pre-commit-ci[bot]mathbunnyru
authored
Remove inkscape package from the minimal-notebook (#1765)
* Removing inkscape * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Adding Rprofile to add plot_mimetypes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update datascience-notebook/Dockerfile Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Update datascience-notebook/Rprofile.site Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Adding R notebook tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Moving Rprofile.site to minimal; Removing duplicate R test code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixing flake8 errors * Update minimal-notebook/Dockerfile Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Update minimal-notebook/Rprofile.site Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Removing empty line * Renaming minetypes to mimetypes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Renaming test module to avoid mypy error * Adding to jupyter.plot_mimetypes * Update R_mimetype_check.py * Update test_mimetypes.py * Update test_R_mimetypes.py * Update test_R_mimetypes.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
1 parent 0d65a32 commit 0fd68f0

File tree

7 files changed

+51
-21
lines changed

7 files changed

+51
-21
lines changed

base-notebook/jupyter_server_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
c.ServerApp.port = 8888
1313
c.ServerApp.open_browser = False
1414

15+
# to output both image/svg+xml and application/pdf plot formats in the notebook file
16+
c.InlineBackend.figure_formats = {"png", "jpeg", "svg", "pdf"}
17+
1518
# https://github.com/jupyter/notebook/issues/3130
1619
c.FileContentsManager.delete_to_trash = False
1720

minimal-notebook/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ RUN apt-get update --yes && \
2121
tzdata \
2222
unzip \
2323
vim-tiny \
24-
# Inkscape is installed to be able to convert SVG files
25-
inkscape \
2624
# git-over-ssh
2725
openssh-client \
2826
# less is needed to run help in R
@@ -40,3 +38,6 @@ RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10
4038

4139
# Switch back to jovyan to avoid accidental container runs as root
4240
USER ${NB_UID}
41+
42+
# Add R mimetype option to specify how the plot returns from R to the browser
43+
COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/

minimal-notebook/Rprofile.site

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Add R mimetype to specify how the plot returns from R to the browser.
2+
# https://notebook.community/andrie/jupyter-notebook-samples/Changing%20R%20plot%20options%20in%20Jupyter
3+
4+
options(jupyter.plot_mimetypes = c('text/plain', 'image/png', 'image/jpeg', 'image/svg+xml', 'application/pdf'))

tests/R_mimetype_check.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
import logging
5+
6+
from tests.conftest import TrackedContainer
7+
8+
LOGGER = logging.getLogger(__name__)
9+
10+
11+
def check_r_mimetypes(container: TrackedContainer) -> None:
12+
"""Check if Rscript command can be executed"""
13+
LOGGER.info("Test that R command can be executed ...")
14+
Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 5) {stop("missing jupyter.plot_mimetypes")}'
15+
logs = container.run_and_wait(
16+
timeout=10,
17+
tty=True,
18+
command=["Rscript", "-e", Rcommand],
19+
)
20+
LOGGER.debug(f"{logs=}")
21+
assert len(logs) == 0, f"Command {Rcommand=} failed"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
from tests.conftest import TrackedContainer
5+
from tests.R_mimetype_check import check_r_mimetypes
6+
7+
8+
def test_mimetypes(container: TrackedContainer) -> None:
9+
"""Check if Rscript command for mimetypes can be executed"""
10+
check_r_mimetypes(container)

tests/minimal-notebook/test_inkscape.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/r-notebook/test_R_mimetypes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
4+
from tests.conftest import TrackedContainer
5+
from tests.R_mimetype_check import check_r_mimetypes
6+
7+
8+
def test_mimetypes(container: TrackedContainer) -> None:
9+
"""Check if Rscript command for mimetypes can be executed"""
10+
check_r_mimetypes(container)

0 commit comments

Comments
 (0)