Skip to content

Commit eb1b2c5

Browse files
marc0oloclaude
andcommitted
fix(rust/face-recognition): remove setup_models() fast path from upload script
Calling setup_models() before uploading panics on a fresh deploy because storage::bytes() calls unwrap() on a non-existent file. The fast path is now redundant — post_upgrade handles the upgrade case automatically (models_ready() returns true before the sync step runs), so the models_ready() check is sufficient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 293ccf8 commit eb1b2c5

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

rust/face-recognition/upload-models-to-canister.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,15 @@ PYEOF
4545
fi
4646

4747
# Skip if models are already loaded.
48+
# On canister upgrades, post_upgrade auto-reloads models from stable memory so
49+
# models_ready() returns true here without any upload needed.
4850
result=$(icp canister call --query backend models_ready '()' 2>/dev/null || echo "(false)")
49-
echo "models_ready: $result"
5051
if echo "$result" | grep -q 'true'; then
5152
echo "Models already loaded — skipping upload."
5253
exit 0
5354
fi
5455

55-
# If the canister was upgraded (not reinstalled), model files are still in stable
56-
# memory but heap state was cleared. Calling setup_models() reloads them without
57-
# re-uploading 100MB+.
58-
setup_result=$(icp canister call backend setup_models '()' 2>/dev/null || echo "(variant { Err })")
59-
if ! echo "$setup_result" | grep -q 'Err'; then
60-
echo "Models reloaded from stable memory (no re-upload needed)."
61-
exit 0
62-
fi
63-
64-
echo "Models not in stable memory — uploading..."
56+
echo "Models not loaded — uploading..."
6557

6658
which ic-file-uploader || cargo install ic-file-uploader
6759

0 commit comments

Comments
 (0)