Skip to content
Snippets Groups Projects
Commit a430b8e6 authored by Christian Rohlfing's avatar Christian Rohlfing
Browse files

- init

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #281482 failed
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Jupyter
.ipynb_checkpoints
image: docker:19.03.1
services:
- docker:19.03.1-dind
stages:
- build
- test
- release
variables:
GIT_SUBMODULE_STRATEGY: recursive
DOCKER_HOST: tcp://docker:2376 # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_TLS_CERTDIR: "/certs"
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build-docker:
stage: build
script:
- docker pull $CONTAINER_TEST_IMAGE || true
- docker build --cache-from $CONTAINER_TEST_IMAGE --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CONTAINER_TEST_IMAGE .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker push $CONTAINER_TEST_IMAGE
only:
- master
only:
changes:
- Dockerfile
build-binder:
stage: build
script:
# Use Binder build API to trigger repo2docker to build image on GKE and OVH Binder Federation clusters
- ls
- apk update && apk add curl
- chmod +x .gitlab-ci_trigger-binder.sh
- .gitlab-ci_trigger-binder.sh https://mybinder.org/build/git/https%3A%2F%2Fgit.rwth-aachen.de%2FIENT%2Fjupyter-quickstart/master
- .gitlab-ci_trigger-binder.sh https://gke.mybinder.org/build/git/https%3A%2F%2Fgit.rwth-aachen.de%2FIENT%2Fjupyter-quickstart/master
- .gitlab-ci_trigger-binder.sh https://ovh.mybinder.org/build/git/https%3A%2F%2Fgit.rwth-aachen.de%2FIENT%2Fjupyter-quickstart/master
- ls
only:
- master
test-docker:
stage: test
script:
- docker pull $CONTAINER_TEST_IMAGE
only:
- master
only:
changes:
- Dockerfile
release-docker:
stage: release
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master
only:
changes:
- Dockerfile
\ No newline at end of file
#!/bin/sh
function trigger_binder() {
local URL="${1}"
curl -L --connect-timeout 10 --max-time 30 "${URL}"
curl_return=$?
# Return code 28 is when the --max-time is reached
if [ "${curl_return}" -eq 0 ] || [ "${curl_return}" -eq 28 ]; then
if [[ "${curl_return}" -eq 28 ]]; then
printf "\nBinder build started.\nCheck back soon.\n"
fi
else
return "${curl_return}"
fi
return 0
}
function main() {
# 1: the Binder build API URL to curl
trigger_binder $1
}
main "$@" || exit 1
ARG BASE_IMAGE=registry.git.rwth-aachen.de/acs/cloud/jupyter/singleuser/python:latest
FROM ${BASE_IMAGE}
# update conda base environment to match specifications in environment.yml
ADD environment.yml /tmp/environment.yml
USER root
RUN sed -i "s|name\: jupyter-quickstart|name\: base|g" /tmp/environment.yml # we need to replace the name of the environment with base such that we can update the base environment here
USER $NB_USER
RUN cat /tmp/environment.yml
RUN conda env update -f /tmp/environment.yml
# cleanup conda packages
RUN conda clean --all -f -y
# install some extensions defined in binder postBuild
ADD postBuild /tmp/postBuild.sh
USER root
RUN chmod +x /tmp/postBuild.sh
USER $NB_USER
RUN /tmp/postBuild.sh
# Copy workspace
COPY ./ /home/jovyan
%% Cell type:markdown id: tags:
![RWTH Logo](https://www.rwth-aachen.de/global/show_picture.asp?id=aaaaaaaaaaagazb)
# Jupyter Quickstart
Welcome to JupyterLab!
* Execute a single cell: <span class="fa-play fa"></span>
* Execute all cells: Menu: Run <span class="fa-chevron-right fa"></span> Run All Cells
* To reboot kernel: <span class="fa-refresh fa"></span>
Find more in the reference (menu: Help <span class="fa-chevron-right fa"></span> Jupyter Reference).
%% Cell type:markdown id: tags:
## Markdown
You can specify the cell type which is either _Code_ or _Markdown_.
### Lists
* Like
* this
1. We can even nest them like
2. this!
* Isn't that wonderfull?
### Images
![Newtons cradle](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Newtons_cradle_animation_book_2.gif/200px-Newtons_cradle_animation_book_2.gif)
### LaTeX equations
$$\mathrm{e}^{\mathrm{j} x} = \cos(x)+\mathrm{j}\sin(x)$$
### Code
``` python
print("Hello world!")
```
### Further reading
Read more in the reference (menu: Help <span class="fa-chevron-right fa"></span> Markdown Reference).
%% Cell type:markdown id: tags:
## Python
%% Cell type:code id: tags:
``` python
print("Hello world!")
```
%% Cell type:markdown id: tags:
## numpy
Execute the cell below to see the contents of variable `a`
%% Cell type:code id: tags:
``` python
import numpy as np
a = np.array([0, 1, -5])
a
```
%% Cell type:markdown id: tags:
## Plots with matplotlib
Nice matplotlib [tutorial](https://matplotlib.org/tutorials/introductory/usage.html#sphx-glr-tutorials-introductory-usage-py)
%% Cell type:code id: tags:
``` python
%matplotlib widget
import matplotlib.pyplot as plt
from rwth_colors_matplotlib import *
fs = 44100;
(t, deltat) = np.linspace(-10, 10, 20*fs, retstep=True) # t axis in seconds
fig,ax = plt.subplots(); ax.grid();
ax.plot(t, np.sin(2*np.pi*t), 'rwth:blue')
ax.set_xlabel(r'$t$'); ax.set_ylabel(r'$s(t) = \sin(2 \pi t)$');
```
%% Cell type:code id: tags:
``` python
from scipy import misc
f = misc.face()
fig,ax = plt.subplots();
ax.imshow(f);
```
%% Cell type:markdown id: tags:
## Interactive Widgets
Jupyter Widgets. You can find a detailled widget list [here](https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html).
This requires to install [Jupyter Matplotlib](https://github.com/matplotlib/jupyter-matplotlib) which is called with the `%matplotlib widget` magic.
Uses Python [decorators](https://docs.python.org/3/glossary.html#term-decorator).
%% Cell type:code id: tags:
``` python
import ipywidgets as widgets
# Create figure
fig0, ax0 = plt.subplots();
# Create update function and decorate them with widgets
@widgets.interact(F = widgets.FloatSlider(min=0.1, max=10, step=0.1, value=0, description='$F$:'))
def update_plot(F):
# Generate signal with given F
s = np.sin(2*np.pi*F*t)
# Plot
if not ax0.lines: # decorate axes with labels etc. (which is only needed once)
ax0.plot(t, s, 'rwth:blue');
ax0.set_xlabel(r'$t$'); ax.set_ylabel(r'$s(t)=\sin(2 \pi F t)$')
else: # update only lines and leave everything else as is (gives huge speed-up)
ax0.lines[0].set_ydata(s)
```
%% Cell type:markdown id: tags:
## Audio
%% Cell type:code id: tags:
``` python
from IPython.display import Audio, Latex
def audio_play(s, fs, txt="", autoplay=False):
if txt: display(Latex(txt))
display(Audio(s, rate=fs, autoplay=autoplay))
# Create sin
s = np.sin(2*np.pi*440*t)
# Play back
audio_play(s, fs, r'$s(t)$')
```
%% Cell type:markdown id: tags:
## RWTH Colors
%% Cell type:code id: tags:
``` python
from rwth_colors_matplotlib import *
# adapted from https://matplotlib.org/2.0.0/examples/color/named_colors.html
colors = rwth_colors;
ncols = 5; nrows = len(colors.keys()) // ncols + 1;
fig, ax = plt.subplots()
X, Y = fig.get_dpi() * fig.get_size_inches() # Get height and width
w = X / ncols; h = Y / (nrows + 1)
for i, name in enumerate(colors.keys()):
col = i % ncols
row = i // ncols
y = Y - (row * h) - h
xi_line = w * (col + 0.05); xf_line = w * (col + 0.25); xi_text = w * (col + 0.3)
ax.text(xi_text, y, name, fontsize=10, horizontalalignment='left', verticalalignment='center')
ax.hlines(y + h * 0.1, xi_line, xf_line, color=colors[name], linewidth=(h * 0.6))
ax.set_xlim(0, X); ax.set_ylim(0, Y); ax.set_axis_off();
fig.subplots_adjust(left=0, right=1, top=1, bottom=0, hspace=0, wspace=0)
```
%% Cell type:markdown id: tags:
## Magic
%% Cell type:code id: tags:
``` python
%%svg
<svg width='300px' height='300px'>
<title>Small SVG example</title>
<circle cx='120' cy='150' r='60' style='fill: gold;'>
<animate attributeName='r' from='2' to='80' begin='0'
dur='3' repeatCount='indefinite' /></circle>
<polyline points='120 30, 25 150, 290 150'
stroke-width='4' stroke='brown' style='fill: none;' />
<polygon points='210 100, 210 200, 270 150'
style='fill: lawngreen;' />
<text x='60' y='250' fill='blue'>Hello, World!</text>
</svg>
```
<img align="right" src="https://git.rwth-aachen.de/IENT/jupyter-quickstart/raw/master/figures/rwth_ient_logo@2x.png" alt="Logo Institut für Nachrichtentechnik | RWTH Aachen University" width="240px">
# Jupyter Quickstart
## Introduction
This repository contains of some getting-started Jupyter notebooks.
Run the notebooks directly online [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/git/https%3A%2F%2Fgit.rwth-aachen.de%2FIENT%2Fjupyter-quickstart/master?urlpath=lab/tree/index.ipynb) (the starting process of the session may take up to one minute).
## Installation on RWTH Jupyter Server
TBD
## Docker
For advanced users only: If you happen to have Docker installed, you can start a local dockerized JupyterLab with enabled GDET3-Demos with
```bash
docker run --name='jupyter-quickstart' --rm -it -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes registry.git.rwth-aachen.de/ient/jupyter-quickstart:master
```
Copy and paste the displayed link to your favorite browser.
## Local Installation
To run the notebooks on your local machine, you may use [Anaconda](https://www.anaconda.com/) (using `pip` is also possible for experienced users. You have to install all the requirements listed in `environment.yml` and install the commands listed in `postBuild`).
* Install [Anaconda](https://www.anaconda.com/).
* Download this repository to your local disk. You can download it as a zip-File or use `git`:
```bash
git clone --recurse-submodules git@git.rwth-aachen.de:IENT/jupyter-quickstart.git
```
* It is highly recommended to run the notebooks in an isolated Anaconda environment. You can create a new environment called `jupyter-quickstart` from the provided `environment.yml` by running the following command in the Anaconda prompt
```bash
conda env create -f environment.yml
```
This makes sure that all required packages are installed amd don't interfere with the packages in your base environment.
* Activate this environment with
```bash
conda activate jupyter-quickstart
```
* Run two final commands in the Anaconda prompt (with activated `jupyter-quickstart` environment):
```bash
chmod +x postBuild
postBuild
```
If the latter command fails, please open `postBuild` and execute the commands listed there manually.
## Local Run
* Activate the environment with `conda activate jupyter-quickstart`.
* Run JupyterLab `jupyter lab`. In your browser, JupyterLab should start. You can then open `index.ipynb` for an overview over all notebooks.
* You can deactivate the environment with `conda deactivate`.
## Contact
* If you found a bug, please use the [issue tracker](https://git.rwth-aachen.de/IENT/jupyter-quickstart/issues).
* In all other cases, please contact [Christian Rohlfing](http://www.ient.rwth-aachen.de/cms/c_rohlfing/).
The code is licensed under the [MIT license](https://opensource.org/licenses/MIT).
name: jupyter-quickstart
channels:
- conda-forge
dependencies:
- numpy=1.16.4
- scipy=1.3.1
- matplotlib=3.1.1
- jupyterlab=1.0.9
- nodejs=12.8.1
- ipympl=0.3.3
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib
\ No newline at end of file
import matplotlib.colors as mcolors
# RWTH Colors
rwth_colors = {
'blue': '#00549F',
'blue-75': '#407FB7',
'blue-50': '#8EBAE5',
'blue-25': '#C7DDF2',
'blue-10': '#E8F1FA',
'black': '#000000',
'black-75': '#646567',
'black-50': '#9C9E9F',
'black-25': '#CFD1D2',
'black-10': '#ECEDED',
'magenta': '#E30066',
'magenta-75': '#E96088',
'magenta-50': '#F19EB1',
'magenta-25': '#F9D2DA',
'magenta-10': '#FDEEF0',
'yellow': '#FFED00',
'yellow-75': '#FFF055',
'yellow-50': '#FFF59B',
'yellow-25': '#FFFAD1',
'yellow-10': '#FFFDEE',
'petrol': '#006165',
'petrol-75': '#2D7F83',
'petrol-50': '#7DA4A7',
'petrol-25': '#BFD0D1',
'petrol-10': '#E6ECEC',
'turquoise': '#0098A1',
'turquoise-75': '#00B1B7',
'turquoise-50': '#89CCCF',
'turquoise-25': '#CAE7E7',
'turquoise-10': '#EBF6F6',
'green': '#57AB27',
'green-75': '#8DC060',
'green-50': '#B8D698',
'green-25': '#DDEBCE',
'green-10': '#F2F7EC',
'maigrun': '#BDCD00',
'maigrun-75': '#D0D95C',
'maigrun-50': '#E0E69A',
'maigrun-25': '#F0F3D0',
'maigrun-10': '#F9FAED',
'orange': '#F6A800',
'orange-75': '#FABE50',
'orange-50': '#FDD48F',
'orange-25': '#FEEAC9',
'orange-10': '#FFF7EA',
'red': '#CC071E',
'red-75': '#D85C41',
'red-50': '#E69679',
'red-25': '#F3CDBB',
'red-10': '#FAEBE3',
'bordeaux': '#A11035',
'bordeaux-75': '#B65256',
'bordeaux-50': '#CD8B87',
'bordeaux-25': '#E5C5C0',
'bordeaux-10': '#F5E8E5',
'violet': '#612158',
'violet-75': '#834E75',
'violet-50': '#A8859E',
'violet-25': '#D2C0CD',
'violet-10': '#EDE5EA',
'purple': '#7A6FAC',
'purple-75': '#9B91C1',
'purple-50': '#BCB5D7',
'purple-25': '#DEDAEB',
'purple-10': '#F2F0F7',
}
# Append prefix
rwth_colors = {'rwth:' + name: value for name, value in rwth_colors.items()}
# Propagate rwth_colors to default matplotlib colors
mcolors.get_named_colors_mapping().update(rwth_colors)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment