From ec58d58320210440219c9a8e0758dd997bad8c6f Mon Sep 17 00:00:00 2001 From: Julien Chastang Date: Wed, 9 Nov 2022 13:53:13 -0700 Subject: [PATCH] JupyterHub config for LROSE AMS 2023 workshop --- jupyter-images/cu-fall-2022/secrets.yaml | 2 + jupyter-images/lrose-ams-2023/.bashrc | 14 ++ jupyter-images/lrose-ams-2023/.condarc | 2 + jupyter-images/lrose-ams-2023/.profile | 6 + jupyter-images/lrose-ams-2023/Dockerfile | 43 ++++++ jupyter-images/lrose-ams-2023/environment.yml | 15 ++ jupyter-images/lrose-ams-2023/readme.md | 13 ++ jupyter-images/lrose-ams-2023/secrets.yaml | 61 ++++++++ .../update_workshop_material.ipynb | 133 ++++++++++++++++++ 9 files changed, 289 insertions(+) create mode 100644 jupyter-images/lrose-ams-2023/.bashrc create mode 100644 jupyter-images/lrose-ams-2023/.condarc create mode 100644 jupyter-images/lrose-ams-2023/.profile create mode 100644 jupyter-images/lrose-ams-2023/Dockerfile create mode 100644 jupyter-images/lrose-ams-2023/environment.yml create mode 100644 jupyter-images/lrose-ams-2023/readme.md create mode 100644 jupyter-images/lrose-ams-2023/secrets.yaml create mode 100644 jupyter-images/lrose-ams-2023/update_workshop_material.ipynb diff --git a/jupyter-images/cu-fall-2022/secrets.yaml b/jupyter-images/cu-fall-2022/secrets.yaml index 6c0545d6..39f26ef6 100644 --- a/jupyter-images/cu-fall-2022/secrets.yaml +++ b/jupyter-images/cu-fall-2022/secrets.yaml @@ -31,6 +31,8 @@ ingress: secretName: certmanager-tls-jupyterhub singleuser: + extraEnv: + NBGITPULLER_DEPTH: "0" storage: capacity: 10Gi startTimeout: 600 diff --git a/jupyter-images/lrose-ams-2023/.bashrc b/jupyter-images/lrose-ams-2023/.bashrc new file mode 100644 index 00000000..31dd33f7 --- /dev/null +++ b/jupyter-images/lrose-ams-2023/.bashrc @@ -0,0 +1,14 @@ +export CLICOLOR=1 +export LANG="en_US.UTF-8" + +alias rm="rm -i" +alias mv="mv -i" +alias cp="cp -i" + +alias ll="ls -alh" + +export PATH=/usr/local/lrose/bin:$PATH + +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lrose/lib + + diff --git a/jupyter-images/lrose-ams-2023/.condarc b/jupyter-images/lrose-ams-2023/.condarc new file mode 100644 index 00000000..4c60048a --- /dev/null +++ b/jupyter-images/lrose-ams-2023/.condarc @@ -0,0 +1,2 @@ +envs_dirs: + - /home/jovyan/my-conda-envs diff --git a/jupyter-images/lrose-ams-2023/.profile b/jupyter-images/lrose-ams-2023/.profile new file mode 100644 index 00000000..35e8d01f --- /dev/null +++ b/jupyter-images/lrose-ams-2023/.profile @@ -0,0 +1,6 @@ +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi diff --git a/jupyter-images/lrose-ams-2023/Dockerfile b/jupyter-images/lrose-ams-2023/Dockerfile new file mode 100644 index 00000000..74364b46 --- /dev/null +++ b/jupyter-images/lrose-ams-2023/Dockerfile @@ -0,0 +1,43 @@ +# Heavily borrowed from docker-stacks/scipy-notebook/ +# https://github.com/jupyter/docker-stacks/blob/master/scipy-notebook/Dockerfile + +ARG BASE_CONTAINER=jupyter/minimal-notebook:ubuntu-20.04 +FROM $BASE_CONTAINER + +LABEL maintainer="Unidata " + +USER root + +RUN apt-get update --yes && \ + apt-get install --yes --no-install-recommends \ + build-essential \ + vim \ + emacs \ + curl && \ + wget \ + https://github.com/NCAR/lrose-core/releases/download/lrose-core-20220222/lrose-core-20220222.ubuntu_20.04.amd64.deb -P /tmp && \ + apt-get install -y /tmp/lrose-core-20220222.ubuntu_20.04.amd64.deb && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +USER ${NB_UID} + +ADD environment.yml /tmp + +RUN conda update conda && \ + conda install --quiet --yes \ + 'conda-forge::nb_conda_kernels' && \ + conda env update --name lrose-ams-2023 -f /tmp/environment.yml && \ + pip install --no-cache-dir nbgitpuller && \ + conda clean --all -f -y && \ + fix-permissions "${CONDA_DIR}" && \ + fix-permissions "/home/${NB_USER}" + +COPY update_workshop_material.ipynb / +COPY Acknowledgements.ipynb / +COPY .condarc / +COPY .bashrc / +COPY .profile / + +USER ${NB_UID} + +WORKDIR "${HOME}" diff --git a/jupyter-images/lrose-ams-2023/environment.yml b/jupyter-images/lrose-ams-2023/environment.yml new file mode 100644 index 00000000..3f470bc1 --- /dev/null +++ b/jupyter-images/lrose-ams-2023/environment.yml @@ -0,0 +1,15 @@ + name: lrose-ams-2023 + channels: + - conda-forge + dependencies: + - numpy + # - matplotlib + - cartopy + - arm_pyart + - metpy + # - siphon + # - pip + - xarray + # - ipywidgets + - jupyter + - jupyterlab diff --git a/jupyter-images/lrose-ams-2023/readme.md b/jupyter-images/lrose-ams-2023/readme.md new file mode 100644 index 00000000..cb879a5b --- /dev/null +++ b/jupyter-images/lrose-ams-2023/readme.md @@ -0,0 +1,13 @@ +# JupyterHub Configuration for AMS 2023 LROSE Workshop + +A few notes on this configuration: + +- `environment.yml` can be found here and is not fetched from some external source. +- The LROSE team required that various command line utilities be installed so you will find those referenced inside the `Dockerfile`. +- `secrets.yaml` contains the JupyterHub configuration with the exception of + - secret or unique identifiers + - user names + - admins + - docker image tags + +Copy `Acknowledgements.ipynb`, required for the Docker build, from the parent directory to this directory. For some reason, Docker builds do not let you copy files from parent directories. diff --git a/jupyter-images/lrose-ams-2023/secrets.yaml b/jupyter-images/lrose-ams-2023/secrets.yaml new file mode 100644 index 00000000..d0127bcd --- /dev/null +++ b/jupyter-images/lrose-ams-2023/secrets.yaml @@ -0,0 +1,61 @@ +hub: + cookieSecret: "xxx" + config: + Authenticator: + admin_users: + - admin + allowed_users: + - user + GitHubOAuthenticator: + client_id: "xxx" + client_secret: "xxx" + oauth_callback_url: "https://lros23s-1.tg-ees220002.projects.jetstream-cloud.org:443/oauth_callback" + JupyterHub: + authenticator_class: github + +proxy: + secretToken: "xxx" + +ingress: + enabled: true + annotations: + kubernetes.io/ingress.class: "nginx" + cert-manager.io/cluster-issuer: "letsencrypt" + # cert-manager.io/issuer: "letsencrypt" + nginx.ingress.kubernetes.io/proxy-body-size: 300m + hosts: + - lros23s-1.tg-ees220002.projects.jetstream-cloud.org + tls: + - hosts: + - lros23s-1.tg-ees220002.projects.jetstream-cloud.org + secretName: certmanager-tls-jupyterhub + +singleuser: + extraEnv: + NBGITPULLER_DEPTH: "0" + storage: + capacity: 10Gi + startTimeout: 600 + memory: + guarantee: 4G + limit: 4G + cpu: + guarantee: 1 + limit: 2 + defaultUrl: "/lab" + image: + name: unidata/lrose-ams-2023 + tag: "xxx" + lifecycleHooks: + postStart: + exec: + command: + - "sh" + - "-c" + - > + gitpuller https://github.com/nsf-lrose/ams2023 main ams2023; + cp /update_workshop_material.ipynb /home/jovyan; + cp /Acknowledgements.ipynb /home/jovyan; + cp /.condarc /home/jovyan; + cp -n /.bashrc /home/jovyan; + cp -n /.profile /home/jovyan; diff --git a/jupyter-images/lrose-ams-2023/update_workshop_material.ipynb b/jupyter-images/lrose-ams-2023/update_workshop_material.ipynb new file mode 100644 index 00000000..41a354a3 --- /dev/null +++ b/jupyter-images/lrose-ams-2023/update_workshop_material.ipynb @@ -0,0 +1,133 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "
\n", + "\n", + "
\n", + "\"Unidata\n", + "
\n", + "\n", + "

