Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
deusebio committed Jan 26, 2024
1 parent dd63dba commit 7a089dd
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
11 changes: 7 additions & 4 deletions build/Dockerfile.jupyter
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
ARG BASE_IMAGE=base-charmed-spark:latest
ARG JUPYTERLAB_VERSION=4.0.11
FROM $BASE_IMAGE

ARG JUPYTERLAB_VERSION
USER root
RUN rm /var/lib/pebble/default/layers/*.yaml

RUN python3 -m pip install "jupyterlab~=4.0"
RUN rm /var/lib/pebble/default/layers/*.yaml /opt/pebble/*.sh

RUN python3 -m pip install "jupyterlab==$JUPYTERLAB_VERSION"
COPY ./files/jupyter/pebble/layers.yaml /var/lib/pebble/default/layers/001-charmed-jupyter.yaml
COPY ./files/jupyter/bin/kf-nb.sh /opt/spark/bin/kf-nb.sh
RUN chown _daemon_:_daemon_ /opt/spark/bin/kf-nb.sh
COPY ./files/jupyter/bin/jupyterlab-server.sh /opt/pebble/jupyterlab-server.sh
RUN chown _daemon_:_daemon_ /opt/pebble/jupyterlab-server.sh

USER _daemon_

Expand Down
14 changes: 14 additions & 0 deletions files/jupyter/bin/jupyterlab-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

sleep 5

export PYSPARK_DRIVER_PYTHON=jupyter

# This variable is injected when running a notebook from Kubeflow.
if [ -z "${NB_PREFIX}" ]; then
NB_PREFIX_ARG="--NotebookApp.base_url '${NB_PREFIX}'"
fi

export PYSPARK_DRIVER_PYTHON_OPTS="lab --no-browser --port=8888 ${NB_PREFIX_ARG} --ip=0.0.0.0 --NotebookApp.token='' --notebook-dir=/var/lib/spark/notebook"

spark-client.pyspark $*
8 changes: 0 additions & 8 deletions files/jupyter/bin/kf-nb.sh

This file was deleted.

2 changes: 1 addition & 1 deletion files/jupyter/pebble/layers.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
jupyter:
command: "/opt/spark/bin/kf-nb.sh"
command: "/opt/pebble/jupyterlab-server.sh"
summary: "This is the Spark-powered Jupyter service"
override: replace
startup: enabled
2 changes: 1 addition & 1 deletion rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ parts:
- python3-pip
overlay-script: |
mkdir -p $CRAFT_PART_INSTALL/opt/spark8t/python/dist
pip install --target=${CRAFT_PART_INSTALL}/opt/spark8t/python/dist git+https://github.com/canonical/spark-k8s-toolkit-py.git@wip-incluster-config
pip install --target=${CRAFT_PART_INSTALL}/opt/spark8t/python/dist git+https://github.com/canonical/spark-k8s-toolkit-py.git@dpe-3398-fix-service-account-permission
rm usr/bin/pip*
stage:
- opt/spark8t/python/dist
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,8 @@ setup_test_pod() {
SLEEP_TIME=$(expr $SLEEP_TIME \* 2);
done

MY_KUBE_CONFIG=$(cat /home/${USER}/.kube/config)
TEST_POD_TEMPLATE=$(cat tests/integration/resources/podTemplate.yaml)

kubectl exec testpod -- /bin/bash -c 'mkdir -p ~/.kube'
kubectl exec testpod -- env KCONFIG="$MY_KUBE_CONFIG" /bin/bash -c 'echo "$KCONFIG" > ~/.kube/config'
kubectl exec testpod -- /bin/bash -c 'cat ~/.kube/config'
kubectl exec testpod -- /bin/bash -c 'cp -r /opt/spark/python /var/lib/spark/'
kubectl exec testpod -- env PTEMPLATE="$TEST_POD_TEMPLATE" /bin/bash -c 'echo "$PTEMPLATE" > /etc/spark/conf/podTemplate.yaml'
}
Expand Down

0 comments on commit 7a089dd

Please sign in to comment.