Update export script to auto package tar and calculate md5

pull/25/merge
Matthew Scholefield 2018-10-12 11:04:08 -05:00
parent da286a2dd7
commit 6b34a58339
1 changed files with 32 additions and 9 deletions

View File

@ -13,15 +13,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if ! [[ "$1" =~ .*\.net$ ]] || ! [ -d "$2" ]; then
echo "Usage: $0 <model>.net <folder_name>"
if ! [[ "$1" =~ .*\.net$ ]] || ! [ -f "$1" ] || [ "$#" != "1" ]; then
echo "Usage: $0 <model>.net"
exit 1
fi
[ -d .cache/precise-data ] || git clone https://github.com/mycroftai/precise-data .cache/precise-data
model_name=$(date +"${1%%net}%y-%m-%d")
precise/scripts/convert.py $1 -o "$2/$model_name.pb"
cp "$1" "$2/$model_name.net"
cp "$1.params" "$2/$model_name.net.params"
mv "$model_name.pb" "$model_name.pb.params" "$2"
echo "Converted to $2/$model_name.*"
model_file=$(readlink -f "$1")
cd "$(dirname "$0")"
set -e
cache=.cache/precise-data
[ -d "$cache" ] || git clone https://github.com/mycroftai/precise-data "$cache" -b models --single-branch
pushd "$cache"
git fetch
git checkout models
git reset --hard origin/models
popd
source .venv/bin/activate
model_name=$(basename "${1%%.net}")
precise-convert "$model_file" -o "$cache/$model_name.pb"
read -p "Uploading $model_file to public repo with name \"$model_name\". Confirm? (y/n) " response
if [ "$response" != "y" ] && [ "$response" != "Y" ]; then
return 1
fi
pushd "$cache"
tar cvf "$model_name.tar.gz" "$model_name.pb" "$model_name.pb.params"
md5sum "$model_name.tar.gz" > "$model_name.tar.gz.md5"
rm -f "$model_name.pb" "$model_name.pb.params" "$model_name.pbtxt"
git reset
git add "$model_name.tar.gz" "$model_name.tar.gz.md5"
git commit -m "Update $model_name"
git push
popd