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

feat: update jupyter-tensorflow-full rock for 1.8 #49

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 10 additions & 9 deletions jupyter-tensorflow-full/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Based on the following Dockerfiles:
# https://github.com/kubeflow/kubeflow/blob/v1.7-branch/components/example-notebook-servers/base/Dockerfile
# https://github.com/kubeflow/kubeflow/blob/v1.7-branch/components/example-notebook-servers/jupyter/Dockerfile
# https://github.com/kubeflow/kubeflow/blob/v1.7-branch/components/example-notebook-servers/jupyter-tensorflow-full/cpu.Dockerfile
# https://github.com/kubeflow/kubeflow/blob/v1.8-branch/components/example-notebook-servers/base/Dockerfile
# https://github.com/kubeflow/kubeflow/blob/v1.8-branch/components/example-notebook-servers/jupyter/Dockerfile
# https://github.com/kubeflow/kubeflow/blob/v1.8-branch/components/example-notebook-servers/jupyter-tensorflow-full/cpu.Dockerfile
name: jupyter-tensorflow-full
summary: An image for using Jupyter & Tensorflow on CPUs
description: |
Expand All @@ -11,7 +11,7 @@ description: |

Both Tensorflow and Jupyter are installed in Conda environment, which is
automatically activated.
version: v1.7.0_20.04_1
version: v1.8.0_20.04_1
license: Apache-2.0
base: ubuntu:20.04
run-user: _daemon_
Expand All @@ -21,8 +21,9 @@ services:
summary: "jupyter-tensorflow-full service"
startup: enabled
environment:
NB_USER: jovyan
NB_UID: 1001
# The following environment variables need to be specified in the Pod's environment, and not hardcoded.
#HOME: ""
#NB_PREFIX: ""
NB_PREFIX: /
HOME: /home/jovyan
SHELL: /bin/bash
Expand All @@ -31,7 +32,7 @@ services:
LC_ALL: en_US.UTF-8
PATH: /opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PYTHONPATH: /opt/conda/lib/python3.8/site-packages/
command: ./jupyter lab --notebook-dir="/home/jovyan" --ip=0.0.0.0 --no-browser --port=8888 --ServerApp.token="" --ServerApp.password="" --ServerApp.allow_origin="*" --ServerApp.base_url="/" --ServerApp.authenticate_prometheus=False
command: bash -c './jupyter lab --notebook-dir=${HOME} --ip=0.0.0.0 --no-browser --port=8888 --ServerApp.token="" --ServerApp.password="" --ServerApp.allow_origin="*" --ServerApp.base_url=${NB_PREFIX} --ServerApp.authenticate_prometheus=False'
working-dir: /opt/conda/bin/
platforms:
amd64:
Expand Down Expand Up @@ -69,7 +70,7 @@ parts:
kubectl:
plugin: nil
stage-snaps:
- kubectl/1.24/stable
- kubectl/1.25/stable
organize:
kubectl: bin/kubectl
stage:
Expand All @@ -94,7 +95,7 @@ parts:
plugin: nil
source: https://github.com/kubeflow/kubeflow
source-type: git
source-tag: v1.7-branch # upstream branch
source-tag: v1.8-branch # upstream branch
build-packages:
- lsb-release
- wget
Expand Down
36 changes: 36 additions & 0 deletions jupyter-tensorflow-full/tests/imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# This python script tests loading of required modules
#

# jupyter packages
import jupyterlab
import notebook
import ipykernel

# kubeflow packages
# TO-DO verfiy proper kfp import. Upgrade might be needed.
#import kfp
import kfp_server_api
import kfserving

# common packages
import bokeh
import cloudpickle
import dill
import ipympl
import ipywidgets
import jupyterlab_git
import matplotlib
import pandas
# TO-DO verify how exactly scikit-image is installed
#import scikit_image
import scikit_learn
import scipy
import seaborn
import xgboost

# tensorflow packages
import tensorflow

# this string is expected by test script
print("PASSED")
4 changes: 2 additions & 2 deletions jupyter-tensorflow-full/tests/test_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def main():
container_id = container_id[0:12]

# to ensure container is started
time.sleep(5)
time.sleep(10)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to add tenacity here instead of sleep?


# retrieve notebook server URL
output = subprocess.run(["curl", "http://127.0.0.1:8888/lab"], stdout=subprocess.PIPE).stdout.decode('utf-8')
output = subprocess.run(["curl", "http://0.0.0.0:8888/lab"], stdout=subprocess.PIPE).stdout.decode('utf-8')
# cleanup
subprocess.run(["docker", "stop", f"{container_id}"])
subprocess.run(["docker", "rm", f"{container_id}"])
Expand Down
29 changes: 29 additions & 0 deletions jupyter-tensorflow-full/tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
#
#
from pathlib import Path

import os
import subprocess
import yaml


def main():
"""Test running container and imports."""
rock = yaml.safe_load(Path("rockcraft.yaml").read_text())
name = rock["name"]
rock_version = rock["version"]
arch = list(rock["platforms"].keys())[0]
rock_image = f"{name}_{rock_version}_{arch}"
LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}"

print(f"Running command in {LOCAL_ROCK_IMAGE}")
script_command = ["bash", "-c", "export PYTHONPATH=$PYTHONPATH:/opt/conda/lib/python3.8/site-packages/keras/api/keras/wrappers/:/opt/conda/lib/python3.8/site-packages/ && python3 /home/jovyan/imports.py"]
pwd = os.getcwd()
output = subprocess.run(["docker", "run", "-v", f"{pwd}/tests/:/home/jovyan", LOCAL_ROCK_IMAGE, "exec", "pebble", "exec"] + script_command, stdout=subprocess.PIPE).stdout.decode('utf-8')
assert "PASSED" in output

if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions jupyter-tensorflow-full/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ allowlist_externals =
rockcraft
deps =
charmed-kubeflow-chisme
juju~=2.9.0
juju<4.0
pytest
pytest-operator
ops
Expand All @@ -29,7 +29,7 @@ commands =
rockcraft pack
bash -c 'NAME=$(yq eval .name rockcraft.yaml) && \
VERSION=$(yq eval .version rockcraft.yaml) && \
ARCH=$(yq eval ".platforms | keys" rockcraft.yaml | awk -F " " '\''{ print $2 }'\'') && \
ARCH=$(yq eval -r ".platforms | keys" rockcraft.yaml | cut -d" " -f2) && \
ROCK="$\{NAME\}_$\{VERSION\}_$\{ARCH\}" && \
sudo skopeo --insecure-policy copy oci-archive:$ROCK.rock docker-daemon:$ROCK:$VERSION && \
docker save $ROCK > $ROCK.tar'
Expand Down