Skip to content

Commit

Permalink
build: minor fixes to script
Browse files Browse the repository at this point in the history
  • Loading branch information
ashay committed Sep 27, 2022
1 parent 3e2d5e0 commit 0f706a8
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/RollPyTorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,51 @@ jobs:
uses: ./.github/actions/setup-build
with:
cache-suffix: x86_64-out-of-tree-OFF
- name: Build Python wheels and smoke test.
- name: Determine nightly PyTorch version
run: |
cd $GITHUB_WORKSPACE
cd ${GITHUB_WORKSPACE}
python -m pip install wheel
# Fetch the most recent nightly PyTorch release
PT_RELEASE=$(python -m pip index versions -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --pre torch | grep "Available versions" | tr ' ' '\n' | grep "^[0-9]" | sort --version-sort --reverse | head -n1 | tr -d ',' | sed 's/\([^+]*\).*/\1/')
printf -- "-f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --pre torch==%s\n" "${PT_RELEASE}" > ./pytorch-requirements.txt
printf -- "-f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --pre torch==%s\n" "${PT_RELEASE}" > pytorch-requirements.txt
# Fetch the whl file associated with the nightly release
rm -f torch-"${PT_RELEASE}"*.whl
python -m pip download -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --pre "torch==${PT_RELEASE}"
# Read the commit hash from the downloaded whl file without extracting it
PT_HASH=$(unzip -p torch-"${PT_RELEASE}"*.whl torch/version.py | grep git_version | awk '{ print $3 }' | tr -d "'")
echo "$PT_HASH" > ./pytorch-version.txt
echo "${PT_HASH}" > pytorch-version.txt
rm torch-"${PT_RELEASE}"*.whl
# Write the release and hash to the environment file so that we can
# retrieve them when creating a PR
echo "PT_HASH=${PT_HASH}" >> $GITHUB_ENV
echo "PT_RELEASE=${PT_RELEASE}" >> $GITHUB_ENV
echo "PT_HASH=${PT_HASH}" >> ${GITHUB_ENV}
echo "PT_RELEASE=${PT_RELEASE}" >> ${GITHUB_ENV}
- name: Build and test
run: |
cd ${GITHUB_WORKSPACE}
TM_PACKAGES="out-of-tree" TM_USE_PYTORCH_BINARY="OFF" \
TORCH_MLIR_SRC_PYTORCH_BRANCH="${PT_HASH}" \
TORCH_MLIR_SRC_PYTORCH_RELEASE="${PT_RELEASE}" \
TORCH_MLIR_SRC_PYTORCH_BRANCH="${{ env.PT_HASH }}" \
TORCH_MLIR_SRC_PYTORCH_RELEASE="${{ env.PT_RELEASE }}" \
./build_tools/python_deploy/build_linux_packages.sh
- name: Push changes to new branch
uses: actions/checkout@v3
run: |
BRANCH="merge/pytorch-update-${{ env.PT_RELEASE }}"
TITLE="update PyTorch version to ${{ env.PT_RELEASE }}"
echo "BRANCH=${BRANCH}" >> ${GITHUB_ENV}
echo "TITLE=${TITLE}" >> ${GITHUB_ENV}
cd ${GITHUB_WORKSPACE}
git config user.email "torch-mlir@users.noreply.github.com"
git config user.name "Roll PyTorch Action"
git checkout -b "${BRANCH}"
git add pytorch-version.txt pytorch-requirements.txt
git commit -m "${TITLE}"
git push --set-upstream origin "${BRANCH}"
- name: Create PR to push new PyTorch version
run: |
URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
BODY="PyTorch commit hash: \`${{ env.PT_HASH }}\`\nCI link: ${URL}"
cd ${GITHUB_WORKSPACE}
gh pr create -H "${{ env.BRANCH }}" -B main --title "${{ env.TITLE }}" \
--body "${BODY}" --reviewer powderluv
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
run: |
git checkout -b "merge/pytorch-update-${{ env.PT_RELEASE }}"
gh pr create -H "merge/pytorch-update-${{ env.PT_RELEASE }}" -B main \
--title "build: update PyTorch version to nightly ${{ env.PT_RELEASE }}" \
--body "Corresponding PyTorch commit hash: `${{ env.PT_HASH }}`" \
--reviewer powderluv

0 comments on commit 0f706a8

Please sign in to comment.