diff --git a/.gitignore b/.gitignore index 5623d3f..12cce24 100644 --- a/.gitignore +++ b/.gitignore @@ -383,3 +383,6 @@ wandb_artifacts/ # Generated by hydra. # outputs/ logs/ + +# Generated for pushing to seuss. +.singularity_images/ diff --git a/cluster/build_push_sif_seuss.bash b/cluster/build_push_sif_seuss.bash new file mode 100755 index 0000000..fd31008 --- /dev/null +++ b/cluster/build_push_sif_seuss.bash @@ -0,0 +1,33 @@ +#!/bin/bash +# Build a docker image, convert it to as singularity image, and push it to the seuss cluster. +# Right now, this is a total hack since we can't actually build the docker image on the cluster, +# nor can we build the singularity image on the cluster. So we build the docker image locally, +# convert it to a singularity image locally, and then push it to the cluster. + +# Whole script fails if any command fails. + +set -e + +# Set some variables. +dockerhub_username=beisner +project_name=python_ml_project_template +scs_username=baeisner + +# Get paths. +script_path=$(realpath $0) +script_dir=$(dirname $script_path) +root_dir=$(realpath ${script_dir}/..) + +# Compute a good tag for the image, which will be /:-scratch. +sanitized_branch_name=`${script_dir}/sanitize_branch_name.bash` + +# Build the docker image. +docker build -t ${dockerhub_username}/${project_name}:${sanitized_branch_name}-scratch . + +# Convert the docker image to a singularity image, and save it in the .singularity_images directory. +mkdir -p ${root_dir}/.singularity_images +sif_name=${root_dir}/.singularity_images/${project_name}_${sanitized_branch_name}-scratch.sif +singularity build ${sif_name} docker-daemon://$dockerhub_username}/${project_name}:${sanitized_branch_name}-scratch + +# Rsync the singularity image to the seuss cluster. +rsync -avz --progress ${sif_name} ${scs_username}@seuss.ri.cmu.edu:/home/${scs_username}/singularity_images/ diff --git a/cluster/sanitize_branch_name.bash b/cluster/sanitize_branch_name.bash new file mode 100755 index 0000000..645302c --- /dev/null +++ b/cluster/sanitize_branch_name.bash @@ -0,0 +1,10 @@ +#!/bin/bash + +# Sanitize a branch name for use in a docker image tag. + +branch_name=$(git branch | grep \* | cut -d ' ' -f2) + +# Sanitize by replacing all slashes with underscores. +sanitized_branch_name=$(echo $branch_name | sed 's/\//_/g') + +echo $sanitized_branch_name