forked from beneisner/python_pkg_template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from r-pad/beneisner/push_sif_to_seuss
set up pushing sif files to seuss
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 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,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/ |
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,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 |