From ce817e0922922ba681ae6611186143f6927a52f1 Mon Sep 17 00:00:00 2001 From: vkumra-broad Date: Mon, 17 Sep 2018 10:28:39 -0400 Subject: [PATCH] install Ronaldo on jupyter docker, add automation test and include example use case (#575) --- .../leonardo/NotebookRKernelSpec.scala | 7 +++ example-notebooks/RonaldoExample.ipynb | 61 +++++++++++++++++++ jupyter-docker/Dockerfile | 1 + 3 files changed, 69 insertions(+) create mode 100644 example-notebooks/RonaldoExample.ipynb diff --git a/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/NotebookRKernelSpec.scala b/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/NotebookRKernelSpec.scala index e4ac85423a8..ef7bb22a5fc 100644 --- a/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/NotebookRKernelSpec.scala +++ b/automation/src/test/scala/org/broadinstitute/dsde/workbench/leonardo/NotebookRKernelSpec.scala @@ -111,6 +111,13 @@ class NotebookRKernelSpec extends ClusterFixtureSpec { } } + "should have Ronaldo automatically installed" in { clusterFixture => + withWebDriver { implicit driver => + withNewNotebook(clusterFixture.cluster, RKernel) { notebookPage => + notebookPage.executeCell(""""Ronaldo" %in% installed.packages()""") shouldBe Some("TRUE") + } + } + } } } diff --git a/example-notebooks/RonaldoExample.ipynb b/example-notebooks/RonaldoExample.ipynb new file mode 100644 index 00000000000..816a9292e43 --- /dev/null +++ b/example-notebooks/RonaldoExample.ipynb @@ -0,0 +1,61 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This notebook shows how the Ronaldo package can be use to get the service account key for the Leonardo user. The getServiceAccountKey function uses SAM to get the key for the service account associated with the user." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "key <- Ronaldo::getServiceAccountKey()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This key can be used to access resources associated with the Leonardo notebook user. In this example we can use the key to access bigquery data. The following command sets the service token which configures the bigquery library to access data that is available to the user." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "library(bigrquery)\n", + "set_service_token(key)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.4.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/jupyter-docker/Dockerfile b/jupyter-docker/Dockerfile index 36f80bba428..65e285d62a8 100644 --- a/jupyter-docker/Dockerfile +++ b/jupyter-docker/Dockerfile @@ -233,6 +233,7 @@ RUN R -e 'install.packages(c( \ "bigrquery", \ "tidyverse"), \ repos="http://cran.mtu.edu")' \ + && R -e 'devtools::install_github("DataBiosphere/Ronaldo")' \ && R -e 'devtools::install_github("IRkernel/IRkernel")' \ && R -e 'IRkernel::installspec(user=FALSE)' \ && chown -R $USER:users /home/jupyter-user/.local \