Skip to content

Commit 817685d

Browse files
INSTALL: regroup & skip NLU generation when it was generated less than 1 day ago
1 parent 14637dc commit 817685d

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

install.sh

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ if [ $upgrade -eq 1 -a $makerfaire2018 -eq 0 -a -d ${home_dir}/wm8960 ]; then
7676
echo "Updating sound driver - 2/14" > /tmp/pynab.upgrade
7777
cd ${home_dir}/wm8960
7878
sudo chown -R ${owner} .git
79-
pull=`git pull`
80-
if [ "$pull" == "Already up to date." -o "$pull" == "Déjà à jour." ]; then
79+
pull=$(LANGUAGE=en git pull)
80+
if [ "$pull" == "Already up to date." ]; then
8181
echo "Sound driver is already up-to-date..."
8282
else
8383
make && sudo make install && make clean
@@ -90,8 +90,8 @@ if [ $upgrade -eq 1 ]; then
9090
if [ -d ${home_dir}/tagtagtag-ears ]; then
9191
cd ${home_dir}/tagtagtag-ears
9292
sudo chown -R ${owner} .git
93-
pull=`git pull`
94-
if [ "$pull" == "Already up to date." -o "$pull" == "Déjà à jour." ]; then
93+
pull=$(LANGUAGE=en git pull)
94+
if [ "$pull" == "Already up to date." ]; then
9595
echo "Ears driver is already up-to-date..."
9696
else
9797
make && sudo make install && make clean
@@ -116,8 +116,8 @@ if [ $upgrade -eq 1 ]; then
116116
if [ -d ${home_dir}/cr14 ]; then
117117
cd ${home_dir}/cr14
118118
sudo chown -R ${owner} .git
119-
pull=`git pull`
120-
if [ "$pull" == "Already up to date." -o "$pull" == "Déjà à jour." ]; then
119+
pull=$(LANGUAGE=en git pull)
120+
if [ "$pull" == "Already up to date." ]; then
121121
echo "RFID driver is already up-to-date..."
122122
else
123123
make && sudo make install && make clean
@@ -142,8 +142,8 @@ if [ $upgrade -eq 1 ]; then
142142
if [ -d ${root_dir}/nabblockly ]; then
143143
cd ${root_dir}/nabblockly
144144
sudo chown -R ${owner} .
145-
pull=`git pull`
146-
if [ "$pull" == "Already up to date." -o "$pull" == "Déjà à jour." ]; then
145+
pull=$(LANGUAGE=en git pull)
146+
if [ "$pull" == "Already up to date." ]; then
147147
echo "NabBlockly is already up-to-date..."
148148
else
149149
./rebar3 release
@@ -238,14 +238,24 @@ if [ $makerfaire2018 -eq 0 ]; then
238238
venv/bin/python -m snips_nlu generate-dataset fr */nlu/intent_fr.yaml > nabd/nlu/nlu_dataset_fr.json
239239

240240
echo "Persisting Snips engines"
241-
if [ -d nabd/nlu/engine_en ]; then
242-
rm -rf nabd/nlu/engine_en
243-
fi
244-
venv/bin/snips-nlu train nabd/nlu/nlu_dataset_en.json nabd/nlu/engine_en
245-
if [ -d nabd/nlu/engine_fr ]; then
246-
rm -rf nabd/nlu/engine_fr
247-
fi
248-
venv/bin/snips-nlu train nabd/nlu/nlu_dataset_fr.json nabd/nlu/engine_fr
241+
#
242+
# Regroupping the logic for all the languages supported
243+
for LANG in "en" "fr"; do
244+
ENGINE="nabd/nlu/engine_${LANG}"
245+
if [ -d "${ENGINE}" ]; then
246+
#
247+
file_age=$(stat -c %Y "${ENGINE}")
248+
epoch_now=$(date +"%s")
249+
#
250+
#Trying to save some time & CPU in case the dataset was generated already today
251+
if (( (epoch_now - file_age) > (60 * 60 * 24) )); then
252+
rm -rf "${ENGINE}"
253+
venv/bin/snips-nlu train nabd/nlu/nlu_dataset_${LANG}.json ${ENGINE}
254+
fi
255+
else
256+
venv/bin/snips-nlu train nabd/nlu/nlu_dataset_${LANG}.json ${ENGINE}
257+
fi
258+
done
249259
fi
250260

251261
trust=`sudo grep local /etc/postgresql/*/main/pg_hba.conf | grep -cE '^local +all +all +trust' || echo -n ''`

0 commit comments

Comments
 (0)