Update Workshop Material

\n", + "

LROSE AMS 2023 Workshop

\n", + "\n", + "
\n", + "
\n", + "\n", + "---\n", + "\n", + "This notebook can be used to update the workshop training material whenever updates are posted.\n", + "\n", + "---\n", + "\n", + "## Running the Update\n", + "\n", + "When you run the following cell, any changes from the workshop GitHub repository will be applied to the material under the `ams2023/` directory in your workspace.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "$ git fetch\n", + "\n", + "$ git reset --mixed\n", + "\n", + "$ git -c user.email=nbgitpuller@nbgitpuller.link -c user.name=nbgitpuller merge -Xours origin/main\n", + "\n", + "Already up to date.\n", + "\n" + ] + } + ], + "source": [ + "!gitpuller https://github.com/nsf-lrose/ams2023 main ams2023" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "---\n", + "\n", + "## What to expect?\n", + "\n", + "If there are no updates to the material, the output from the cell will look something like the following:\n", + "\n", + "~~~bash\n", + "\n", + "$ git fetch\n", + "\n", + "$ git reset --mixed\n", + "\n", + "$ git -c user.email=nbgitpuller@nbgitpuller.link -c user.name=nbgitpuller merge -Xours origin/main\n", + "\n", + "Already up to date.\n", + "\n", + "~~~\n", + "\n", + "If there are updates to the material, the output will look something like this:\n", + "\n", + "~~~bash\n", + "\n", + "$ git fetch\n", + "\n", + "$ git reset --mixed\n", + "\n", + "$ git -c user.email=nbgitpuller@nbgitpuller.link -c user.name=nbgitpuller merge -Xours origin/main\n", + "\n", + "Updating 7a12da2..894542f\n", + "\n", + "Fast-forward\n", + "\n", + " README.md | 10 +\n", + "\n", + " images/LROSE_logo_small.png | Bin 0 -> 518397 bytes\n", + "\n", + " images/erad2022_cidd_mosaic.png | Bin 0 -> 45254 bytes\n", + "\n", + " params/RadxRate.nexrad | 6 +-\n", + "\n", + " params/old/Ecco.mrms_taiwan | 777 +++++++++\n", + "\n", + " params/old/Ecco.nexrad_mosaic | 777 +++++++++\n", + " \n", + " ~~~\n", + "\n", + "That's it!\n", + "Now you have the latest and greatest material for the workshop." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}