Skip to content

Instantly share code, notes, and snippets.

@creotiv
Last active April 15, 2021 09:41
Show Gist options
  • Save creotiv/0d296ec8d8e576a4d2253960580257b5 to your computer and use it in GitHub Desktop.
Save creotiv/0d296ec8d8e576a4d2253960580257b5 to your computer and use it in GitHub Desktop.
Script to run ml code from git in parallel without changing branch
if [ ! -d ".git" ]; then
echo "Error: Git not initialized. Maybe running not from root dir?"
exit 0
fi
if ! grep -q .run/ ".gitignore"; then
echo -e "\\n.run/" >> .gitignore
fi
path=./.run/
while getopts ":b:" flag; do
case "${flag}" in
b) branch=${OPTARG};;
esac
done
cmd=${@:3}
path=$path$branch
rm -rf $path
mkdir $path
git clone --shared --branch $branch ./ $path
rm -rf $path/.git
base=$(pwd)
cd $path && BASEPATH=$base $cmd || cd ../../

Use

./ml.sh -b master python3 test.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment