File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
registry/coder/modules/jupyter-notebook Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ A module that adds Jupyter Notebook in your Coder template.
1616module "jupyter-notebook" {
1717 count = data.coder_workspace.me.start_count
1818 source = "registry.coder.com/coder/jupyter-notebook/coder"
19- version = "1.1.1 "
19+ version = "1.2.0 "
2020 agent_id = coder_agent.example.id
2121}
2222```
Original file line number Diff line number Diff line change @@ -48,13 +48,27 @@ variable "group" {
4848 default = null
4949}
5050
51+ variable "requirements_path" {
52+ type = string
53+ description = " The path to requirements.txt with packages to preinstall"
54+ default = " "
55+ }
56+
57+ variable "pip_install_extra_packages" {
58+ type = string
59+ description = " List of extra packages to preinstall (example: numpy==1.26.4 pandas matplotlib<4 scikit-learn)"
60+ default = " "
61+ }
62+
5163resource "coder_script" "jupyter-notebook" {
5264 agent_id = var. agent_id
5365 display_name = " jupyter-notebook"
5466 icon = " /icon/jupyter.svg"
5567 script = templatefile (" ${ path . module } /run.sh" , {
5668 LOG_PATH : var.log_path,
57- PORT : var.port
69+ PORT : var.port,
70+ REQUIREMENTS_PATH : var.requirements_path,
71+ PIP_INSTALL_EXTRA_PACKAGES : var.pip_install_extra_packages
5872 })
5973 run_on_start = true
6074}
Original file line number Diff line number Diff line change 2020 echo " 🥳 jupyter-notebook is already installed\n\n"
2121fi
2222
23+ # Install packages selected with REQUIREMENTS_PATH
24+ if [ -n " ${REQUIREMENTS_PATH} " ]; then
25+ if [ -f " ${REQUIREMENTS_PATH} " ]; then
26+ echo " 📄 Installing packages from ${REQUIREMENTS_PATH} ..."
27+ pipx -q runpip notebook install -r " ${REQUIREMENTS_PATH} "
28+ echo " 🥳 Packages from ${REQUIREMENTS_PATH} have been installed\n\n"
29+ else
30+ echo " ⚠️ REQUIREMENTS_PATH is set to '${REQUIREMENTS_PATH} ' but the file does not exist!\n\n"
31+ fi
32+ fi
33+
34+ # Install packages selected with PIP_INSTALL_EXTRA_PACKAGES
35+ if [ -n " ${PIP_INSTALL_EXTRA_PACKAGES} " ]; then
36+ echo " 📦 Installing additional packages: ${PIP_INSTALL_EXTRA_PACKAGES} "
37+ pipx -q runpip notebook install ${PIP_INSTALL_EXTRA_PACKAGES}
38+ echo " 🥳 Additional packages have been installed\n\n"
39+ fi
40+
2341echo " 👷 Starting jupyter-notebook in background..."
2442echo " check logs at ${LOG_PATH} "
2543$HOME /.local/bin/jupyter-notebook --NotebookApp.ip=' 0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token=' ' --ServerApp.password=' ' > ${LOG_PATH} 2>&1 &
You can’t perform that action at this time.
0 commit comments