-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding farmshare, still under development
- Loading branch information
Showing
10 changed files
with
246 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Farmshare | ||
|
||
Hi friend! These haven't been tested fully yet. Do you want to help? Please work with @vsoch! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# The singularity-run script will run a container, and it would use the | ||
# container's runscript as entrypoint. To execute a command, | ||
# use singularity-exec | ||
|
||
CONTAINER=${1} | ||
shift | ||
|
||
if [ "$#" -gr 0 ]; then | ||
NOTEBOOK_DIR=${1} | ||
shift 1 | ||
else | ||
NOTEBOOK_DIR=${SCRATCH} | ||
fi | ||
|
||
cd $NOTEBOOK_DIR | ||
|
||
export SINGULARITY_CACHEDIR=/farmshare/user_data/${USERNAME}/.singularity | ||
singularity exec ${CONTAINER} "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# Usage | ||
|
||
# 1. Default Jupyter notebook (with your scratch to work in) | ||
# $ bash start.sh singularity-jupyter | ||
|
||
# 2. Default Jupyter notebook with custom working directory | ||
# $ bash start.sh singularity-jupyter /scratch/users/<username> | ||
|
||
# 3. Select your own jupyter container on Sherlock! | ||
# $ bash start.sh singularity-jupyter /scratch/users/<username> /path/to/container | ||
|
||
# 4. Or any singularity container... | ||
# $ bash start.sh singularity /path/to/container <args> | ||
|
||
PORT=$1 | ||
NOTEBOOK_DIR=${2:-${SCRATCH}} | ||
CONTAINER=${3:-docker://vanessa/repo2docker} | ||
|
||
export SINGULARITY_CACHEDIR=/farmshare/user_data/${USERNAME}/.singularity | ||
echo "Container is ${CONTAINER}" | ||
echo "Notebook directory is ${NOTEBOOK_DIR}" | ||
cd ${NOTEBOOK_DIR} | ||
|
||
# Create .local folder for default modules, if doesn't exist | ||
if [ ! -d "${HOME}/.local" ]; | ||
then | ||
echo "Creating local python modules folder to map at ${HOME}/.local"; | ||
mkdir -p "${HOME}/.local"; | ||
fi | ||
|
||
singularity exec --home ${HOME} --bind ${HOME}/.local:/home/username/.local ${CONTAINER} jupyter notebook --no-browser --port=$PORT --ip 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# The singularity-run script will run a container, and it would use the | ||
# container's runscript as entrypoint. To execute a command, | ||
# use singularity-exec | ||
|
||
CONTAINER=${1} | ||
shift | ||
|
||
if [ "$#" -gr 0 ]; then | ||
NOTEBOOK_DIR=${1} | ||
shift 1 | ||
else | ||
NOTEBOOK_DIR=${SCRATCH} | ||
fi | ||
|
||
cd $NOTEBOOK_DIR | ||
|
||
export SINGULARITY_CACHEDIR=/farmshare/user_data/${USERNAME}/.singularity | ||
singularity run ${CONTAINER} "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
# Run a Singularity container notebook, meaning content is in /home/joyvan and | ||
# your $HOME/.local is mounted to the container's $HOME/.local to make | ||
# extra modules available. | ||
|
||
# --- Usage | ||
# bash start.sh sherlock/singularity-notebook <container> | ||
|
||
# --- <container> | ||
# This batch script is intended to run a singularity notebook container, | ||
# and this can mean: | ||
|
||
# A Singularity container image FILE on your scratch | ||
# $ bash start.sh sherlock/singularity-notebook /scratch/users/vsochat/julia.simg | ||
|
||
# A Docker unique resource identifier | ||
# $ bash start.sh sherlock/singularity-notebook docker://<username>/<repository>:<tag> | ||
|
||
# A Singularity Hub unique resource identifier | ||
# $ bash start.sh sherlock/singularity-notebook shub://<username>/<repository>:<tag> | ||
|
||
# --- Container Expectations | ||
# In all cases, it's expected that the notebook is in /home/joyvan (jupyter | ||
# standard). Your local installation directory (at $HOME/.local) will be | ||
# mapped to the container so that modules you have installed locally will | ||
# be usable in the notebook. | ||
|
||
# Ensure we have at least port and container | ||
if (( $# < 2 )); then | ||
echo "Please provide minimally PORT and CONTAINER" | ||
echo "singularity-notebook.sbatch <port> <container>" | ||
exit 1 | ||
fi | ||
|
||
PORT=$1 | ||
CONTAINER="${2}" | ||
NOTEBOOK_DIR="${3:-${SCRATCH}}" | ||
|
||
module use system | ||
module load singularity | ||
export SINGULARITY_CACHEDIR="${SCRATCH}/.singularity" | ||
echo "Container is ${CONTAINER}" | ||
echo "Notebook directory is ${NOTEBOOK_DIR}" | ||
cd ${NOTEBOOK_DIR} | ||
|
||
# If it's not a file, try pulling it | ||
if [ ! -f "${CONTAINER}" ] | ||
then | ||
|
||
# Attempt 1: look in the containershare | ||
echo "Container ${CONTAINER} not found on filesystem, attempting pull..." | ||
CONTAINER_NAME=$(echo -n "${CONTAINER}" | md5sum | awk '{ print $1 }').simg | ||
|
||
# Pull the container, if it doesn't exist. | ||
if [ ! -f "${SINGULARITY_CACHEDIR}/${CONTAINER_NAME}" ] | ||
then | ||
singularity pull --name "${CONTAINER_NAME}" "${CONTAINER}" | ||
fi | ||
CONTAINER="${SINGULARITY_CACHEDIR}/${CONTAINER_NAME}" | ||
fi | ||
|
||
# If still doesn't exist, exit | ||
if [ ! -f "${CONTAINER}" ] | ||
then | ||
echo "Issue obtaining ${CONTAINER}." | ||
exit 1 | ||
fi | ||
|
||
# Create .local folder for default modules, if doesn't exist | ||
if [ ! -d "${HOME}/.local" ]; | ||
then | ||
echo "Creating local python modules folder to map at ${HOME}/.local"; | ||
mkdir -p "${HOME}/.local"; | ||
fi | ||
|
||
singularity exec --home "${HOME}" --bind ${HOME}/.local:/home/joyvan/.local "${CONTAINER}" jupyter notebook --no-browser --port=$PORT --ip 0.0.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.