Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • image
  • notebooks
2 results

Target

Select target project
  • acs/public/teaching/slew/slew-jupyter-profile
  • upasana1993pal31may/iambanalyses
  • hristo.vassilev/2-d-3-d
  • Arnd2/itsd-demo
  • andrea.hanke/datenverarbeitung-ii
  • inda/innda
  • felix.schwinger/ifo-m-2022-profile
  • john.arnold/cos-3-a-uebung
  • alexander.bonkowski/physchem-ii
  • jupyter/example-profile
  • johanna.ochs/example-profile
  • fibis/example-profile
  • ChristophGuenther/example-profile
  • annabell.brocker/example-profile
  • yanik.soeltzer/example-profile
  • henrik.hose/example-profile
  • christoph.weyer/example-profile
  • jakob-beetz/ifcopenshell-jupyter-profile
  • rohlfing/example-profile
  • noemi.kremer/example-profile
  • maximilian.vitz/jupyter-profile
  • japhba/edyn
  • ulf.liebal/iambanalyses
  • john.arnold/cos-3-a-uebung-showcase
  • steffen.kortmann/multi-energy-systems
  • hristo.vassilev/ml4ce-env
  • felix.gaumnitz/multi-energy-systems
  • jakob-beetz/bim-programming-2023
  • Christoph.Bannwarth/cos-3-a-uebung
  • aev-lectures/digitalization-of-energy-distribution-grids
  • joneschakk/example-profile-test-copy
  • thilo.birkenfeld/ex-phys-3
  • philipp.soldin/experimentalphysik-4-excercises
  • unruh/jupyter-intro-qc
  • kjlehmann/fb-bio-bioinformatics-course
  • mlcg/teaching/binf24
  • jens.brandt/jupyter-profile-oscar
  • yousseftarek12.yt/innda
  • lars.goettgens/jupyter-profile-oscar
  • mlcg/bioinfo-workshop
40 results
Select Git revision
  • blup
  • master
2 results
Show changes
Commits on Source (5)
......@@ -7,3 +7,7 @@ __pycache__/
# Jupyter
.ipynb_checkpoints
*~
......@@ -16,5 +16,5 @@ build:
- docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
- docker push ${CI_REGISTRY_IMAGE}:latest
only:
- master
- image
# Specify parent image. Please select a fixed tag here.
ARG BASE_IMAGE=registry.git.rwth-aachen.de/jupyter/profiles/rwth-courses:latest
FROM ${BASE_IMAGE}
# Install packages via requirements.txt
ADD requirements.txt .
RUN pip install -r requirements.txt
ARG conda_env=python3
ARG py_ver=3.12
ARG disp_name="Python 3 (ipykernel)"
USER root
RUN apt update && apt install -y poppler-utils && apt clean
USER jovyan
RUN mamba create --yes -p "${CONDA_DIR}/envs/${conda_env}" python=${py_ver} ipython ipykernel && mamba clean --all -f -y
# .. Or update conda base environment to match specifications in environment.yml
ADD environment.yml /tmp/environment.yml
RUN "${CONDA_DIR}/envs/${conda_env}/bin/python" -m ipykernel install --prefix=${CONDA_DIR} --name="${conda_env}" --display-name "${disp_name}" && fix-permissions "${CONDA_DIR}" && fix-permissions "/home/${NB_USER}"
ADD requirements.txt .
RUN "${CONDA_DIR}/envs/${conda_env}/bin/pip" install --no-cache-dir -r requirements.txt
# All packages specified in environment.yml are installed in the base environment
RUN mamba env update -f /tmp/environment.yml && \
mamba clean -a -f -y
%% Cell type:markdown id: tags:
![RWTH Logo](https://www.rwth-aachen.de/global/show_picture.asp?id=aaaaaaaaaaagazb)
# Jupyter Example Profile 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
import rwth_nb.plots.mpl_decorations as rwth_plots
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: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
# adapted from https://matplotlib.org/2.0.0/examples/color/named_colors.html
colors = rwth_plots.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>
```
# Jupyter Example Profile
## Introduction
This repository contains an exemplary Jupyter profile which works with the RWTHjupyter cluster. To be more specific, it includes the following files
* `Quickstart.ipynb` which is an exemplary Jupyter notebook file.
* `environment.yml` which specifies the required Python packages needed to run `Quickstart.ipynb`. This file is used by Anaconda or `conda`.
* `Dockerfile` which defines the linux environment. In the end, the packages in `environment.yml` are installed.
* `.gitlab-ci.yml` which specifies the necessary Docker build commands (which are executed every time `Dockerfile` changes in Git).
## Installation
### Installation on RWTHjupyter cluster
Please follow the instruction listed here: https://jupyter.pages.rwth-aachen.de/documentation/instructors/NewProfiles.html
### Docker
If you happen to have Docker installed, you can start a local dockerized JupyterLab for testing your profile:
```bash
# Navigate to your local clone of this repo
# Note: Adjust this path to your local environment
WORKDIR=/home/stv0g/example-profile
cd ${WORKDIR}
# Login to the RWTH GitLab Docker registry
# (required for pulling the base image)
docker login registry.git.rwth-aachen.de
# Build the Docker image
docker build --tag jupyter-example-profile .
# Run the Docker image
docker run --name='jupyter-example-profile' --rm --interactive --tty --publish 8888:8888 --volume ${WORKDIR}:/home/jovyan jupyter-example-profile
```
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.sh`).
* 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 git@git-ce.rwth-aachen.de:jupyter/profiles/example.git
```
* It is highly recommended to run the notebooks in an isolated Anaconda environment. You can create a new environment called `jupyter-example-profile` 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-example-profile
```
### Local Run
* Activate the environment with `conda activate jupyter-example-profile`.
* 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-ce.rwth-aachen.de/jupyter/profiles/examples/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: base
channels:
- conda-forge
dependencies:
- bokeh==2.4.0
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
# mypy: ignore-errors
import os
import stat
import subprocess
from pathlib import Path
from jupyter_core.paths import jupyter_data_dir
c = get_config() # noqa: F821
c.ServerApp.ip = "0.0.0.0"
c.ServerApp.open_browser = False