From 65040e3aba2224d11d9b4f0d3e072845f47e9c61 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Sat, 21 Sep 2024 00:20:18 +0500 Subject: [PATCH 1/2] Switch from pip3 to pipx for Jupyter install --- jupyter-notebook/run.sh | 14 +++++++------- jupyterlab/run.sh | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/jupyter-notebook/run.sh b/jupyter-notebook/run.sh index 4f8c4a20..0c7a9b85 100755 --- a/jupyter-notebook/run.sh +++ b/jupyter-notebook/run.sh @@ -7,14 +7,14 @@ printf "$${BOLD}Installing jupyter-notebook!\n" # check if jupyter-notebook is installed if ! command -v jupyter-notebook > /dev/null 2>&1; then # install jupyter-notebook - # check if python3 pip is installed - if ! command -v pip3 > /dev/null 2>&1; then - echo "pip3 is not installed" - echo "Please install pip3 in your Dockerfile/VM image before running this script" + # check if pipx is installed + if ! command -v pipx > /dev/null 2>&1; then + echo "pipx is not installed" + echo "Please install pipx in your Dockerfile/VM image before using this module" exit 1 fi - # install jupyter-notebook - pip3 install --upgrade --no-cache-dir --no-warn-script-location jupyter + # install jupyter notebook + pipx install -q notebook echo "🥳 jupyter-notebook has been installed\n\n" else echo "🥳 jupyter-notebook is already installed\n\n" @@ -22,4 +22,4 @@ fi echo "👷 Starting jupyter-notebook in background..." echo "check logs at ${LOG_PATH}" -$HOME/.local/bin/jupyter notebook --NotebookApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 & +$HOME/.local/bin/jupyter-notebook --NotebookApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 & diff --git a/jupyterlab/run.sh b/jupyterlab/run.sh index b040cec1..0245b069 100755 --- a/jupyterlab/run.sh +++ b/jupyterlab/run.sh @@ -7,14 +7,14 @@ printf "$${BOLD}Installing jupyterlab!\n" # check if jupyterlab is installed if ! command -v jupyterlab > /dev/null 2>&1; then # install jupyterlab - # check if python3 pip is installed - if ! command -v pip3 > /dev/null 2>&1; then - echo "pip3 is not installed" - echo "Please install pip3 in your Dockerfile/VM image before running this script" + # check if pipx is installed + if ! command -v pipx > /dev/null 2>&1; then + echo "pipx is not installed" + echo "Please install pipx in your Dockerfile/VM image before running this script" exit 1 fi # install jupyterlab - pip3 install --upgrade --no-cache-dir --no-warn-script-location jupyterlab + pipx install -q jupyterlab echo "🥳 jupyterlab has been installed\n\n" else echo "🥳 jupyterlab is already installed\n\n" @@ -22,4 +22,4 @@ fi echo "👷 Starting jupyterlab in background..." echo "check logs at ${LOG_PATH}" -$HOME/.local/bin/jupyter lab --ServerApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 & +$HOME/.local/bin/jupyter-lab --ServerApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' > ${LOG_PATH} 2>&1 & From 035128d8c09d31d9819a475f0a383c243e77b5f1 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Sat, 21 Sep 2024 00:44:57 +0500 Subject: [PATCH 2/2] Switch from pip3 to pipx in JupyterLab tests --- jupyterlab/main.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jupyterlab/main.test.ts b/jupyterlab/main.test.ts index 2597dc21..122de774 100644 --- a/jupyterlab/main.test.ts +++ b/jupyterlab/main.test.ts @@ -22,7 +22,7 @@ const executeScriptInContainerWithPip = async ( }> => { const instance = findResourceInstance(state, "coder_script"); const id = await runContainer(image); - const respPip = await execContainer(id, [shell, "-c", "apk add py3-pip"]); + const respPipx = await execContainer(id, [shell, "-c", "apk add pipx"]); const resp = await execContainer(id, [shell, "-c", instance.script]); const stdout = resp.stdout.trim().split("\n"); const stderr = resp.stderr.trim().split("\n"); @@ -40,7 +40,7 @@ describe("jupyterlab", async () => { agent_id: "foo", }); - it("fails without pip3", async () => { + it("fails without pipx", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", }); @@ -48,14 +48,14 @@ describe("jupyterlab", async () => { expect(output.exitCode).toBe(1); expect(output.stdout).toEqual([ "\u001B[0;1mInstalling jupyterlab!", - "pip3 is not installed", - "Please install pip3 in your Dockerfile/VM image before running this script", + "pipx is not installed", + "Please install pipx in your Dockerfile/VM image before running this script", ]); }); - // TODO: Add faster test to run with pip3. + // TODO: Add faster test to run with pipx. // currently times out. - // it("runs with pip3", async () => { + // it("runs with pipx", async () => { // ... // const output = await executeScriptInContainerWithPip(state, "alpine"); // ...