From c6c1422c8dfb6ac16b4a60b39710217d40266a9c Mon Sep 17 00:00:00 2001 From: Darek Date: Mon, 8 Aug 2022 17:06:13 -0400 Subject: [PATCH 01/22] Removing inkscape --- base-notebook/jupyter_server_config.py | 3 +++ minimal-notebook/Dockerfile | 2 -- tests/minimal-notebook/test_inkscape.py | 19 ------------------- 3 files changed, 3 insertions(+), 21 deletions(-) delete mode 100644 tests/minimal-notebook/test_inkscape.py diff --git a/base-notebook/jupyter_server_config.py b/base-notebook/jupyter_server_config.py index ef0380bd35..c8e0d8b73c 100644 --- a/base-notebook/jupyter_server_config.py +++ b/base-notebook/jupyter_server_config.py @@ -12,6 +12,9 @@ c.ServerApp.port = 8888 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 c.FileContentsManager.delete_to_trash = False diff --git a/minimal-notebook/Dockerfile b/minimal-notebook/Dockerfile index f7b495f6dd..4a01601aee 100644 --- a/minimal-notebook/Dockerfile +++ b/minimal-notebook/Dockerfile @@ -21,8 +21,6 @@ RUN apt-get update --yes && \ tzdata \ unzip \ vim-tiny \ - # Inkscape is installed to be able to convert SVG files - inkscape \ # git-over-ssh openssh-client \ # less is needed to run help in R diff --git a/tests/minimal-notebook/test_inkscape.py b/tests/minimal-notebook/test_inkscape.py deleted file mode 100644 index 7cdcf2777f..0000000000 --- a/tests/minimal-notebook/test_inkscape.py +++ /dev/null @@ -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" From f59ba42db960b1266befa3ff0e5e0309a75c48cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Aug 2022 21:10:43 +0000 Subject: [PATCH 02/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- base-notebook/jupyter_server_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base-notebook/jupyter_server_config.py b/base-notebook/jupyter_server_config.py index c8e0d8b73c..c95957cc7b 100644 --- a/base-notebook/jupyter_server_config.py +++ b/base-notebook/jupyter_server_config.py @@ -13,7 +13,7 @@ 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'} +c.InlineBackend.figure_formats = {"png", "jpeg", "svg", "pdf"} # https://github.com/jupyter/notebook/issues/3130 c.FileContentsManager.delete_to_trash = False From c4b286aafb253d3691929e29ca5aac5a1bf7f5a7 Mon Sep 17 00:00:00 2001 From: Darek Date: Tue, 9 Aug 2022 15:25:40 -0400 Subject: [PATCH 03/22] Adding Rprofile to add plot_mimetypes --- datascience-notebook/Dockerfile | 3 +++ datascience-notebook/Rprofile.site | 5 +++++ r-notebook/Dockerfile | 3 +++ r-notebook/Rprofile.site | 5 +++++ 4 files changed, 16 insertions(+) create mode 100644 datascience-notebook/Rprofile.site create mode 100644 r-notebook/Rprofile.site diff --git a/datascience-notebook/Dockerfile b/datascience-notebook/Dockerfile index 584d1f5374..9324e49444 100644 --- a/datascience-notebook/Dockerfile +++ b/datascience-notebook/Dockerfile @@ -85,6 +85,9 @@ RUN mamba install --quiet --yes \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}" +# Add mimetype to specifies how the plot returns from R to the browser. +COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ + # `rpy2` and `r-tidymodels` are not easy to install under aarch64 RUN set -x && \ arch=$(uname -m) && \ diff --git a/datascience-notebook/Rprofile.site b/datascience-notebook/Rprofile.site new file mode 100644 index 0000000000..33bbfe7b3a --- /dev/null +++ b/datascience-notebook/Rprofile.site @@ -0,0 +1,5 @@ + +# Add mimetype to specifies 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/svg+xml', 'application/pdf')) \ No newline at end of file diff --git a/r-notebook/Dockerfile b/r-notebook/Dockerfile index 3319a802b3..fa8b9d764c 100644 --- a/r-notebook/Dockerfile +++ b/r-notebook/Dockerfile @@ -61,3 +61,6 @@ RUN set -x && \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}"; \ fi; + +# Add mimetype to specifies how the plot returns from R to the browser. +COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ \ No newline at end of file diff --git a/r-notebook/Rprofile.site b/r-notebook/Rprofile.site new file mode 100644 index 0000000000..33bbfe7b3a --- /dev/null +++ b/r-notebook/Rprofile.site @@ -0,0 +1,5 @@ + +# Add mimetype to specifies 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/svg+xml', 'application/pdf')) \ No newline at end of file From 464f035691cdc6711edaec95b9248f876f6a326f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Aug 2022 19:26:11 +0000 Subject: [PATCH 04/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- datascience-notebook/Rprofile.site | 2 +- r-notebook/Dockerfile | 2 +- r-notebook/Rprofile.site | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datascience-notebook/Rprofile.site b/datascience-notebook/Rprofile.site index 33bbfe7b3a..551e9aa0e8 100644 --- a/datascience-notebook/Rprofile.site +++ b/datascience-notebook/Rprofile.site @@ -2,4 +2,4 @@ # Add mimetype to specifies 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/svg+xml', 'application/pdf')) \ No newline at end of file +options(jupyter.plot_mimetypes = c('text/plain', 'image/svg+xml', 'application/pdf')) diff --git a/r-notebook/Dockerfile b/r-notebook/Dockerfile index fa8b9d764c..b1ae785476 100644 --- a/r-notebook/Dockerfile +++ b/r-notebook/Dockerfile @@ -63,4 +63,4 @@ RUN set -x && \ fi; # Add mimetype to specifies how the plot returns from R to the browser. -COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ \ No newline at end of file +COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ diff --git a/r-notebook/Rprofile.site b/r-notebook/Rprofile.site index 33bbfe7b3a..551e9aa0e8 100644 --- a/r-notebook/Rprofile.site +++ b/r-notebook/Rprofile.site @@ -2,4 +2,4 @@ # Add mimetype to specifies 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/svg+xml', 'application/pdf')) \ No newline at end of file +options(jupyter.plot_mimetypes = c('text/plain', 'image/svg+xml', 'application/pdf')) From 7333d91ca482bb747a2c73707c0d15713a087b25 Mon Sep 17 00:00:00 2001 From: Darek Date: Wed, 10 Aug 2022 09:23:52 -0400 Subject: [PATCH 05/22] Update datascience-notebook/Dockerfile Co-authored-by: Ayaz Salikhov --- datascience-notebook/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datascience-notebook/Dockerfile b/datascience-notebook/Dockerfile index 9324e49444..3e20cc75ea 100644 --- a/datascience-notebook/Dockerfile +++ b/datascience-notebook/Dockerfile @@ -85,7 +85,7 @@ RUN mamba install --quiet --yes \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}" -# Add mimetype to specifies how the plot returns from R to the browser. +# Add `mimetype` to specify how the plot returns from R to the browser. COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ # `rpy2` and `r-tidymodels` are not easy to install under aarch64 From 1eeed83898928aa88a13b56614e4bc3ca2596e38 Mon Sep 17 00:00:00 2001 From: Darek Date: Wed, 10 Aug 2022 10:36:58 -0400 Subject: [PATCH 06/22] Update datascience-notebook/Rprofile.site Co-authored-by: Ayaz Salikhov --- datascience-notebook/Rprofile.site | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/datascience-notebook/Rprofile.site b/datascience-notebook/Rprofile.site index 551e9aa0e8..a6c0a2f7ee 100644 --- a/datascience-notebook/Rprofile.site +++ b/datascience-notebook/Rprofile.site @@ -1,5 +1,4 @@ - -# Add mimetype to specifies how the plot returns from R to the browser. +# Add `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/svg+xml', 'application/pdf')) From 603f07b8bb395d17ca5f3feabb19e90db2d246b6 Mon Sep 17 00:00:00 2001 From: Darek Date: Wed, 17 Aug 2022 12:32:09 -0400 Subject: [PATCH 07/22] Adding R notebook tests --- .../data/minetypes_R.ipynb | 37 ++++++++++++++++++ tests/datascience-notebook/test_R_notebook.py | 38 +++++++++++++++++++ tests/r-notebook/data/minetypes_R.ipynb | 37 ++++++++++++++++++ tests/r-notebook/test_R_notebook.py | 38 +++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 tests/datascience-notebook/data/minetypes_R.ipynb create mode 100644 tests/datascience-notebook/test_R_notebook.py create mode 100644 tests/r-notebook/data/minetypes_R.ipynb create mode 100644 tests/r-notebook/test_R_notebook.py diff --git a/tests/datascience-notebook/data/minetypes_R.ipynb b/tests/datascience-notebook/data/minetypes_R.ipynb new file mode 100644 index 0000000000..539de42d2c --- /dev/null +++ b/tests/datascience-notebook/data/minetypes_R.ipynb @@ -0,0 +1,37 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "r" + } + }, + "outputs": [], + "source": [ + "# Test for a number of plot_mimetypes available\n", + "if (length(getOption(\"jupyter.plot_mimetypes\")) != 3) {\n", + " stop(\"missing jupyter.plot_mimetypes\")\n", + "}" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "R", + "language": "R", + "name": "ir" + }, + "language_info": { + "codemirror_mode": "r", + "file_extension": ".r", + "mimetype": "text/x-r-source", + "name": "R", + "pygments_lexer": "r", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/tests/datascience-notebook/test_R_notebook.py b/tests/datascience-notebook/test_R_notebook.py new file mode 100644 index 0000000000..730533106b --- /dev/null +++ b/tests/datascience-notebook/test_R_notebook.py @@ -0,0 +1,38 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +import logging +from pathlib import Path + +import pytest # type: ignore + +from tests.conftest import TrackedContainer + +LOGGER = logging.getLogger(__name__) +THIS_DIR = Path(__file__).parent.resolve() + +@pytest.mark.parametrize( + "test_file", ["minetypes_R"], +) +def test_minetypes(container: TrackedContainer, test_file: str) -> None: + """Check if R notebooks can be executed""" + host_data_dir = THIS_DIR / "data" + cont_data_dir = "/home/jovyan/data" + output_dir = "/tmp" + conversion_timeout_ms = 600 + LOGGER.info(f"Test that {test_file} notebook can be executed ...") + command = ( + "jupyter nbconvert --to markdown " + + f"--ExecutePreprocessor.timeout={conversion_timeout_ms} " + + f"--output-dir {output_dir} " + + f"--execute {cont_data_dir}/{test_file}.ipynb" + ) + logs = container.run_and_wait( + timeout=60, + volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}}, + tty=True, + command=["start.sh", "bash", "-c", command], + ) + + expected_file = f"{output_dir}/{test_file}.md" + assert expected_file in logs, f"Expected file {expected_file} not generated" diff --git a/tests/r-notebook/data/minetypes_R.ipynb b/tests/r-notebook/data/minetypes_R.ipynb new file mode 100644 index 0000000000..539de42d2c --- /dev/null +++ b/tests/r-notebook/data/minetypes_R.ipynb @@ -0,0 +1,37 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "r" + } + }, + "outputs": [], + "source": [ + "# Test for a number of plot_mimetypes available\n", + "if (length(getOption(\"jupyter.plot_mimetypes\")) != 3) {\n", + " stop(\"missing jupyter.plot_mimetypes\")\n", + "}" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "R", + "language": "R", + "name": "ir" + }, + "language_info": { + "codemirror_mode": "r", + "file_extension": ".r", + "mimetype": "text/x-r-source", + "name": "R", + "pygments_lexer": "r", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/tests/r-notebook/test_R_notebook.py b/tests/r-notebook/test_R_notebook.py new file mode 100644 index 0000000000..730533106b --- /dev/null +++ b/tests/r-notebook/test_R_notebook.py @@ -0,0 +1,38 @@ +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +import logging +from pathlib import Path + +import pytest # type: ignore + +from tests.conftest import TrackedContainer + +LOGGER = logging.getLogger(__name__) +THIS_DIR = Path(__file__).parent.resolve() + +@pytest.mark.parametrize( + "test_file", ["minetypes_R"], +) +def test_minetypes(container: TrackedContainer, test_file: str) -> None: + """Check if R notebooks can be executed""" + host_data_dir = THIS_DIR / "data" + cont_data_dir = "/home/jovyan/data" + output_dir = "/tmp" + conversion_timeout_ms = 600 + LOGGER.info(f"Test that {test_file} notebook can be executed ...") + command = ( + "jupyter nbconvert --to markdown " + + f"--ExecutePreprocessor.timeout={conversion_timeout_ms} " + + f"--output-dir {output_dir} " + + f"--execute {cont_data_dir}/{test_file}.ipynb" + ) + logs = container.run_and_wait( + timeout=60, + volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}}, + tty=True, + command=["start.sh", "bash", "-c", command], + ) + + expected_file = f"{output_dir}/{test_file}.md" + assert expected_file in logs, f"Expected file {expected_file} not generated" From 7ee5a396ec5ebc8d6668e03f168ba293a6c8276b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Aug 2022 16:32:53 +0000 Subject: [PATCH 08/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/datascience-notebook/test_R_notebook.py | 4 +++- tests/r-notebook/test_R_notebook.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/datascience-notebook/test_R_notebook.py b/tests/datascience-notebook/test_R_notebook.py index 730533106b..c3c9d1aeb3 100644 --- a/tests/datascience-notebook/test_R_notebook.py +++ b/tests/datascience-notebook/test_R_notebook.py @@ -11,8 +11,10 @@ LOGGER = logging.getLogger(__name__) THIS_DIR = Path(__file__).parent.resolve() + @pytest.mark.parametrize( - "test_file", ["minetypes_R"], + "test_file", + ["minetypes_R"], ) def test_minetypes(container: TrackedContainer, test_file: str) -> None: """Check if R notebooks can be executed""" diff --git a/tests/r-notebook/test_R_notebook.py b/tests/r-notebook/test_R_notebook.py index 730533106b..c3c9d1aeb3 100644 --- a/tests/r-notebook/test_R_notebook.py +++ b/tests/r-notebook/test_R_notebook.py @@ -11,8 +11,10 @@ LOGGER = logging.getLogger(__name__) THIS_DIR = Path(__file__).parent.resolve() + @pytest.mark.parametrize( - "test_file", ["minetypes_R"], + "test_file", + ["minetypes_R"], ) def test_minetypes(container: TrackedContainer, test_file: str) -> None: """Check if R notebooks can be executed""" From 05b8faf5bcab139bf1a95e0b65a27006e0530715 Mon Sep 17 00:00:00 2001 From: Darek Date: Thu, 18 Aug 2022 11:55:48 -0400 Subject: [PATCH 09/22] Moving Rprofile.site to minimal; Removing duplicate R test code --- datascience-notebook/Dockerfile | 3 -- datascience-notebook/Rprofile.site | 4 -- minimal-notebook/Dockerfile | 3 ++ .../Rprofile.site | 0 r-notebook/Dockerfile | 5 +-- tests/R_minetype_check.py | 21 ++++++++++ .../data/minetypes_R.ipynb | 37 ----------------- .../datascience-notebook/test_R_minetypes.py | 10 +++++ tests/datascience-notebook/test_R_notebook.py | 40 ------------------- tests/r-notebook/data/minetypes_R.ipynb | 37 ----------------- tests/r-notebook/test_R_minetypes.py | 10 +++++ tests/r-notebook/test_R_notebook.py | 40 ------------------- 12 files changed, 45 insertions(+), 165 deletions(-) delete mode 100644 datascience-notebook/Rprofile.site rename {r-notebook => minimal-notebook}/Rprofile.site (100%) create mode 100644 tests/R_minetype_check.py delete mode 100644 tests/datascience-notebook/data/minetypes_R.ipynb create mode 100644 tests/datascience-notebook/test_R_minetypes.py delete mode 100644 tests/datascience-notebook/test_R_notebook.py delete mode 100644 tests/r-notebook/data/minetypes_R.ipynb create mode 100644 tests/r-notebook/test_R_minetypes.py delete mode 100644 tests/r-notebook/test_R_notebook.py diff --git a/datascience-notebook/Dockerfile b/datascience-notebook/Dockerfile index 3e20cc75ea..584d1f5374 100644 --- a/datascience-notebook/Dockerfile +++ b/datascience-notebook/Dockerfile @@ -85,9 +85,6 @@ RUN mamba install --quiet --yes \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}" -# Add `mimetype` to specify how the plot returns from R to the browser. -COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ - # `rpy2` and `r-tidymodels` are not easy to install under aarch64 RUN set -x && \ arch=$(uname -m) && \ diff --git a/datascience-notebook/Rprofile.site b/datascience-notebook/Rprofile.site deleted file mode 100644 index a6c0a2f7ee..0000000000 --- a/datascience-notebook/Rprofile.site +++ /dev/null @@ -1,4 +0,0 @@ -# Add `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/svg+xml', 'application/pdf')) diff --git a/minimal-notebook/Dockerfile b/minimal-notebook/Dockerfile index 4a01601aee..6a6e4f6f54 100644 --- a/minimal-notebook/Dockerfile +++ b/minimal-notebook/Dockerfile @@ -38,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 USER ${NB_UID} + +# Add R mimetype option to specifies how the plot returns from R to the browser +COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ \ No newline at end of file diff --git a/r-notebook/Rprofile.site b/minimal-notebook/Rprofile.site similarity index 100% rename from r-notebook/Rprofile.site rename to minimal-notebook/Rprofile.site diff --git a/r-notebook/Dockerfile b/r-notebook/Dockerfile index b1ae785476..a7499a0ee4 100644 --- a/r-notebook/Dockerfile +++ b/r-notebook/Dockerfile @@ -60,7 +60,4 @@ RUN set -x && \ mamba clean --all -f -y && \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}"; \ - fi; - -# Add mimetype to specifies how the plot returns from R to the browser. -COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ + fi; \ No newline at end of file diff --git a/tests/R_minetype_check.py b/tests/R_minetype_check.py new file mode 100644 index 0000000000..9f809a9456 --- /dev/null +++ b/tests/R_minetype_check.py @@ -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 minetypes_check(container: TrackedContainer) -> None: + """Check if Rscript command can be executed""" + LOGGER.info(f"Test that R command can be executed ...") + Rcommand = "if (length(getOption(\"jupyter.plot_mimetypes\")) != 3) {stop(\"missing jupyter.plot_mimetypes\")}" + logs = container.run_and_wait( + timeout=60, + tty=True, + command=["Rscript", "-e", Rcommand], + ) + LOGGER.debug(f"{logs=}") + assert len(logs) == 0, f"Command {Rcommand=} failed" + + return logs \ No newline at end of file diff --git a/tests/datascience-notebook/data/minetypes_R.ipynb b/tests/datascience-notebook/data/minetypes_R.ipynb deleted file mode 100644 index 539de42d2c..0000000000 --- a/tests/datascience-notebook/data/minetypes_R.ipynb +++ /dev/null @@ -1,37 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "r" - } - }, - "outputs": [], - "source": [ - "# Test for a number of plot_mimetypes available\n", - "if (length(getOption(\"jupyter.plot_mimetypes\")) != 3) {\n", - " stop(\"missing jupyter.plot_mimetypes\")\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "R", - "language": "R", - "name": "ir" - }, - "language_info": { - "codemirror_mode": "r", - "file_extension": ".r", - "mimetype": "text/x-r-source", - "name": "R", - "pygments_lexer": "r", - "version": "3.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/tests/datascience-notebook/test_R_minetypes.py b/tests/datascience-notebook/test_R_minetypes.py new file mode 100644 index 0000000000..a17041a3ef --- /dev/null +++ b/tests/datascience-notebook/test_R_minetypes.py @@ -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_minetype_check import minetypes_check + +def test_minetypes(container: TrackedContainer) -> None: + """Check if Rscript command for minetypes can be executed""" + logs=minetypes_check(container) + assert len(logs) == 0, f"Command R command failed" \ No newline at end of file diff --git a/tests/datascience-notebook/test_R_notebook.py b/tests/datascience-notebook/test_R_notebook.py deleted file mode 100644 index c3c9d1aeb3..0000000000 --- a/tests/datascience-notebook/test_R_notebook.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -import logging -from pathlib import Path - -import pytest # type: ignore - -from tests.conftest import TrackedContainer - -LOGGER = logging.getLogger(__name__) -THIS_DIR = Path(__file__).parent.resolve() - - -@pytest.mark.parametrize( - "test_file", - ["minetypes_R"], -) -def test_minetypes(container: TrackedContainer, test_file: str) -> None: - """Check if R notebooks can be executed""" - host_data_dir = THIS_DIR / "data" - cont_data_dir = "/home/jovyan/data" - output_dir = "/tmp" - conversion_timeout_ms = 600 - LOGGER.info(f"Test that {test_file} notebook can be executed ...") - command = ( - "jupyter nbconvert --to markdown " - + f"--ExecutePreprocessor.timeout={conversion_timeout_ms} " - + f"--output-dir {output_dir} " - + f"--execute {cont_data_dir}/{test_file}.ipynb" - ) - logs = container.run_and_wait( - timeout=60, - volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}}, - tty=True, - command=["start.sh", "bash", "-c", command], - ) - - expected_file = f"{output_dir}/{test_file}.md" - assert expected_file in logs, f"Expected file {expected_file} not generated" diff --git a/tests/r-notebook/data/minetypes_R.ipynb b/tests/r-notebook/data/minetypes_R.ipynb deleted file mode 100644 index 539de42d2c..0000000000 --- a/tests/r-notebook/data/minetypes_R.ipynb +++ /dev/null @@ -1,37 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "r" - } - }, - "outputs": [], - "source": [ - "# Test for a number of plot_mimetypes available\n", - "if (length(getOption(\"jupyter.plot_mimetypes\")) != 3) {\n", - " stop(\"missing jupyter.plot_mimetypes\")\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "R", - "language": "R", - "name": "ir" - }, - "language_info": { - "codemirror_mode": "r", - "file_extension": ".r", - "mimetype": "text/x-r-source", - "name": "R", - "pygments_lexer": "r", - "version": "3.6.3" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/tests/r-notebook/test_R_minetypes.py b/tests/r-notebook/test_R_minetypes.py new file mode 100644 index 0000000000..a17041a3ef --- /dev/null +++ b/tests/r-notebook/test_R_minetypes.py @@ -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_minetype_check import minetypes_check + +def test_minetypes(container: TrackedContainer) -> None: + """Check if Rscript command for minetypes can be executed""" + logs=minetypes_check(container) + assert len(logs) == 0, f"Command R command failed" \ No newline at end of file diff --git a/tests/r-notebook/test_R_notebook.py b/tests/r-notebook/test_R_notebook.py deleted file mode 100644 index c3c9d1aeb3..0000000000 --- a/tests/r-notebook/test_R_notebook.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -import logging -from pathlib import Path - -import pytest # type: ignore - -from tests.conftest import TrackedContainer - -LOGGER = logging.getLogger(__name__) -THIS_DIR = Path(__file__).parent.resolve() - - -@pytest.mark.parametrize( - "test_file", - ["minetypes_R"], -) -def test_minetypes(container: TrackedContainer, test_file: str) -> None: - """Check if R notebooks can be executed""" - host_data_dir = THIS_DIR / "data" - cont_data_dir = "/home/jovyan/data" - output_dir = "/tmp" - conversion_timeout_ms = 600 - LOGGER.info(f"Test that {test_file} notebook can be executed ...") - command = ( - "jupyter nbconvert --to markdown " - + f"--ExecutePreprocessor.timeout={conversion_timeout_ms} " - + f"--output-dir {output_dir} " - + f"--execute {cont_data_dir}/{test_file}.ipynb" - ) - logs = container.run_and_wait( - timeout=60, - volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}}, - tty=True, - command=["start.sh", "bash", "-c", command], - ) - - expected_file = f"{output_dir}/{test_file}.md" - assert expected_file in logs, f"Expected file {expected_file} not generated" From 461d307f04bcd673f30e392c437626006b1c4122 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Aug 2022 15:58:31 +0000 Subject: [PATCH 10/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- minimal-notebook/Dockerfile | 2 +- r-notebook/Dockerfile | 2 +- tests/R_minetype_check.py | 6 ++++-- tests/datascience-notebook/test_R_minetypes.py | 5 +++-- tests/r-notebook/test_R_minetypes.py | 5 +++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/minimal-notebook/Dockerfile b/minimal-notebook/Dockerfile index 6a6e4f6f54..d685038320 100644 --- a/minimal-notebook/Dockerfile +++ b/minimal-notebook/Dockerfile @@ -40,4 +40,4 @@ RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10 USER ${NB_UID} # Add R mimetype option to specifies how the plot returns from R to the browser -COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ \ No newline at end of file +COPY --chown=${NB_UID}:${NB_GID} Rprofile.site /opt/conda/lib/R/etc/ diff --git a/r-notebook/Dockerfile b/r-notebook/Dockerfile index a7499a0ee4..3319a802b3 100644 --- a/r-notebook/Dockerfile +++ b/r-notebook/Dockerfile @@ -60,4 +60,4 @@ RUN set -x && \ mamba clean --all -f -y && \ fix-permissions "${CONDA_DIR}" && \ fix-permissions "/home/${NB_USER}"; \ - fi; \ No newline at end of file + fi; diff --git a/tests/R_minetype_check.py b/tests/R_minetype_check.py index 9f809a9456..96640a6f74 100644 --- a/tests/R_minetype_check.py +++ b/tests/R_minetype_check.py @@ -2,14 +2,16 @@ # Distributed under the terms of the Modified BSD License. import logging + from tests.conftest import TrackedContainer LOGGER = logging.getLogger(__name__) + def minetypes_check(container: TrackedContainer) -> None: """Check if Rscript command can be executed""" LOGGER.info(f"Test that R command can be executed ...") - Rcommand = "if (length(getOption(\"jupyter.plot_mimetypes\")) != 3) {stop(\"missing jupyter.plot_mimetypes\")}" + Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 3) {stop("missing jupyter.plot_mimetypes")}' logs = container.run_and_wait( timeout=60, tty=True, @@ -18,4 +20,4 @@ def minetypes_check(container: TrackedContainer) -> None: LOGGER.debug(f"{logs=}") assert len(logs) == 0, f"Command {Rcommand=} failed" - return logs \ No newline at end of file + return logs diff --git a/tests/datascience-notebook/test_R_minetypes.py b/tests/datascience-notebook/test_R_minetypes.py index a17041a3ef..e8a7369fed 100644 --- a/tests/datascience-notebook/test_R_minetypes.py +++ b/tests/datascience-notebook/test_R_minetypes.py @@ -4,7 +4,8 @@ from tests.conftest import TrackedContainer from tests.R_minetype_check import minetypes_check + def test_minetypes(container: TrackedContainer) -> None: """Check if Rscript command for minetypes can be executed""" - logs=minetypes_check(container) - assert len(logs) == 0, f"Command R command failed" \ No newline at end of file + logs = minetypes_check(container) + assert len(logs) == 0, f"Command R command failed" diff --git a/tests/r-notebook/test_R_minetypes.py b/tests/r-notebook/test_R_minetypes.py index a17041a3ef..e8a7369fed 100644 --- a/tests/r-notebook/test_R_minetypes.py +++ b/tests/r-notebook/test_R_minetypes.py @@ -4,7 +4,8 @@ from tests.conftest import TrackedContainer from tests.R_minetype_check import minetypes_check + def test_minetypes(container: TrackedContainer) -> None: """Check if Rscript command for minetypes can be executed""" - logs=minetypes_check(container) - assert len(logs) == 0, f"Command R command failed" \ No newline at end of file + logs = minetypes_check(container) + assert len(logs) == 0, f"Command R command failed" From 60e7001f30a7bc90f49559aa293980b54c293f74 Mon Sep 17 00:00:00 2001 From: Darek Date: Thu, 18 Aug 2022 12:02:19 -0400 Subject: [PATCH 11/22] Fixing flake8 errors --- tests/R_minetype_check.py | 2 +- tests/datascience-notebook/test_R_minetypes.py | 2 +- tests/r-notebook/test_R_minetypes.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/R_minetype_check.py b/tests/R_minetype_check.py index 96640a6f74..166ab2bac3 100644 --- a/tests/R_minetype_check.py +++ b/tests/R_minetype_check.py @@ -10,7 +10,7 @@ def minetypes_check(container: TrackedContainer) -> None: """Check if Rscript command can be executed""" - LOGGER.info(f"Test that R command can be executed ...") + LOGGER.info("Test that R command can be executed ...") Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 3) {stop("missing jupyter.plot_mimetypes")}' logs = container.run_and_wait( timeout=60, diff --git a/tests/datascience-notebook/test_R_minetypes.py b/tests/datascience-notebook/test_R_minetypes.py index e8a7369fed..acd0ee004b 100644 --- a/tests/datascience-notebook/test_R_minetypes.py +++ b/tests/datascience-notebook/test_R_minetypes.py @@ -8,4 +8,4 @@ def test_minetypes(container: TrackedContainer) -> None: """Check if Rscript command for minetypes can be executed""" logs = minetypes_check(container) - assert len(logs) == 0, f"Command R command failed" + assert len(logs) == 0, "Command R command failed" diff --git a/tests/r-notebook/test_R_minetypes.py b/tests/r-notebook/test_R_minetypes.py index e8a7369fed..acd0ee004b 100644 --- a/tests/r-notebook/test_R_minetypes.py +++ b/tests/r-notebook/test_R_minetypes.py @@ -8,4 +8,4 @@ def test_minetypes(container: TrackedContainer) -> None: """Check if Rscript command for minetypes can be executed""" logs = minetypes_check(container) - assert len(logs) == 0, f"Command R command failed" + assert len(logs) == 0, "Command R command failed" From 9d946ecdefef0de836098fbace4193b3974a35c1 Mon Sep 17 00:00:00 2001 From: Darek Date: Thu, 18 Aug 2022 12:03:24 -0400 Subject: [PATCH 12/22] Update minimal-notebook/Dockerfile Co-authored-by: Ayaz Salikhov --- minimal-notebook/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minimal-notebook/Dockerfile b/minimal-notebook/Dockerfile index d685038320..e421750eee 100644 --- a/minimal-notebook/Dockerfile +++ b/minimal-notebook/Dockerfile @@ -39,5 +39,5 @@ RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10 # Switch back to jovyan to avoid accidental container runs as root USER ${NB_UID} -# Add R mimetype option to specifies how the plot returns from R to the browser +# 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/ From d773f50f593a24d3f0ba846a6da70204a5c2dde7 Mon Sep 17 00:00:00 2001 From: Darek Date: Thu, 18 Aug 2022 12:04:13 -0400 Subject: [PATCH 13/22] Update minimal-notebook/Rprofile.site Co-authored-by: Ayaz Salikhov --- minimal-notebook/Rprofile.site | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minimal-notebook/Rprofile.site b/minimal-notebook/Rprofile.site index 551e9aa0e8..51e0dc889d 100644 --- a/minimal-notebook/Rprofile.site +++ b/minimal-notebook/Rprofile.site @@ -1,5 +1,5 @@ -# Add mimetype to specifies how the plot returns from R to the browser. +# Add 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/svg+xml', 'application/pdf')) From 231ec60d76f3a08cd8eab0bf9e7d976b416f5924 Mon Sep 17 00:00:00 2001 From: Darek Date: Thu, 18 Aug 2022 12:06:47 -0400 Subject: [PATCH 14/22] Removing empty line --- minimal-notebook/Rprofile.site | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/minimal-notebook/Rprofile.site b/minimal-notebook/Rprofile.site index 51e0dc889d..4b287455de 100644 --- a/minimal-notebook/Rprofile.site +++ b/minimal-notebook/Rprofile.site @@ -1,5 +1,4 @@ - -# Add mimetype to specify how the plot returns from R to the browser. +# 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/svg+xml', 'application/pdf')) From 80de1936640c20fa09e1cecdaa66e7b2b5e2c27a Mon Sep 17 00:00:00 2001 From: Darek Date: Thu, 18 Aug 2022 12:18:04 -0400 Subject: [PATCH 15/22] Renaming minetypes to mimetypes --- tests/{R_minetype_check.py => R_mimetype_check.py} | 3 +-- tests/datascience-notebook/test_R_mimetypes.py | 11 +++++++++++ tests/datascience-notebook/test_R_minetypes.py | 11 ----------- tests/r-notebook/test_R_mimetypes.py | 11 +++++++++++ tests/r-notebook/test_R_minetypes.py | 11 ----------- 5 files changed, 23 insertions(+), 24 deletions(-) rename tests/{R_minetype_check.py => R_mimetype_check.py} (91%) create mode 100644 tests/datascience-notebook/test_R_mimetypes.py delete mode 100644 tests/datascience-notebook/test_R_minetypes.py create mode 100644 tests/r-notebook/test_R_mimetypes.py delete mode 100644 tests/r-notebook/test_R_minetypes.py diff --git a/tests/R_minetype_check.py b/tests/R_mimetype_check.py similarity index 91% rename from tests/R_minetype_check.py rename to tests/R_mimetype_check.py index 166ab2bac3..f525492a0e 100644 --- a/tests/R_minetype_check.py +++ b/tests/R_mimetype_check.py @@ -2,13 +2,12 @@ # Distributed under the terms of the Modified BSD License. import logging - from tests.conftest import TrackedContainer LOGGER = logging.getLogger(__name__) -def minetypes_check(container: TrackedContainer) -> None: +def mimetypes_check(container: TrackedContainer) -> str: """Check if Rscript command can be executed""" LOGGER.info("Test that R command can be executed ...") Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 3) {stop("missing jupyter.plot_mimetypes")}' diff --git a/tests/datascience-notebook/test_R_mimetypes.py b/tests/datascience-notebook/test_R_mimetypes.py new file mode 100644 index 0000000000..9438ff2b8e --- /dev/null +++ b/tests/datascience-notebook/test_R_mimetypes.py @@ -0,0 +1,11 @@ +# 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 mimetypes_check + + +def test_mimetypes(container: TrackedContainer) -> None: + """Check if Rscript command for mimetypes can be executed""" + logs = mimetypes_check(container) + assert len(logs) == 0, "Command R command failed" diff --git a/tests/datascience-notebook/test_R_minetypes.py b/tests/datascience-notebook/test_R_minetypes.py deleted file mode 100644 index acd0ee004b..0000000000 --- a/tests/datascience-notebook/test_R_minetypes.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -from tests.conftest import TrackedContainer -from tests.R_minetype_check import minetypes_check - - -def test_minetypes(container: TrackedContainer) -> None: - """Check if Rscript command for minetypes can be executed""" - logs = minetypes_check(container) - assert len(logs) == 0, "Command R command failed" diff --git a/tests/r-notebook/test_R_mimetypes.py b/tests/r-notebook/test_R_mimetypes.py new file mode 100644 index 0000000000..9438ff2b8e --- /dev/null +++ b/tests/r-notebook/test_R_mimetypes.py @@ -0,0 +1,11 @@ +# 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 mimetypes_check + + +def test_mimetypes(container: TrackedContainer) -> None: + """Check if Rscript command for mimetypes can be executed""" + logs = mimetypes_check(container) + assert len(logs) == 0, "Command R command failed" diff --git a/tests/r-notebook/test_R_minetypes.py b/tests/r-notebook/test_R_minetypes.py deleted file mode 100644 index acd0ee004b..0000000000 --- a/tests/r-notebook/test_R_minetypes.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -from tests.conftest import TrackedContainer -from tests.R_minetype_check import minetypes_check - - -def test_minetypes(container: TrackedContainer) -> None: - """Check if Rscript command for minetypes can be executed""" - logs = minetypes_check(container) - assert len(logs) == 0, "Command R command failed" From c27d085de0e766f032925a226a53579d4ad6d51a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Aug 2022 16:18:22 +0000 Subject: [PATCH 16/22] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/R_mimetype_check.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/R_mimetype_check.py b/tests/R_mimetype_check.py index f525492a0e..a749f712d9 100644 --- a/tests/R_mimetype_check.py +++ b/tests/R_mimetype_check.py @@ -2,6 +2,7 @@ # Distributed under the terms of the Modified BSD License. import logging + from tests.conftest import TrackedContainer LOGGER = logging.getLogger(__name__) From 722ef81be2609b70737201c879ecaab4d5919583 Mon Sep 17 00:00:00 2001 From: Darek Date: Fri, 19 Aug 2022 08:02:41 -0400 Subject: [PATCH 17/22] Renaming test module to avoid mypy error --- .../{test_R_mimetypes.py => test_mimetypes.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/datascience-notebook/{test_R_mimetypes.py => test_mimetypes.py} (100%) diff --git a/tests/datascience-notebook/test_R_mimetypes.py b/tests/datascience-notebook/test_mimetypes.py similarity index 100% rename from tests/datascience-notebook/test_R_mimetypes.py rename to tests/datascience-notebook/test_mimetypes.py From c3584cd61d6229205d9861c6f4b4a54b3831d54b Mon Sep 17 00:00:00 2001 From: Darek Date: Fri, 19 Aug 2022 08:13:17 -0400 Subject: [PATCH 18/22] Adding to jupyter.plot_mimetypes --- minimal-notebook/Rprofile.site | 2 +- tests/R_mimetype_check.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/minimal-notebook/Rprofile.site b/minimal-notebook/Rprofile.site index 4b287455de..3d6a93cc1f 100644 --- a/minimal-notebook/Rprofile.site +++ b/minimal-notebook/Rprofile.site @@ -1,4 +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/svg+xml', 'application/pdf')) +options(jupyter.plot_mimetypes = c('text/plain', 'image/png', 'image/jpeg', 'image/svg+xml', 'application/pdf')) diff --git a/tests/R_mimetype_check.py b/tests/R_mimetype_check.py index a749f712d9..7ffc4cac98 100644 --- a/tests/R_mimetype_check.py +++ b/tests/R_mimetype_check.py @@ -11,7 +11,7 @@ def mimetypes_check(container: TrackedContainer) -> str: """Check if Rscript command can be executed""" LOGGER.info("Test that R command can be executed ...") - Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 3) {stop("missing jupyter.plot_mimetypes")}' + Rcommand = 'if (length(getOption("jupyter.plot_mimetypes")) != 5) {stop("missing jupyter.plot_mimetypes")}' logs = container.run_and_wait( timeout=60, tty=True, From 01c85d142daa16da657d4b376afb5b902da12f76 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Sat, 20 Aug 2022 00:16:18 +0400 Subject: [PATCH 19/22] Update R_mimetype_check.py --- tests/R_mimetype_check.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/R_mimetype_check.py b/tests/R_mimetype_check.py index 7ffc4cac98..cc09d13423 100644 --- a/tests/R_mimetype_check.py +++ b/tests/R_mimetype_check.py @@ -8,16 +8,14 @@ LOGGER = logging.getLogger(__name__) -def mimetypes_check(container: TrackedContainer) -> str: +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=60, + timeout=10, tty=True, command=["Rscript", "-e", Rcommand], ) LOGGER.debug(f"{logs=}") assert len(logs) == 0, f"Command {Rcommand=} failed" - - return logs From da13813876fec4197d4a1aef8cdae1b82551e346 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Sat, 20 Aug 2022 00:16:50 +0400 Subject: [PATCH 20/22] Update test_mimetypes.py --- tests/datascience-notebook/test_mimetypes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/datascience-notebook/test_mimetypes.py b/tests/datascience-notebook/test_mimetypes.py index 9438ff2b8e..a2ac55cf06 100644 --- a/tests/datascience-notebook/test_mimetypes.py +++ b/tests/datascience-notebook/test_mimetypes.py @@ -2,10 +2,9 @@ # Distributed under the terms of the Modified BSD License. from tests.conftest import TrackedContainer -from tests.R_mimetype_check import mimetypes_check +from tests.R_mimetype_check import check_r_mimetypes def test_mimetypes(container: TrackedContainer) -> None: """Check if Rscript command for mimetypes can be executed""" - logs = mimetypes_check(container) - assert len(logs) == 0, "Command R command failed" + check_r_mimetypes(container) From d4d054ca267a7b51794928e4dbc4813b1f8cc08b Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Sat, 20 Aug 2022 00:17:19 +0400 Subject: [PATCH 21/22] Update test_R_mimetypes.py --- tests/r-notebook/test_R_mimetypes.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/r-notebook/test_R_mimetypes.py b/tests/r-notebook/test_R_mimetypes.py index 9438ff2b8e..361cb2c4f1 100644 --- a/tests/r-notebook/test_R_mimetypes.py +++ b/tests/r-notebook/test_R_mimetypes.py @@ -2,10 +2,9 @@ # Distributed under the terms of the Modified BSD License. from tests.conftest import TrackedContainer -from tests.R_mimetype_check import mimetypes_check +from tests.R_mimetype_check import check_r_mimetypes -def test_mimetypes(container: TrackedContainer) -> None: +def check_r_mimetypes(container: TrackedContainer) -> None: """Check if Rscript command for mimetypes can be executed""" - logs = mimetypes_check(container) - assert len(logs) == 0, "Command R command failed" + check_r_mimetypes(container) From 45f1a7ca787d3152343827e7474773dd4f45ad16 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Sat, 20 Aug 2022 00:18:35 +0400 Subject: [PATCH 22/22] Update test_R_mimetypes.py --- tests/r-notebook/test_R_mimetypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/r-notebook/test_R_mimetypes.py b/tests/r-notebook/test_R_mimetypes.py index 361cb2c4f1..a2ac55cf06 100644 --- a/tests/r-notebook/test_R_mimetypes.py +++ b/tests/r-notebook/test_R_mimetypes.py @@ -5,6 +5,6 @@ from tests.R_mimetype_check import check_r_mimetypes -def check_r_mimetypes(container: TrackedContainer) -> None: +def test_mimetypes(container: TrackedContainer) -> None: """Check if Rscript command for mimetypes can be executed""" check_r_mimetypes(container)