Skip to content

Instantly share code, notes, and snippets.

@mjuric
Last active September 13, 2018 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjuric/7141a18b3ca26820f59bf9f379569d5e to your computer and use it in GitHub Desktop.
Save mjuric/7141a18b3ca26820f59bf9f379569d5e to your computer and use it in GitHub Desktop.
Setting up custom kernel on epyc, based on the SSSC environment and with access to the LSST stack

Making your own (editable) clone of the SSSC conda environment and Jupyter kernel

This gist describes how to clone the SSSC conda environment (and jupyter kernel) on epyc into your own directory where you can install your own packages into.

This will continue using the LSST stack from the SSSC directory, but you will be able to override (i.e., setup, in the EUPS sense) individual packages by editing your copy of env-setup.sh (see below).

##
## make sure you're using bash, and bring conda to your path
##
bash
. /epyc/opt/anaconda/etc/profile.d/conda.sh
export SSSC="/epyc/projects/sssc"

##
## Create a directory for the new environment and files
##
export DIR="/epyc/ssd/users/$USER/sssc"
mkdir -p "$DIR"
cd "$DIR"

##
## Clone the SSSC conda environment
##
export ENVDIR="$DIR/conda-sssc-env"
conda create -p "$ENVDIR" --clone "$SSSC/conda-sssc-env/"
conda activate "$ENVDIR"

##
## Copy and tweak the Jupyter kernel support files
##
cp "$SSSC/sssc-jupyterhub/ipykernel-with-lsst-stack.sh" "$DIR"
cp "$SSSC/sssc-jupyterhub/env-setup.sh" "$DIR"
sed -i "s|activate /epyc/projects/sssc/conda-sssc-env|activate $ENVDIR|" "$DIR/env-setup.sh"

##
## Copy and tweak the Jupyter kernel definition file
##
mkdir -p $HOME/.local/share/jupyter/kernels
export IPY="$HOME/.local/share/jupyter/kernels/sssc-$USER"
cp -a "$SSSC/sssc-jupyterhub/kernels/python3" "$IPY"
# This will change the startup command to our own
sed -i 's|[^"]*/\(ipykernel-with-lsst-stack.sh\)|'"$DIR"'/\1|' "$IPY/kernel.json"
# This will change the kernel display name
sed -i 's|display_name":.*|display_name": "Python 3 (my SSSC)",|' "$IPY/kernel.json"

Now refresh your JupyterHub page, and you should see the new kernel named Python 3 (my SSSC) available.

To install new packages into your cloned environment, open a terminal and run:

bash # only needed if it's not your default shell
. /epyc/opt/anaconda/etc/profile.d/conda.sh
conda activate /epyc/ssd/users/$USER/sssc/conda-sssc-env
conda install YOUR_PACKAGE_OF_INTEREST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment