Create PR with Dependency Update #509
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create PR with Dependency Update | |
| on: | |
| schedule: | |
| - cron: '0 8 * * *' # Runs at 08:00 UTC every day | |
| workflow_dispatch: # Manual trigger | |
| jobs: | |
| fetch-release-and-create-pr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| env: | |
| repo_url: "https://pypi.eng.aws.tenstorrent.com/ttnn/" | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Fetch Latest Pre-release from Another Repo | |
| id: fetch_release | |
| run: | | |
| # Pull links from internal pypi, sort by version, take the last one (newest) | |
| latest_pre_release=$(curl -s ${{ env.repo_url }} | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep cp310 | sort -V | tail -n 1) | |
| echo "release=$latest_pre_release" >> $GITHUB_OUTPUT | |
| latest_release_name_short=$(curl -s ${{ env.repo_url }} | sed -n 's/.*href=".*>ttnn-\(.*\)-cp310-c.*/\1/p' | sort -V | tail -n 1) | |
| echo "release_short=$latest_release_name_short" >> $GITHUB_OUTPUT | |
| - name: Update requirements.txt | |
| id: update-requirements | |
| run: | | |
| # Remove any existing ttnn lines (adjust the regex if needed) | |
| sed -i '/^ttnn @ /d' requirements.txt | |
| # Append the line for the newest version | |
| echo "ttnn @ ${{ env.repo_url }}${{steps.fetch_release.outputs.release}} ; python_version==\"3.10\"" >> requirements.txt | |
| - name: Update setup.py and pyproject.toml | |
| run: | | |
| latest_version=${{ steps.fetch_release.outputs.release }} | |
| latest_version_short=$(echo $latest_version | sed 's/-rc/rc/') | |
| ttnn_url="ttnn @ https://github.com/tenstorrent/tt-metal/releases/download/v${latest_version}/ttnn-$latest_version_short-cp310-cp310-linux_x86_64.whl" | |
| platform_constraint=" ; python_version=='3.10' and platform_system=='Linux' and platform_machine=='x86_64'" | |
| # Update setup.py - using the get_ttnn_url() function | |
| sed -i "s|ttnn @ https://github.com/tenstorrent/tt-metal/releases/download/v[0-9.]*-rc[0-9]*/ttnn-[0-9.]*rc[0-9]*-cp310-cp310-linux_x86_64.whl.*|$ttnn_url$platform_constraint|g" setup.py | |
| # Update pyproject.toml - using the same format as setup.py | |
| sed -i "s|ttnn @ https://github.com/tenstorrent/tt-metal/releases/download/v[0-9.]*-rc[0-9]*/ttnn-[0-9.]*rc[0-9]*-cp310-cp310-linux_x86_64.whl.*|$ttnn_url$platform_constraint|g" pyproject.toml | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| id: create-pr | |
| with: | |
| branch: update-dependency | |
| branch-suffix: timestamp | |
| committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
| author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | |
| base: main | |
| commit-message: "Update dependencies to ${{ steps.fetch_release.outputs.release }}" | |
| title: "Update TT-NN to ${{ steps.fetch_release.outputs.release_short }}" | |
| body: "This PR updates TT-NN wheel to the latest pre-release version." | |
| labels: ttnn-wheel-update | |
| delete-branch: true | |
| token: ${{ secrets.GH_TOKEN }} | |
| - name: Approve Pull Request | |
| if: ${{ steps.create-pr.outputs.pull-request-number }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}" | |
| echo "Pull Request URL - ${{ steps.create-pr.outputs.pull-request-url }}" | |
| gh pr review ${{ steps.create-pr.outputs.pull-request-number }} --approve | |
| - name: Enable Pull Request Automerge | |
| if: ${{ steps.create-pr.outputs.pull-request-number }} | |
| run: gh pr merge --merge --auto "${{ steps.create-pr.outputs.pull-request-number }}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| build_cache_cpp_extension: | |
| runs-on: ["in-service", "nfs"] | |
| container: | |
| image: ${{ github.event.inputs.docker_tag || 'ghcr.io/tenstorrent/pytorch2.0_ttnn/ubuntu-22.04-amd64:latest' }} | |
| credentials: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GH_TOKEN }} | |
| options: >- | |
| --rm -v /dev/hugepages-1G:/dev/hugepages-1G --device /dev/tenstorrent | |
| -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} | |
| -v /mnt/tt-metal-pytorch-cache/.cache:/root/.cache | |
| env: | |
| CACHE_DIR: /root/.cache/cpp-extension-cache | |
| repo_url: "https://pypi.eng.aws.tenstorrent.com/ttnn/" | |
| steps: | |
| # TODO: checkout must be changed to main once branch is merged | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| fetch-depth: 0 | |
| submodules: "recursive" | |
| ref: main | |
| - name: Update system | |
| run: | | |
| apt update -y && apt upgrade -y | |
| apt install -y curl jq | |
| - name: Update .gitsubmodules | |
| run: | | |
| # The name of the link nearly matches the spec from git describe. Modify and use that | |
| latest_release_name_short=$(curl -s ${{ env.repo_url }} | sed -n 's/.*href=".*>ttnn-\(.*\)-cp310-c.*/\1/p' | sort -V | tail -n 1) | |
| # prepend v, change dev to -, and change +g to -g | |
| latest_version=$(echo $latest_release_name_short | sed -e 's/.dev/-/' -e 's/+g/-g/' -e 's/^/v/') | |
| sed -i "/\[submodule \"torch_ttnn\/cpp_extension\/third-party\/tt-metal\"\]/,/^\[/{s/^\s*branch\s*=.*/\tbranch = $latest_version/}" .gitmodules | |
| echo "Updated .gitmodules with the latest version: $latest_version" | |
| - name: Build C++ Extensions | |
| uses: ./.github/actions/build_cpp_extension_artifacts |