Skip to content

Commit 1b403be

Browse files
authored
[torch] Replace inline bash with write_torch_version.py. (#1120)
Splitting this off from #1100. Not tested recently.
1 parent 71e9a29 commit 1b403be

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

.github/workflows/build_portable_linux_pytorch_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ jobs:
146146
--index-url "${{ inputs.cloudfront_url }}/${{ inputs.amdgpu_family }}/" \
147147
--clean \
148148
--output-dir ${{ env.PACKAGE_DIST_DIR }} ${{ env.optional_build_prod_arguments }}
149-
echo "torch_version=`cd ${{ env.PACKAGE_DIST_DIR }}; python -c 'import glob; print(glob.glob("torch-*.whl")[0].split("-")[1])'`" >> $GITHUB_OUTPUT
149+
python ./build_tools/github_actions/write_torch_version.py
150150
151151
- name: Configure AWS Credentials
152152
if: always()

.github/workflows/build_windows_pytorch_wheels.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
PACKAGE_DIST_DIR: ${{ github.workspace }}\output\packages\dist
6565
S3_BUCKET_PY: "therock-${{ inputs.release_type }}-python"
6666
optional_build_prod_arguments: ""
67+
outputs:
68+
torch_version: ${{ steps.build-pytorch-wheels.outputs.torch_version }}
6769
defaults:
6870
run:
6971
# Note: there are mixed uses of 'bash' (this default) and 'cmd' below
@@ -112,6 +114,7 @@ jobs:
112114
--rocm-version ${{ inputs.rocm_version }}
113115
114116
- name: Build PyTorch Wheels
117+
id: build-pytorch-wheels
115118
# Using 'cmd' here is load bearing! There are configuration issues when
116119
# run under 'bash': https://github.com/ROCm/TheRock/issues/827#issuecomment-3025858800
117120
shell: cmd
@@ -126,6 +129,7 @@ jobs:
126129
--clean ^
127130
--output-dir ${{ env.PACKAGE_DIST_DIR }} ^
128131
${{ env.optional_build_prod_arguments }}
132+
python ./build_tools/github_actions/write_torch_version.py
129133
130134
- name: Configure AWS Credentials
131135
if: always()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
3+
"""Writes torch_version to GITHUB_OUTPUT."""
4+
5+
import os
6+
import glob
7+
8+
from github_actions_utils import *
9+
10+
11+
def main(argv: list[str]):
12+
# Get the torch version from the first torch wheel in PACKAGE_DIST_DIR.
13+
package_dist_dir = os.getenv("PACKAGE_DIST_DIR")
14+
version = glob.glob("torch-*.whl", root_dir=package_dist_dir)[0].split("-")[1]
15+
gha_set_output({"torch_version": version})
16+
17+
18+
if __name__ == "__main__":
19+
main(sys.argv[1:])

0 commit comments

Comments
 (0)