Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SensiML notebook, based on TensorFlow notebook #1234

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion docs/using/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ RUN $CONDA_DIR/envs/${conda_env}/bin/python -m ipykernel install --user --name=$
fix-permissions /home/$NB_USER

# any additional pip installs can be added by uncommenting the following line
# RUN $CONDA_DIR/envs/${conda_env}/bin/pip install
# RUN $CONDA_DIR/envs/${conda_env}/bin/pip install

# prepend conda environment to path
ENV PATH $CONDA_DIR/envs/${conda_env}/bin:$PATH
Expand Down Expand Up @@ -528,3 +528,24 @@ USER $NB_UID

RUN pip install --quiet --no-cache-dir auto-sklearn
```

## Enable SensiML notebooks

Using `sensiml` requires `tensorflow`, and installs `qgrid` and `bqplot`. There is no conda package for `sensiml` at this time.

```dockerfile
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/tensorflow-notebook
FROM $BASE_CONTAINER

# Install SensiML and enable notebook extensions.
RUN pip install --quiet --no-cache-dir \
'sensiml' && \
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
jupyter nbextension enable --py --sys-prefix bqplot && \
jupyter nbextension enable --py --sys-prefix qgrid && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

```
32 changes: 26 additions & 6 deletions docs/using/specifics.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docker run -it --rm jupyter/pyspark-notebook:spark-2.4.7 pyspark --version
# _\ \/ _ \/ _ `/ __/ '_/
# /___/ .__/\_,_/_/ /_/\_\ version 2.4.7
# /_/
#
#
# Using Scala version 2.11.12, OpenJDK 64-Bit Server VM, 1.8.0_275
```

Expand Down Expand Up @@ -82,7 +82,7 @@ sc <- sparkR.session("local")
# Sum of the first 100 whole numbers
sdf <- createDataFrame(list(1:100))
dapplyCollect(sdf,
function(x)
function(x)
{ x <- sum(x)}
)
# 5050
Expand All @@ -102,7 +102,7 @@ conf$spark.sql.catalogImplementation <- "in-memory"
sc <- spark_connect(master = "local", config = conf)

# Sum of the first 100 whole numbers
sdf_len(sc, 100, repartition = 1) %>%
sdf_len(sc, 100, repartition = 1) %>%
spark_apply(function(e) sum(e))
# 5050
```
Expand Down Expand Up @@ -171,7 +171,7 @@ sc <- sparkR.session("spark://master:7077")
# Sum of the first 100 whole numbers
sdf <- createDataFrame(list(1:100))
dapplyCollect(sdf,
function(x)
function(x)
{ x <- sum(x)}
)
# 5050
Expand All @@ -190,7 +190,7 @@ conf$spark.sql.catalogImplementation <- "in-memory"
sc <- spark_connect(master = "spark://master:7077", config = conf)

# Sum of the first 100 whole numbers
sdf_len(sc, 100, repartition = 1) %>%
sdf_len(sc, 100, repartition = 1) %>%
spark_apply(function(e) sum(e))
# 5050
```
Expand Down Expand Up @@ -232,6 +232,26 @@ sess.run(init)
sess.run(hello)
```

## SensiML

