Skip to content

Commit

Permalink
Merge pull request #4 from guimou/streamlit
Browse files Browse the repository at this point in the history
Addition of Streamlit notebook
  • Loading branch information
guimou authored Jun 8, 2022
2 parents e805657 + dc48dde commit 18ca05f
Show file tree
Hide file tree
Showing 35 changed files with 4,341 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store
*.bundle.*
lib/
node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
*.lock
__pycache__

# Ensure embedme does not run ont node_modules README.md files.
**/node_modules/**/README.md

static
labextension
**/test-results/
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Fix Python Kernel name
Nothing there!

## [0.0.9] - 2022-06-08

### Added

- Streamlit notebook

## [0.0.8] - 2022-03-28

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,19 @@ Various custom Jupyter Notebook Images to use with [Open Data Hub](http://openda
* OptaPy: Minimal JupyterLab notebook including [OptaPy](https://www.optapy.org/optapy/latest/optapy-introduction/optapy-introduction.html), the Python version of OptaPlanner.
* R: Minimal JupyterLab notebook including [R](https://www.r-project.org/) (4.0.5) and [RStudio](https://www.rstudio.com/products/rstudio/) (2022.02.0).
* SageMath: Minimal JupyterLab notebook including [SageMath](https://www.sagemath.org/) 9.3
* Streamlit: Standard Data Science notebook image including [Streamlit](https://streamlit.io/) 1.9.2

## Deployment

In each custom notebook folder you will find a `deploy` folder with an ImageStream YAML file. Simply apply this file in your Open Data Hub namespace (e.g. `oc apply -n opendatahub -f s2i-minimal-data-science-streamlit-notebook_image-stream.yaml`) and the new notebook image will appear in your JupyterHub menu.

## Pre-built images

Pre-built versions of the images are available:

* OptaPy: https://quay.io/guimou/s2i-minimal-data-science-optapy-notebook
* R: https://quay.io/guimou/odh-minimal-data-science-r-notebook
* SageMath: https://quay.io/guimou/s2i-minimal-data-science-sagemath-notebook
* Streamlit: https://quay.io/guimou/s2i-generic-data-science-streamlit-notebook

*[Changelog](CHANGELOG.md)*
23 changes: 23 additions & 0 deletions streamlit-notebook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Streamlit Notebook

Custom notebook based on RHODS standard data science notebook, adding:

* [Streamlit](https://streamlit.io/) ([Github repo](https://github.com/streamlit/streamlit))

Streamlit turns data scripts into shareable web apps in minutes.
All in pure Python. No front‑end experience required.

![Streamlit Menu](streamlit-extension.gif)

## Usage

On top of the Streamlit package itself, this image includes jupyter-server-proxy and a custom JupyterLab extension to easily launch your files.

You can either:

* From the main menu bar, click on the Streamlit menu item, then Select file. In the dialog box select the file to launch with Streamlit.
* From the file browser on the left, right-click on the file you want to launch. The Streamlit option in the contextual menu only shows if you selected a Python file.

A new Terminal will open in your JupyterLab, launch Streamlit and give you information on where the app is accessible. And a new tab will open automatically in your browser to display the app!

To shut down the Streamlit app you simply have to close the Terminal window, it will also shut down the associated Kernel.
40 changes: 40 additions & 0 deletions streamlit-notebook/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM quay.io/thoth-station/s2i-minimal-f34-py39-notebook:v0.3.0

LABEL name="s2i-generic-data-science-streamlit-notebook:latest" \
summary="Generic Data Science Jupyter Notebook Source-to-Image for Python 3.9 applications." \
description="Notebook image based on Source-to-Image.These images can be used in OpenDatahub JupterHub." \
io.k8s.description="Notebook image based on Source-to-Image.These images can be used in OpenDatahub JupterHub." \
io.k8s.display-name="Generic Data Science with Streamlit Notebook Python 3.9-ubi8 S2I" \
io.openshift.expose-services="8888:http" \
io.openshift.tags="python,python39" \
authoritative-source-url="https://quay.io/guimou/s2i-generic-data-science-streamlit-notebook" \
io.openshift.s2i.build.commit.ref="main" \
io.openshift.s2i.build.source-location="https://github.com/guimou/custom-notebooks" \
io.openshift.s2i.build.image="quay.io/thoth-station/s2i-minimal-f34-py39-notebook:v0.2.2"

USER root

WORKDIR /tmp/

# Copying custom packages
COPY Pipfile Pipfile.lock /tmp/
RUN micropipenv install --deploy && \
rm -rf /opt/app-root/lib/python3.9/site-packages/~*

# Streamlit extenstion installation
COPY streamlit-launcher.sh /opt/app-root/bin/
COPY streamlit-menu/dist/jupyterlab_streamlit_menu-0.1.0-py3-none-any.whl /tmp/

# Install packages and cleanup upgrades
RUN pip install --no-cache-dir /tmp/jupyterlab_streamlit_menu-0.1.0-py3-none-any.whl

RUN jupyter lab build && \
jupyter lab clean && \
npm cache clean --force && \
rm -rf /usr/local/share/.cache/yarn && \
fix-permissions /opt/app-root

WORKDIR /opt/app-root/src
USER 1001

CMD /opt/app-root/bin/start-singleuser.sh --ip=0.0.0.0 --port=8080
51 changes: 51 additions & 0 deletions streamlit-notebook/container/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
beautifulsoup4 = "==4.6.3"
bokeh = "~=2.4.3"
boto3 = "==1.24.2"
cloudpickle = "~=2.1.0"
cython = "==0.29.30"
dask = "2022.5.2"
dill = "~=0.3.5.1"
distributed = "2022.5.2"
elyra-python-editor-extension = "==3.9.0"
h5py = "~=3.7.0"
ipywidgets = "~=7.7.0"
jupyter_kernel_gateway = "~=2.5.0"
jupyter-bokeh = "~=3.0.4"
jupyter-nbrequirements = "*"
jupyter-server-proxy = "~=3.2.1"
jupyterhub = "~=1.5.0"
jupyterlab = "~=3.4.2"
jupyterlab-git = "~=0.37.0"
jupyterlab-requirements = "~=0.16.0"
jupyterlab-spellchecker = "~=0.7.2"
jupyterlab-tabnine = "==0.0.24"
kafka-python = "~=2.0.2"
matplotlib = "~=3.5.2"
notebook = "~=6.4.0"
numpy = "~=1.22.4"
pandas = "~=1.4.2"
plotly = "~=5.8.0"
pre-commit = "~=2.19.0"
pyarrow = "~=8.0.0"
scikit-image = "~=0.19.2"
scikit-learn = "~=1.1.1"
scipy = "~=1.8.1"
seaborn = "~=0.11.2"
sqlalchemy = "~=1.4.37"
statsmodels = "~=0.13.2"
streamlit = "~=1.9.2"
supervisor = "~=4.2.0"

[dev-packages]

[requires]
python_version = "3.9"

[pipenv]
allow_prereleases = true
Loading

0 comments on commit 18ca05f

Please sign in to comment.