From ace8dd6087be68a2e4869b5341158258b08045d6 Mon Sep 17 00:00:00 2001 From: Xi Yan Date: Mon, 13 Jan 2025 17:53:38 -0800 Subject: [PATCH] [CI/CD] more robust re-try for downloading testpypi package (#749) # What does this PR do? - Context: Our current `sleep 10` may not be enough time for uploaded testpypi to be able to be downloadable. - Solution: Add re-try logic for at most 1 minute to download testpypi package and test the downloaded package. ## Test Plan - Triggered workflow: https://github.com/meta-llama/llama-stack/actions/runs/12753561894/job/35545490629?pr=749 image ## Sources Please link relevant resources if necessary. ## Before submitting - [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). - [ ] Ran pre-commit to handle lint / formatting issues. - [ ] Read the [contributor guideline](https://github.com/meta-llama/llama-stack/blob/main/CONTRIBUTING.md), Pull Request section? - [ ] Updated relevant documentation. - [ ] Wrote necessary unit or integration tests. --- .github/workflows/publish-to-test-pypi.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index 1ba1cac7a..957761235 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -202,8 +202,21 @@ jobs: steps: - name: Install the package run: | - sleep 10 - pip install --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ llama-stack==${{ needs.trigger-client-and-models-build.outputs.version }} + max_attempts=6 + attempt=1 + while [ $attempt -le $max_attempts ]; do + echo "Attempt $attempt of $max_attempts to install package..." + if pip install --no-cache --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ llama-stack==${{ needs.trigger-client-and-models-build.outputs.version }}; then + echo "Package installed successfully" + break + fi + if [ $attempt -ge $max_attempts ]; then + echo "Failed to install package after $max_attempts attempts" + exit 1 + fi + attempt=$((attempt + 1)) + sleep 10 + done - name: Test the package versions run: | pip list | grep llama_