Mineyev_Roman_I_rmineyev3 commited on
Commit ·
0a1c2c3
1
Parent(s): 09204af
Add images batch 20260512_223007
Browse files
upload.sh
CHANGED
|
@@ -3,20 +3,31 @@
|
|
| 3 |
# Uploads new images to Hugging Face repo every 5 minutes if there are changes.
|
| 4 |
# Usage: Go to terminal, go to microscope-data directory, and run `./upload.sh`
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
while true; do
|
| 10 |
-
# Check if there's anything new to commit
|
| 11 |
if [[ -n $(git status --porcelain) ]]; then
|
| 12 |
echo "[$(date)] Adding and committing..."
|
| 13 |
git add .
|
| 14 |
git commit -m "Add images batch $(date +%Y%m%d_%H%M%S)"
|
| 15 |
-
git push
|
| 16 |
-
echo "[$(date)] Pushed successfully."
|
| 17 |
else
|
| 18 |
echo "[$(date)] Nothing new to commit."
|
| 19 |
fi
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
sleep $INTERVAL
|
| 22 |
done
|
|
|
|
| 3 |
# Uploads new images to Hugging Face repo every 5 minutes if there are changes.
|
| 4 |
# Usage: Go to terminal, go to microscope-data directory, and run `./upload.sh`
|
| 5 |
|
| 6 |
+
# If you don't want computer to turn off during long uploads:
|
| 7 |
+
# systemd-inhibit bash upload.sh
|
| 8 |
|
| 9 |
+
#!/bin/bash
|
| 10 |
+
|
| 11 |
+
INTERVAL=310
|
| 12 |
|
| 13 |
while true; do
|
|
|
|
| 14 |
if [[ -n $(git status --porcelain) ]]; then
|
| 15 |
echo "[$(date)] Adding and committing..."
|
| 16 |
git add .
|
| 17 |
git commit -m "Add images batch $(date +%Y%m%d_%H%M%S)"
|
|
|
|
|
|
|
| 18 |
else
|
| 19 |
echo "[$(date)] Nothing new to commit."
|
| 20 |
fi
|
| 21 |
|
| 22 |
+
echo "[$(date)] Pushing..."
|
| 23 |
+
push_output=$(git push 2>&1)
|
| 24 |
+
echo "$push_output"
|
| 25 |
+
|
| 26 |
+
if echo "$push_output" | grep -q "Everything up-to-date"; then
|
| 27 |
+
echo "[$(date)] All done, everything is up to date!"
|
| 28 |
+
break
|
| 29 |
+
fi
|
| 30 |
+
|
| 31 |
+
echo "[$(date)] Waiting ${INTERVAL}s..."
|
| 32 |
sleep $INTERVAL
|
| 33 |
done
|