mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 10:04:03 +00:00
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>
This commit is contained in:
@@ -12,6 +12,9 @@ c.ServerApp.ip = "0.0.0.0"
|
|||||||
c.ServerApp.port = 8888
|
c.ServerApp.port = 8888
|
||||||
c.ServerApp.open_browser = False
|
c.ServerApp.open_browser = False
|
||||||
|
|
||||||
|
# to output both image/svg+xml and application/pdf plot formats in the notebook file
|
||||||
|
c.InlineBackend.figure_formats = {"png", "jpeg", "svg", "pdf"}
|
||||||
|
|
||||||
# https://github.com/jupyter/notebook/issues/3130
|
# https://github.com/jupyter/notebook/issues/3130
|
||||||
c.FileContentsManager.delete_to_trash = False
|
c.FileContentsManager.delete_to_trash = False
|
||||||
|
|
||||||
|
@@ -21,8 +21,6 @@ RUN apt-get update --yes && \
|
|||||||
tzdata \
|
tzdata \
|
||||||
unzip \
|
unzip \
|
||||||
vim-tiny \
|
vim-tiny \
|
||||||
# Inkscape is installed to be able to convert SVG files
|
|
||||||
inkscape \
|
|
||||||
# git-over-ssh
|
# git-over-ssh
|
||||||
openssh-client \
|
openssh-client \
|
||||||
# less is needed to run help in R
|
# less is needed to run help in R
|
||||||
@@ -40,3 +38,6 @@ RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10
|
|||||||
|
|
||||||
# Switch back to jovyan to avoid accidental container runs as root
|
# Switch back to jovyan to avoid accidental container runs as root
|
||||||
USER ${NB_UID}
|
USER ${NB_UID}
|
||||||
|
|
||||||
|
# Add R mimetype option to specify how the plot returns from R to the browser
|
||||||
|
COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/
|
||||||
|
4
minimal-notebook/Rprofile.site
Normal file
4
minimal-notebook/Rprofile.site
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Add R mimetype to specify how the plot returns from R to the browser.
|
||||||
|
# https://notebook.community/andrie/jupyter-notebook-samples/Changing%20R%20plot%20options%20in%20Jupyter
|
||||||
|
|
||||||
|
options(jupyter.plot_mimetypes = c('text/plain', 'image/png', 'image/jpeg', 'image/svg+xml', 'application/pdf'))
|
21
tests/R_mimetype_check.py
Normal file
21
tests/R_mimetype_check.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright (c) Jupyter Development Team.
|
||||||
|
# Distributed under the terms of the Modified BSD License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from tests.conftest import TrackedContainer
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def check_r_mimetypes(container: TrackedContainer) -> None:
|
||||||
|
"""Check if Rscript command can be executed"""
|
||||||
|
LOGGER.info("Test that R command can be executed ...")
|
||||||
|
Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 5) {stop("missing jupyter.plot_mimetypes")}'
|
||||||
|
logs = container.run_and_wait(
|
||||||
|
timeout=10,
|
||||||
|
tty=True,
|
||||||
|
command=["Rscript", "-e", Rcommand],
|
||||||
|
)
|
||||||
|
LOGGER.debug(f"{logs=}")
|
||||||
|
assert len(logs) == 0, f"Command {Rcommand=} failed"
|
10
tests/datascience-notebook/test_mimetypes.py
Normal file
10
tests/datascience-notebook/test_mimetypes.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) Jupyter Development Team.
|
||||||
|
# Distributed under the terms of the Modified BSD License.
|
||||||
|
|
||||||
|
from tests.conftest import TrackedContainer
|
||||||
|
from tests.R_mimetype_check import check_r_mimetypes
|
||||||
|
|
||||||
|
|
||||||
|
def test_mimetypes(container: TrackedContainer) -> None:
|
||||||
|
"""Check if Rscript command for mimetypes can be executed"""
|
||||||
|
check_r_mimetypes(container)
|
@@ -1,19 +0,0 @@
|
|||||||
# Copyright (c) Jupyter Development Team.
|
|
||||||
# Distributed under the terms of the Modified BSD License.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from tests.conftest import TrackedContainer
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def test_inkscape(container: TrackedContainer) -> None:
|
|
||||||
"""Inkscape shall be installed to be able to convert SVG files."""
|
|
||||||
LOGGER.info("Test that inkscape is working by printing its version ...")
|
|
||||||
logs = container.run_and_wait(
|
|
||||||
timeout=10,
|
|
||||||
tty=True,
|
|
||||||
command=["start.sh", "bash", "-c", "inkscape --version"],
|
|
||||||
)
|
|
||||||
assert "Inkscape" in logs, "Inkscape not installed or not working"
|
|
10
tests/r-notebook/test_R_mimetypes.py
Normal file
10
tests/r-notebook/test_R_mimetypes.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) Jupyter Development Team.
|
||||||
|
# Distributed under the terms of the Modified BSD License.
|
||||||
|
|
||||||
|
from tests.conftest import TrackedContainer
|
||||||
|
from tests.R_mimetype_check import check_r_mimetypes
|
||||||
|
|
||||||
|
|
||||||
|
def test_mimetypes(container: TrackedContainer) -> None:
|
||||||
|
"""Check if Rscript command for mimetypes can be executed"""
|
||||||
|
check_r_mimetypes(container)
|
Reference in New Issue
Block a user