Skip to content

Commit

Permalink
Merge pull request #3 from r-pad/beneisner/push_sif_to_seuss
Browse files Browse the repository at this point in the history
set up pushing sif files to seuss
  • Loading branch information
beneisner authored Oct 2, 2024
2 parents 8784848 + 33cbbd1 commit d1465cd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -383,3 +383,6 @@ wandb_artifacts/
# Generated by hydra.
# outputs/
logs/

# Generated for pushing to seuss.
.singularity_images/
33 changes: 33 additions & 0 deletions cluster/build_push_sif_seuss.bash
Original file line number Diff line number Diff line change
@@ -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 <dockerhub_username>/<project_name>:<branch-name>-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/
10 changes: 10 additions & 0 deletions cluster/sanitize_branch_name.bash
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d1465cd

Please sign in to comment.