Skip to content

Commit

Permalink
add retry mechanism and makefile phony
Browse files Browse the repository at this point in the history
* context: pip install fails on large files due to network instability

Signed-off-by: Jack Luar <[email protected]>
  • Loading branch information
luarss committed Jan 10, 2025
1 parent 18b521f commit 7a48e12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tools/AutoTuner/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: init

clearcache:
@echo "Cleaning python cache"
@find . -type d -name __pycache__ -exec rm -r {} \+
Expand Down
23 changes: 21 additions & 2 deletions tools/AutoTuner/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ script_dir="$(dirname "${BASH_SOURCE[0]}")"
venv_name="autotuner_env"
python3 -m venv "$script_dir/$venv_name"
source "$script_dir/$venv_name/bin/activate"
pip3 cache purge
pip3 install --no-cache-dir -U -r $script_dir/requirements.txt
retry_count=0
max_retries=5
success=false

while [[ $retry_count -lt $max_retries ]]; do
if pip3 cache purge && pip3 install --no-cache-dir -U -r "$script_dir/requirements.txt"; then
success=true
break
else
retry_count=$((retry_count + 1))
echo "Attempt $retry_count failed. Retrying in 1 minute..."
sleep 60
fi
done

if [ "$success" = false ]; then
echo "Failed to install requirements after $max_retries attempts."
deactivate
exit 1
fi

deactivate

0 comments on commit 7a48e12

Please sign in to comment.