2023-09-26 18:52:11 +00:00
#!/bin/bash
set -e
MODEL_ID = $1
ACCESS_TOKEN = $2
usage( ) {
echo " Usage: $0 <model_id> <access_token> "
exit 1
}
if [ -z " ${ MODEL_ID } " ] ; then
usage
fi
2023-10-26 23:46:20 +00:00
git clone https://oauth2:${ ACCESS_TOKEN } @www.modelscope.cn/$MODEL_ID .git ms_model --depth 1 || true
git clone https://huggingface.co/$MODEL_ID hf_model --depth 1 || true
2023-09-26 18:52:11 +00:00
echo "Sync directory"
2023-09-26 20:09:59 +00:00
rsync -avh --exclude '.git' --delete hf_model/ ms_model/
2023-09-26 18:52:11 +00:00
echo "Create README.md"
cat <<EOF >ms_model/RE ADME.md
---
license: other
tasks:
- text-generation
---
# ${MODEL_ID}
This is an mirror of [ ${ MODEL_ID } ] ( https://huggingface.co/${ MODEL_ID } ) .
2023-09-26 20:09:59 +00:00
[ Tabby] ( https://github.com/TabbyML/tabby) is a self-hosted AI coding assistant, offering an open-source and on-premises alternative to GitHub Copilot. It boasts several key features:
* Self-contained, with no need for a DBMS or cloud service.
* OpenAPI interface, easy to integrate with existing infrastructure ( e.g Cloud IDE) .
* Supports consumer-grade GPUs.
2023-09-26 18:52:11 +00:00
EOF
echo "Create configuration.json"
cat <<EOF >ms_model/configuration.json
{
"framework" : "pytorch" ,
"task" : "text-generation" ,
"pipeline" : {
"type" : "text-generation-pipeline"
}
}
EOF
2023-10-26 23:46:20 +00:00
push_origin( ) {
git lfs push origin --all
git push origin
}
2023-09-26 18:52:11 +00:00
set -x
2023-09-26 20:09:59 +00:00
pushd ms_model
2023-09-26 18:52:11 +00:00
git add .
2023-10-26 23:46:20 +00:00
git commit -m "sync with upstream" || true
while true; do
push_origin && break
done
2023-09-26 20:09:59 +00:00
popd
2023-09-26 18:52:11 +00:00
echo "Success!"
rm -rf hf_model
rm -rf ms_model