Skip to content

Commit

Permalink
added conditions in start custom script (#669)
Browse files Browse the repository at this point in the history
* added conditions in start custom script

* updated workflow

* added missing space

* reversed logic and added echo

* fixed if statement

* update echo message
  • Loading branch information
mathis-marcotte authored Oct 30, 2024
1 parent f3c46eb commit 4bb0030
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ jobs:

- name: Push image to local registry (default pushes all tags)
run: make push/${{ matrix.notebook }} REPO=${{ env.LOCAL_REPO }}

# Image testing

- name: Set Up Python for Test Suite
uses: actions/setup-python@v4
with:
Expand Down
57 changes: 38 additions & 19 deletions output/docker-stacks-datascience-notebook/start-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@ else
fi

# Step up Git Credential Manager
git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc

# Clone example notebooks (with retries)
RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
# only if it wasn't already setup
if grep -q "export GPG_TTY" ~/.bashrc; then
echo "Git Credential Manager already setup"
else
echo "Setting up Git Credential Manager"

git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc
fi

# Clone example notebooks (with retries because it sometimes initially fails)
if [[ ! -d ~/aaw-contrib-jupyter-notebooks ]]; then
echo "Cloning examples notebooks"

RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
else
echo "Example notebooks already cloned."
fi

if [ ! -e /home/$NB_USER/.Rprofile ]; then
cat /tmp/.Rprofile >> /home/$NB_USER/.Rprofile && rm -rf /tmp/.Rprofile
Expand All @@ -51,11 +64,17 @@ fi

# add rm wrapper:
# https://jirab.statcan.ca/browse/ZPS-40
mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
if [ ! -f /home/$NB_USER/.local/bin/rm ]; then
echo "adding rm wrapper"

mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
else
echo "rm wrapper already exists"
fi

export VISUAL="/usr/bin/nano"
export EDITOR="$VISUAL"
Expand Down
57 changes: 38 additions & 19 deletions output/jupyterlab-cpu/start-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@ else
fi

# Step up Git Credential Manager
git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc

# Clone example notebooks (with retries)
RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
# only if it wasn't already setup
if grep -q "export GPG_TTY" ~/.bashrc; then
echo "Git Credential Manager already setup"
else
echo "Setting up Git Credential Manager"

git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc
fi

# Clone example notebooks (with retries because it sometimes initially fails)
if [[ ! -d ~/aaw-contrib-jupyter-notebooks ]]; then
echo "Cloning examples notebooks"

RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
else
echo "Example notebooks already cloned."
fi

if [ ! -e /home/$NB_USER/.Rprofile ]; then
cat /tmp/.Rprofile >> /home/$NB_USER/.Rprofile && rm -rf /tmp/.Rprofile
Expand All @@ -51,11 +64,17 @@ fi

# add rm wrapper:
# https://jirab.statcan.ca/browse/ZPS-40
mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
if [ ! -f /home/$NB_USER/.local/bin/rm ]; then
echo "adding rm wrapper"

mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
else
echo "rm wrapper already exists"
fi

export VISUAL="/usr/bin/nano"
export EDITOR="$VISUAL"
Expand Down
57 changes: 38 additions & 19 deletions output/jupyterlab-pytorch/start-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@ else
fi

# Step up Git Credential Manager
git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc

# Clone example notebooks (with retries)
RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
# only if it wasn't already setup
if grep -q "export GPG_TTY" ~/.bashrc; then
echo "Git Credential Manager already setup"
else
echo "Setting up Git Credential Manager"

git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc
fi

# Clone example notebooks (with retries because it sometimes initially fails)
if [[ ! -d ~/aaw-contrib-jupyter-notebooks ]]; then
echo "Cloning examples notebooks"

RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
else
echo "Example notebooks already cloned."
fi

if [ ! -e /home/$NB_USER/.Rprofile ]; then
cat /tmp/.Rprofile >> /home/$NB_USER/.Rprofile && rm -rf /tmp/.Rprofile
Expand All @@ -51,11 +64,17 @@ fi

# add rm wrapper:
# https://jirab.statcan.ca/browse/ZPS-40
mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
if [ ! -f /home/$NB_USER/.local/bin/rm ]; then
echo "adding rm wrapper"

mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
else
echo "rm wrapper already exists"
fi

export VISUAL="/usr/bin/nano"
export EDITOR="$VISUAL"
Expand Down
57 changes: 38 additions & 19 deletions output/jupyterlab-tensorflow/start-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@ else
fi

# Step up Git Credential Manager
git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc

# Clone example notebooks (with retries)
RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
# only if it wasn't already setup
if grep -q "export GPG_TTY" ~/.bashrc; then
echo "Git Credential Manager already setup"
else
echo "Setting up Git Credential Manager"

git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc
fi

# Clone example notebooks (with retries because it sometimes initially fails)
if [[ ! -d ~/aaw-contrib-jupyter-notebooks ]]; then
echo "Cloning examples notebooks"

RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
else
echo "Example notebooks already cloned."
fi

if [ ! -e /home/$NB_USER/.Rprofile ]; then
cat /tmp/.Rprofile >> /home/$NB_USER/.Rprofile && rm -rf /tmp/.Rprofile
Expand All @@ -51,11 +64,17 @@ fi

# add rm wrapper:
# https://jirab.statcan.ca/browse/ZPS-40
mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
if [ ! -f /home/$NB_USER/.local/bin/rm ]; then
echo "adding rm wrapper"

mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
else
echo "rm wrapper already exists"
fi

export VISUAL="/usr/bin/nano"
export EDITOR="$VISUAL"
Expand Down
57 changes: 38 additions & 19 deletions output/remote-desktop/start-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,33 @@ else
fi

# Step up Git Credential Manager
git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc

# Clone example notebooks (with retries)
RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
# only if it wasn't already setup
if grep -q "export GPG_TTY" ~/.bashrc; then
echo "Git Credential Manager already setup"
else
echo "Setting up Git Credential Manager"

git config --global credential.credentialStore gpg
git config --global credential.helper manager
echo "export GPG_TTY=\$(tty)" >> ~/.bashrc
fi

# Clone example notebooks (with retries because it sometimes initially fails)
if [[ ! -d ~/aaw-contrib-jupyter-notebooks ]]; then
echo "Cloning examples notebooks"

RETRIES_NO=5
RETRY_DELAY=3
for i in $(seq 1 $RETRIES_NO); do
test -z "$GIT_EXAMPLE_NOTEBOOKS" || git clone "$GIT_EXAMPLE_NOTEBOOKS" && break
echo "Failed to cloned the example notebooks. Attempt $i of $RETRIES_NO"
#if it ran all the retries, exit
[[ $i -eq $RETRIES_NO ]] && echo "Failed to clone example notebooks after $RETRIES_NO retries"
sleep ${RETRY_DELAY}
done
else
echo "Example notebooks already cloned."
fi

if [ ! -e /home/$NB_USER/.Rprofile ]; then
cat /tmp/.Rprofile >> /home/$NB_USER/.Rprofile && rm -rf /tmp/.Rprofile
Expand All @@ -51,11 +64,17 @@ fi

# add rm wrapper:
# https://jirab.statcan.ca/browse/ZPS-40
mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
if [ ! -f /home/$NB_USER/.local/bin/rm ]; then
echo "adding rm wrapper"

mkdir -p /home/$NB_USER/.local/bin/
git clone https://gitlab.k8s.cloud.statcan.ca/zone/build-scripts/snippets/415.git /home/$NB_USER/.local/bin/rm-git
mv /home/$NB_USER/.local/bin/rm-git/rm /home/$NB_USER/.local/bin/rm
rm -rf /home/$NB_USER/.local/bin/rm-git
chmod +x /home/$NB_USER/.local/bin/rm
else
echo "rm wrapper already exists"
fi

export VISUAL="/usr/bin/nano"
export EDITOR="$VISUAL"
Expand Down
Loading

0 comments on commit 4bb0030

Please sign in to comment.