Last active
April 23, 2024 15:27
-
-
Save agostini01/1de77fde6dc2203ed4186f367f3efc28 to your computer and use it in GitHub Desktop.
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
#/bin/bash | |
set -o pipefail | |
set -e | |
# Verbose commands for now | |
set -x | |
# Check if the first argument is passed | |
if [ "$#" -eq 0 ]; then | |
echo "Error: No argument passed" | |
echo "Usage: pull-model-from-hf.sh https://huggingface.co/USER/PROJ <optional: file to pull>" | |
exit 1 | |
fi | |
INPUT=$1 | |
IFS='/' read -ra ADDR <<< "$INPUT" | |
declare -a arr=("${ADDR[@]}") | |
USER=${arr[3]} | |
REPO=${arr[4]} | |
echo "INPUT: $INPUT" | |
echo "User: $USER" | |
echo "Repo: $REPO" | |
# Check if the folder exists | |
if [ ! -d "$USER/$REPO" ]; then | |
# Control will enter here if $DIRECTORY doesn't exist. | |
mkdir -p $USER && pushd $USER && GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/$USER/$REPO && popd | |
fi | |
# Check if a second argument is passed | |
if [ "$#" -ne 2 ]; then | |
echo "No file to pull" | |
else | |
echo "Pulling file $2" | |
pushd $USER/$REPO && git lfs pull --include $2 && popd | |
fi | |
set +x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment