Skip to content

Commit

Permalink
Merge pull request #160 from nmfs-opensci/eeholmes-patch-1
Browse files Browse the repository at this point in the history
Update install-vscode-extensions.sh
  • Loading branch information
eeholmes authored Nov 8, 2024
2 parents 357cfa8 + 33cd838 commit 1cda219
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
3 changes: 3 additions & 0 deletions appendix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ RUN mkdir -p /pyrocket_scripts && cp -r ${REPO_DIR}/scripts/* /pyrocket_scripts/
RUN chown -R root:staff /pyrocket_scripts && \
chmod -R 775 /pyrocket_scripts

# Debugging
RUN /pyrocket_scripts/test.sh

# Some basic VS Code extensions
RUN /pyrocket_scripts/install-vscode-extensions.sh ${REPO_DIR}/vscode-extensions.txt

Expand Down
13 changes: 9 additions & 4 deletions scripts/install-conda-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fi

# Main script execution as NB_USER
echo "Running install-conda-packages.sh as ${NB_USER}"
echo "NB_PYTHON_PREFIX: $NB_PYTHON_PREFIX, CONDA_ENV: $CONDA_ENV, CONDA_DIR: $CONDA_DIR"

# Set the file variable to the provided argument
ENV_FILE="$1"
Expand Down Expand Up @@ -58,15 +59,19 @@ if [ "$INSTALLATION_HAPPENED" = true ]; then
# Updating the notebook environment sometimes gets rid of pip installed packages.
# Make sure the core environment didn't get damaged.
# Check if jupyterlab-quarto is installed, and reinstall if missing
if ! python -m pip show jupyterlab-quarto > /dev/null 2>&1; then
if ! ${NB_PYTHON_PREFIX}/bin/pip show jupyterlab-quarto > /dev/null 2>&1; then
echo " Reinstalling jupyterlab-quarto..."
python -m pip install jupyterlab-quarto
if ! ${NB_PYTHON_PREFIX}/bin/pip install jupyterlab-quarto; then
echo " Error: Failed to reinstall jupyterlab-quarto. Continuing with the process." >&2
fi
fi

# Check if jupyter-remote-desktop-proxy is installed, and reinstall if missing
if ! python -m pip show jupyter-remote-desktop-proxy > /dev/null 2>&1; then
if ! ${NB_PYTHON_PREFIX}/bin/pip show jupyter-remote-desktop-proxy > /dev/null 2>&1; then
echo " Reinstalling jupyter-remote-desktop-proxy..."
python -m pip install jupyter-remote-desktop-proxy
if ! ${NB_PYTHON_PREFIX}/bin/pip install jupyter-remote-desktop-proxy; then
echo " Error: Failed to reinstall jupyter-remote-desktop-proxy. Continuing with the process." >&2
fi
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/install-pip-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi

# Main script execution as NB_USER
echo "Running install-pip-packages.sh as ${NB_USER}"

echo "NB_PYTHON_PREFIX: $NB_PYTHON_PREFIX, CONDA_ENV: $CONDA_ENV, CONDA_DIR: $CONDA_DIR"

# Set variable for the provided file
requirements_file="$1"
Expand Down
3 changes: 2 additions & 1 deletion scripts/install-r-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fi

# Main script execution as NB_USER
echo "Running install-r-packages.sh as ${NB_USER}"
echo "Rscript location: $(which Rscript)"

# Set the file variable to the provided argument
INSTALL_FILE="$1"
Expand All @@ -29,7 +30,7 @@ fi

echo " Found file: $INSTALL_FILE"

# Install R packages using the provided R script
# Install R packages using the provided R script; should be /usr/local/bin/Rscript
if ! Rscript "$INSTALL_FILE"; then
echo " Error: Installation of packages from '$INSTALL_FILE' failed. Please check the script for errors." >&2
exit 1
Expand Down
4 changes: 1 addition & 3 deletions scripts/install-vscode-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ fi

# Install each extension listed in the file
while IFS= read -r EXT; do
if code-server --install-extension "$EXT"; then
if ${NB_PYTHON_PREFIX}/bin/code-server --install-extension "$EXT"; then
echo " Successfully installed extension: $EXT"
else
echo " Failed to install extension: $EXT" >&2
fi
done < "$ext_file"

echo " Success! install-vscode-extensions.sh"
18 changes: 18 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Required User: NB_USER

echo "user is root"
echo "NB_PYTHON_PREFIX: $NB_PYTHON_PREFIX"
echo "CONDA_ENV: $CONDA_ENV"
echo "CONDA_DIR: $CONDA_DIR"

# Check if running as root and switch to NB_USER if needed
if [[ $(id -u) -eq 0 ]]; then
echo "Switching to ${NB_USER} to run install-conda-packages.sh"
exec su "${NB_USER}" -c "/bin/bash $0 $1" # Pass along the filename argument
fi

echo "user is jovyan"
echo "NB_PYTHON_PREFIX: $NB_PYTHON_PREFIX"
echo "CONDA_ENV: $CONDA_ENV"
echo "CONDA_DIR: $CONDA_DIR"

0 comments on commit 1cda219

Please sign in to comment.