Skip to content

Commit 5fdbfb1

Browse files
authored
Fixes issue where Jupyter notebook cells couldn't be run (#14)
* Adds a script to fetch the requirements.txt for the correct version of JupyterHub being used * Updates Dockerfile.spawn to properly install IPython and avoid issues running Jupyter notebooks
1 parent b1e1726 commit 5fdbfb1

File tree

3 files changed

+272
-276
lines changed

3 files changed

+272
-276
lines changed

2025-HPDC/docker/Dockerfile.spawn

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ COPY ./docker/requirements.txt /requirements.txt
2424

2525
RUN . /opt/global_py_venv/bin/activate && \
2626
# Needed for some viz in thicket-tutorial
27-
python3 -m pip install plotly[express] && \
28-
python3 -m pip install -r /requirements.txt && \
29-
# Covered in requirements.txt, so shouldn't be needed here
30-
# python3 -m pip install ipython==7.34.0 ipykernel==6.25.1 && \
31-
python3 -m IPython kernel install
27+
/opt/global_py_venv/bin/python3 -m pip install plotly[express] && \
28+
/opt/global_py_venv/bin/python3 -m pip install -r /requirements.txt && \
29+
/opt/global_py_venv/bin/python3 -m pip install -U jupyter ipython ipykernel && \
30+
/opt/global_py_venv/bin/python3 -m ipykernel install --prefix=/usr/local --name 'benchpark-tutorial-kernel'
3231

3332
COPY ./docker/kitware-archive.sh /tmp
3433

@@ -41,7 +40,12 @@ RUN /tmp/kitware-archive.sh && \
4140
COPY ./tutorial-code/thicket-tutorial/requirements.txt /tmp/thicket-tutorial/requirements.txt
4241

4342
RUN . /opt/global_py_venv/bin/activate && \
44-
python3 -m pip install -r /tmp/thicket-tutorial/requirements.txt
43+
python3 -m pip install extrap scikit-learn seaborn
44+
# NOTE: we're not installing the dependencies for thicket-tutorial with
45+
# requirements.txt because it hardcodes a version of IPython, which
46+
# breaks all sorts of things. Instead, we extract the relevant dependencies
47+
# and place them above.
48+
# python3 -m pip install -r /tmp/thicket-tutorial/requirements.txt
4549

4650
COPY ./tutorial-code/caliper-tutorial/apps /tmp/caliper-tutorial/apps/
4751
COPY ./tutorial-code/caliper-tutorial/cmake /tmp/caliper-tutorial/cmake/
@@ -78,7 +82,16 @@ RUN cmake \
7882
# && \
7983
# rm -rf /tmp/build-xsbench
8084

81-
RUN chmod -R 777 ~/ ${HOME}
85+
COPY ./tutorial-code/caliper-tutorial/tutorial ${HOME}/caliper-tutorial/
86+
COPY ./tutorial-code/thicket-tutorial/data/ ${HOME}/thicket-tutorial/data/
87+
COPY ./tutorial-code/thicket-tutorial/notebooks ${HOME}/thicket-tutorial/notebooks/
88+
COPY ./tutorial-code/thicket-tutorial/LICENSE ${HOME}/thicket-tutorial
89+
90+
COPY tutorial-code/system-description/aws-tutorial ${HOME}/benchpark/systems/aws-tutorial
91+
COPY tutorial-code/system-description/AWS_Tutorial-c7i-EFA ${HOME}/benchpark/systems/all_hardware_descriptions/AWS_Tutorial-c7i-EFA
92+
93+
RUN chown -R jovyan ${HOME}
94+
# RUN chmod -R 777 ~/ ${HOME}
8295

8396
WORKDIR ${HOME}
8497

@@ -91,14 +104,6 @@ USER ${NB_USER}
91104
ENV SHELL=/usr/bin/bash
92105
ENV FLUX_URI_RESOLVE_LOCAL=t
93106

94-
COPY ./tutorial-code/caliper-tutorial/tutorial ${HOME}/caliper-tutorial/
95-
COPY ./tutorial-code/thicket-tutorial/data/ ${HOME}/thicket-tutorial/data/
96-
COPY ./tutorial-code/thicket-tutorial/notebooks ${HOME}/thicket-tutorial/notebooks/
97-
COPY ./tutorial-code/thicket-tutorial/LICENSE ${HOME}/thicket-tutorial
98-
99-
COPY tutorial-code/system-description/aws-tutorial ${HOME}/benchpark/systems/aws-tutorial
100-
COPY tutorial-code/system-description/AWS_Tutorial-c7i-EFA ${HOME}/benchpark/systems/all_hardware_descriptions/AWS_Tutorial-c7i-EFA
101-
102107
EXPOSE 8888
103108
ENTRYPOINT [ "tini", "--" ]
104109

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
function usage {
4+
echo "Usage: ./get_requirements_for_jupyterhub_k8s.sh <jupyterhub_k8s_version>"
5+
}
6+
7+
if [[ $# -ne 1 ]]; then
8+
usage
9+
exit 1
10+
fi
11+
12+
jh_k8s_version="$1"
13+
14+
if [[ "$jh_k8s_version" == "--help" ]] || [[ "$jh_k8s_version" == "-h" ]]; then
15+
usage
16+
exit 0
17+
fi
18+
19+
if ! command -v gh >/dev/null; then
20+
echo "This script requires the GitHub CLI (i.e., the 'gh' command)!"
21+
echo "Install and try again"
22+
exit 1
23+
fi
24+
25+
if ! command -v curl >/dev/null; then
26+
echo "This script requires the 'curl' command!"
27+
echo "Install and try again"
28+
exit 1
29+
fi
30+
31+
if ! command -v jq >/dev/null; then
32+
echo "This script requires the 'jq' command!"
33+
echo "Install and try again"
34+
exit 1
35+
fi
36+
37+
if ! command -v jq >/dev/null; then
38+
echo "This script requires the 'wget' command!"
39+
echo "Install and try again"
40+
exit 1
41+
fi
42+
43+
if ! command -v sed >/dev/null; then
44+
echo "This script requires the 'sed' command!"
45+
echo "Install and try again"
46+
exit 1
47+
fi
48+
49+
github_url="https://api.github.com/repos/jupyterhub/zero-to-jupyterhub-k8s/contents/images/hub/requirements.txt?ref=$jh_k8s_version"
50+
51+
file_lookup_json=$(curl -JL \
52+
-H "Accept: application/vnd.github+json" \
53+
-H "Authorization: Bearer $(gh auth token)" \
54+
-H "X-GitHub-Api-Version: 2022-11-28" \
55+
"$github_url")
56+
57+
wget_url=$(echo "$file_lookup_json" | jq -r '.download_url')
58+
59+
wget -O $(pwd)/requirements.txt $wget_url
60+
61+
sed -i '' '/psycopg2/d' $(pwd)/requirements.txt

0 commit comments

Comments
 (0)