The `jupyter/sensiml-notebook` image supports the use of
[SensiML](https://www.sensiml.com/) Analytics Toolkit using a SensiML account.

### Single Machine Mode

```python
from sensiml import *

connection = SensiML()

# Here you will be prompted for your username/password

# Now, Open the DashBoard UI:
DashBoard(connection)
```

For further usage examples, see the [SensiML Analytics Studio Notebook documentation](https://sensiml.com/documentation/analytics-studio-notebook/index.html).

### Distributed Mode

```python
Expand All @@ -249,4 +269,4 @@ sess.run(hello)

[sparkr]: https://spark.apache.org/docs/latest/sparkr.html
[sparklyr]: https://spark.rstudio.com/
[spark-conf]: https://spark.apache.org/docs/latest/configuration.html
[spark-conf]: https://spark.apache.org/docs/latest/configuration.html
4 changes: 4 additions & 0 deletions sensiml-notebook/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Documentation
README.md
hooks
test
15 changes: 15 additions & 0 deletions sensiml-notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/tensorflow-notebook
FROM $BASE_CONTAINER

LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"

# Install SensiML and enable notebook extensions.
RUN pip install --quiet --no-cache-dir \
'sensiml' && \
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
jupyter nbextension enable --py --sys-prefix bqplot && \
jupyter nbextension enable --py --sys-prefix qgrid && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
14 changes: 14 additions & 0 deletions sensiml-notebook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[![docker pulls](https://img.shields.io/docker/pulls/jupyter/sensiml-notebook.svg)](https://hub.docker.com/r/jupyter/sensiml-notebook/)
[![docker stars](https://img.shields.io/docker/stars/jupyter/sensiml-notebook.svg)](https://hub.docker.com/r/jupyter/sensiml-notebook/)
[![image metadata](https://images.microbadger.com/badges/image/jupyter/sensiml-notebook.svg)](https://microbadger.com/images/jupyter/sensiml-notebook "jupyter/sensiml-notebook image metadata")

# Jupyter Notebook Deep Learning Stack

GitHub Actions in the https://github.com/jupyter/docker-stacks project builds and pushes this image
to Docker Hub.

Please visit the project documentation site for help using and contributing to this image and
others.

- [Jupyter Docker Stacks on ReadTheDocs](http://jupyter-docker-stacks.readthedocs.io/en/latest/index.html)
- [Image Specifics :: Tensorflow](http://jupyter-docker-stacks.readthedocs.io/en/latest/using/specifics.html#sensiml)
45 changes: 45 additions & 0 deletions sensiml-notebook/hooks/run_hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -e

# Apply tags
GIT_SHA_TAG=${GITHUB_SHA:0:12}
docker tag $IMAGE_NAME "$DOCKER_REPO:$GIT_SHA_TAG"

# Update index
INDEX_ROW="|\`${BUILD_TIMESTAMP}\`|\`jupyter/${IMAGE_SHORT_NAME}:${GIT_SHA_TAG}\`|[Git diff](https://github.com/jupyter/docker-stacks/commit/${GITHUB_SHA})<br />[Dockerfile](https://github.com/jupyter/docker-stacks/blob/${GITHUB_SHA}/${IMAGE_SHORT_NAME}/Dockerfile)<br />[Build manifest](./${IMAGE_SHORT_NAME}-${GIT_SHA_TAG})|"
sed "/|-|/a ${INDEX_ROW}" -i "${WIKI_PATH}/Home.md"

# Build manifest
MANIFEST_FILE="${WIKI_PATH}/manifests/${IMAGE_SHORT_NAME}-${GIT_SHA_TAG}.md"
mkdir -p $(dirname "$MANIFEST_FILE")

cat << EOF > "$MANIFEST_FILE"
* Build datetime: ${BUILD_TIMESTAMP}
* Docker image: ${DOCKER_REPO}:${GIT_SHA_TAG}
* Docker image size: $(docker images ${IMAGE_NAME} --format "{{.Size}}")
* Git commit SHA: [${GITHUB_SHA}](https://github.com/jupyter/docker-stacks/commit/${GITHUB_SHA})
* Git commit message:
\`\`\`
${COMMIT_MSG}
\`\`\`

## Python Packages

\`\`\`
$(docker run --rm ${IMAGE_NAME} python --version)
\`\`\`

\`\`\`
$(docker run --rm ${IMAGE_NAME} conda info)
\`\`\`

\`\`\`
$(docker run --rm ${IMAGE_NAME} conda list)
\`\`\`

## Apt Packages

\`\`\`
$(docker run --rm ${IMAGE_NAME} apt list --installed)
\`\`\`
EOF
30 changes: 30 additions & 0 deletions sensiml-notebook/test/test_sensiml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging

import pytest

LOGGER = logging.getLogger(__name__)


@pytest.mark.parametrize(
"name,command",
[
(
"Hello SensiML",
"import sensiml;print(sensiml.name)",
),
(
"Widget Modules Length",
"import sensiml;print(len(dir(sensiml.widgets)) > 0)",
),
],
)
def test_sensiml(container, name, command):
"""Basic SensiML tests"""
LOGGER.info(f"Testing SensiML: {name} ...")
c = container.run(tty=True, command=["start.sh", "python", "-c", command])
rv = c.wait(timeout=30)
assert rv == 0 or rv["StatusCode"] == 0, f"Command {command} failed"
logs = c.logs(stdout=True).decode("utf-8")
LOGGER.debug(logs)
30 changes: 30 additions & 0 deletions sensiml-notebook/test/test_tensorflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging

import pytest

LOGGER = logging.getLogger(__name__)


@pytest.mark.parametrize(
"name,command",
[
(
"Hello world",
"import tensorflow as tf;print(tf.constant('Hello, TensorFlow'))",
),
(
"Sum",
"import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))",
),
],
)
def test_tensorflow(container, name, command):
"""Basic tensorflow tests"""
LOGGER.info(f"Testing tensorflow: {name} ...")
c = container.run(tty=True, command=["start.sh", "python", "-c", command])
rv = c.wait(timeout=30)
assert rv == 0 or rv["StatusCode"] == 0, f"Command {command} failed"
logs = c.logs(stdout=True).decode("utf-8")
LOGGER.debug(logs)