Skip to content

Commit

Permalink
JupyterHub config for LROSE AMS 2023 workshop
Browse files Browse the repository at this point in the history
  • Loading branch information
julienchastang committed Dec 26, 2022
1 parent 60711a2 commit ec58d58
Show file tree
Hide file tree
Showing 9 changed files with 289 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jupyter-images/cu-fall-2022/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ ingress:
secretName: certmanager-tls-jupyterhub

singleuser:
extraEnv:
NBGITPULLER_DEPTH: "0"
storage:
capacity: 10Gi
startTimeout: 600
Expand Down
14 changes: 14 additions & 0 deletions jupyter-images/lrose-ams-2023/.bashrc
Original file line number Diff line number Diff line change
@@ -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


2 changes: 2 additions & 0 deletions jupyter-images/lrose-ams-2023/.condarc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
envs_dirs:
- /home/jovyan/my-conda-envs
6 changes: 6 additions & 0 deletions jupyter-images/lrose-ams-2023/.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
43 changes: 43 additions & 0 deletions jupyter-images/lrose-ams-2023/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"

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}"
15 changes: 15 additions & 0 deletions jupyter-images/lrose-ams-2023/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: lrose-ams-2023
channels:
- conda-forge
dependencies:
- numpy
# - matplotlib
- cartopy
- arm_pyart
- metpy
# - siphon
# - pip
- xarray
# - ipywidgets
- jupyter
- jupyterlab
13 changes: 13 additions & 0 deletions jupyter-images/lrose-ams-2023/readme.md
Original file line number Diff line number Diff line change
@@ -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.
61 changes: 61 additions & 0 deletions jupyter-images/lrose-ams-2023/secrets.yaml
Original file line number Diff line number Diff line change
@@ -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;
133 changes: 133 additions & 0 deletions jupyter-images/lrose-ams-2023/update_workshop_material.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<a name=\"top\"></a>\n",
"<div style=\"width:1000 px\">\n",
"\n",
"<div style=\"float:right; width:98 px; height:98px;\">\n",
"<img src=\"https://gateway.lrose.net/media/images/Screen_Shot_2020-09-16_at_2.55.39_PM.original.png\" alt=\"Unidata Logo\" style=\"height: 98px;\">\n",
"</div>\n",
"\n",
"<h1>Update Workshop Material</h1>\n",
"<h3>LROSE AMS 2023 Workshop</h3>\n",
"\n",
"<div style=\"clear:both\"></div>\n",
"</div>\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 [email protected] -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 [email protected] -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 [email protected] -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
}

0 comments on commit ec58d58

Please sign in to comment.