-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade/install fixes #322
base: master
Are you sure you want to change the base?
Upgrade/install fixes #322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below about 14637dc.
install.sh
Outdated
@@ -77,7 +77,9 @@ if [ $upgrade -eq 1 -a $makerfaire2018 -eq 0 -a -d ${home_dir}/wm8960 ]; then | |||
cd ${home_dir}/wm8960 | |||
sudo chown -R ${owner} .git | |||
pull=`git pull` | |||
if [ "$pull" != "Already up to date." ]; then | |||
if [ "$pull" == "Already up to date." -o "$pull" == "Déjà à jour." ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for French, but what about other non-English languages?...
I think a simpler/more general solution would be to just add the line:
export LANGUAGE=
at the beginning of the script, so that git
always outputs messages in the default (English) language.
be823f2
to
45dcbb6
Compare
PR purged from duplicated commits to focus on the smarter builds & models generation ;) |
45dcbb6
to
817685d
Compare
All good and happy TagTagTag running on debian 11 upgraded from the latest debian 10 image released :) |
So apparently the newer version of Git in Raspbian 11 also slightly changes the message when the clone is already up-to-date:
|
Just curious: What exact version of Git is this? Where/how did you get it? |
I was very surprised to see this slightly different message too on my dev Pi.
I was not aware that Git could provide alternate variants of the update status but apparently it does. |
To the best of my knowledge, it does not (and this has not changed recently): Git is just
|
As you can see, my Git config is minimal too (just the name+email to be able to create a commit if necessary):
For the reproducer, the official pynab image won't do as it is a debian 10 (except if you want me to do another debian 10 to 11 upgrade in place). |
You can use one of the images from my v0.9.1+fl0.9.3 release:
|
So with the debian 11 image (zero_raspios), it works out-of-the-box and with all updates applied (no change in Git version after update):
Next text will be to test with the debian 10 image (zero_raspbian) and after upgrading it to debian 11 in place... ;) UPDATE: with the debian 10 image from your fork, I got BOTH output:
The plot thickens... 😁 |
Do you think this is worth the effort? |
I was thinking that if you are concerned that the proposed wildcard may be too generous, I can also replace it by a strict match to "Already up to date." and add another possible strict match to "Current branch release is up to date." (any other branch being development so not being too concerned about optimizing here). |
Not at all. Your proposed change seems technically fine. |
This is when you do a
Well... It was so obvious that we missed it, but here is what triggered the message wording change in your original Git config:
since this makes |
install.sh
Outdated
pull=$(LANGUAGE=en git pull) | ||
if [ "$pull" == "Already up to date." ]; then | ||
if [[ "$pull" == *" up to date." ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change might rather be:
pull=$(LANGUAGE=en git pull --no-rebase)
(with no change in the "Already up to date." test)
b089215
to
817685d
Compare
As the whole point is to make sure the script behaves properly and as efficiently as possible, I reverted the extra commit as the default configuration of git in the image as well as the script are using a regular pull without rebase. The good news is: if there is a decision to change the git pull command, default git config or just see that the rebase is used more frequently than we thought, we already have the diff ready to be applied ;) At least now we went to the bottom of the problem and back and have the satisfaction that we did not hold anybody up (as I don´t think the repo admins are waiting for this to merge the PR 😛 ). Great catch ! |
So as QEmu failed the rebuild after the commit removal, I ended up using the second push to implement the --no-rebase (instead of just a dummy commit). |
Forcing |
install.sh
Outdated
if [ -d "${ENGINE}" ]; then | ||
# | ||
file_age=$(stat -c %Y "${ENGINE}") | ||
epoch_now=$(date +"%s") | ||
# | ||
#Trying to save some time & CPU in case the dataset was generated already today | ||
if (( (epoch_now - file_age) > (60 * 60 * 24) )); then | ||
rm -rf "${ENGINE}" | ||
venv/bin/snips-nlu train nabd/nlu/nlu_dataset_${LANG}.json ${ENGINE} | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This optimisation may not be desirable.
It may indeed seem overkill to re-train the NLU engine when the install.sh
script is invoked repeatedly, for testing purposes or whatever.
But in the general use case (regular update) this optimisation will be a problem in the (unlikely but possible) case of 2 successive (less than 24h apart) updates where the second update includes a change in NLU source data: this change will then be missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original scenario was to run the upgrade script after upgrading the OS and having it fail at different points (early adopter). You are right that 24h may be a bit generous. But the idea is to save CPU and time when running it again and again within a window of a few hours.
We could drop the threshold to 2h...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could drop the threshold to 2h...
That would still leave a window for failure.
But the idea is to save CPU and time when running it again and again within a window of a few hours.
Sure.
But if you want to have this "optimisation" in a public commit, you should at least condition it by the install.sh
test
parameter/flag (or rather a new adhoc parameter/flag).
The early adopter/tester would then set this flag when running install.sh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. As implementing a new flag for the install.sh would be a decent PR on its own, I removed this change from the diff to keep only the efforts around the git commands.
I still have to apply the additional --no-rebase in the upgrade.sh but I keep it as a reason to push the CI to rebuild (as it is not very cooperative lately...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this change from the diff to keep only the efforts around the git commands.
Fine. You can still keep the optimisation in a private commit, and just git cherry-pick
it for your tests...
.... to push the CI to rebuild (as it is not very cooperative lately...).
Well, for this there is no hope till issue #329 is fixed...
I checked the upgrade.sh script and in this case there is no check of the output. So we could apply the --no-rebase but like for the LANG= change, it may not be necessary per-se (but could be still put there for the sake of consistency). |
9409c3f
to
895438c
Compare
Indeed. But this is not the issue. |
db412f0
to
3878c0f
Compare
@Commit-La-Grenouille : Thanks for all your work on this PR...
|
b36c32c
to
c1fc141
Compare
PR renamed and changes unified under a unique commit. That is exactly the point of the PR flow: brainstorming to make sure the change is the prettiest it can before going into the main branch ;) |
upgrade.sh
Outdated
sudo -u ${owner} touch /tmp/pynab.upgrade | ||
sudo chown ${owner} /tmp/pynab.upgrade | ||
echo "Updating code - 1/?" > /tmp/pynab.upgrade | ||
cd ${root_dir} | ||
if [[ $EUID -ne ${ownerid} ]]; then | ||
sudo -u ${owner} git pull | ||
sudo -u ${owner} git pull --no-rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we would want --no-rebase here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context is that when there is a default rebase strategy active in the global git config, the up-to-date message returned by Git is slightly different from the one tested (see PR discussion earlier). I initially proposed to adjust the message matching to support "Already up-to-date" and "Branch XXX is up-to-date". @f-laurens suggested that the message could be made consistent by using --no-rebase.
install.sh
Outdated
@@ -76,7 +76,8 @@ if [ $upgrade -eq 1 -a $makerfaire2018 -eq 0 -a -d ${home_dir}/wm8960 ]; then | |||
echo "Updating sound driver - 2/14" > /tmp/pynab.upgrade | |||
cd ${home_dir}/wm8960 | |||
sudo chown -R ${owner} .git | |||
pull=`git pull` | |||
# Making sure we keep the up-to-date status message consistent no matter the rebase default behavior | |||
pull=$(LANGUAGE=en git pull --no-rebase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, I don't understand why we would like LANGUAGE=en here.
This code is not meant to be executed from an interactive session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See better implementaitons such as:
https://unix.stackexchange.com/questions/155046/determine-if-git-working-directory-is-clean-from-a-script/394674#394674
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point that there may be some porcelain/plumbing trick we can use to have a consistent status no matter what the locale & git config is active in the OS.
However, the git diff-index discussed in your link seems to work only where the local clone is ahead (or with untracked files) compared to remote. When I tried to test it with a local clone behind the remote (by doing a reset --hard to a previous commit & confirming that status reports a branch behind by X commits) the diff-index seems to return 0 the same way that when the branch is up-to-date.
I will keep on searching in the reference documentation until I hit something that could provide us a reliable way to tell if we have fresh code we want to rebuild ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I ended up decomposing the action in 3: doing a git fetch before, checking the local/remote discrepancy with status --porcelain (safest) and apply the pull if there is something to get and rebuild.
When there is no remote/local difference, the output looks like:
ᐅ git status --branch --porcelain
## bulleye_upgrade_fixes...origin/bulleye_upgrade_fixes
And where there is a difference:
ᐅ git status --branch --porcelain
## bulleye_upgrade_fixes...origin/bulleye_upgrade_fixes [behind 1]
As it is a change of strategy in the code, I kept the change in a separate commit for now until it is considered satisfactory (and then I can rebase everything into a single commit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, I don't understand why we would like LANGUAGE=en here. This code is not meant to be executed from an interactive session.
Just my 2 cts. If you want to have consistent messages in your scripts tests, use LC_ALL=C, not LANGUAGE=en. LANGUAGE=en will still depend on the English flavors (en-GB, en-US, en-CA...)
See https://unix.stackexchange.com/questions/87745/what-does-lc-all-c-do for a good explanation.
…atter the locale defined + keeping all git calls immune to explicit rebase config
c1fc141
to
5c8af62
Compare
…k of locale or rebase strategy impacting the result)
5c8af62
to
67d98b1
Compare
Quelques ajustements bienvenue pendant que je lançais et re-lançais le script de maj une fois passé à debian 11 (depuis l'image officielle en debian 10)