Skip to content

Commit 7ae55b7

Browse files
committed
modify base to be reusable, change build.sh to install nightly, add nightly workflow, change normal workflow to use reusable
1 parent 20d0478 commit 7ae55b7

File tree

4 files changed

+42
-176
lines changed

4 files changed

+42
-176
lines changed

.github/workflows/_build-tutorials-base.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: Build tutorials
22

33
on:
4-
pull_request:
5-
push:
6-
branches:
7-
- main
4+
workflow_call:
5+
inputs:
6+
USE_NIGHTLY:
7+
description: "Use nightly builds inside build.sh"
8+
required: false
9+
type: number
10+
default: false
811

912
concurrency:
1013
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
@@ -73,6 +76,7 @@ jobs:
7376
COMMIT_ID: ${{ github.sha }}
7477
JOB_TYPE: worker
7578
COMMIT_SOURCE: ${{ github.ref }}
79+
USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }}
7680
run: |
7781
set -ex
7882
@@ -85,6 +89,7 @@ jobs:
8589
-e COMMIT_ID \
8690
-e JOB_TYPE \
8791
-e COMMIT_SOURCE \
92+
-e USE_NIGHTLY \
8893
--env-file="/tmp/github_env_${GITHUB_RUN_ID}" \
8994
--tty \
9095
--detach \
@@ -139,11 +144,12 @@ jobs:
139144
env:
140145
DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
141146
NUM_WORKERS: 15
142-
WORKER_ID: ${{ matrix.shard }}
147+
WORKER_ID: 0
143148
COMMIT_ID: ${{ github.sha }}
144149
JOB_TYPE: manager
145150
COMMIT_SOURCE: ${{ github.ref }}
146151
GITHUB_PYTORCHBOT_TOKEN: ${{ secrets.PYTORCHBOT_TOKEN }}
152+
USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }}
147153
run: |
148154
set -ex
149155
@@ -157,6 +163,7 @@ jobs:
157163
-e JOB_TYPE \
158164
-e COMMIT_SOURCE \
159165
-e GITHUB_PYTORCHBOT_TOKEN \
166+
-e USE_NIGHTLY \
160167
--env-file="/tmp/github_env_${GITHUB_RUN_ID}" \
161168
--tty \
162169
--detach \
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Build tutorials against nightly or test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
uses: ./.github/workflows/_build-tutorials-base.yml
16+
secrets: inherit
17+
with:
18+
USE_NIGHTLY: 1

.github/workflows/build-tutorials.yml

Lines changed: 5 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -11,173 +11,8 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
worker:
15-
name: pytorch_tutorial_build_worker
16-
strategy:
17-
matrix:
18-
include:
19-
- { shard: 1, num_shards: 15, runner: "linux.g5.12xlarge.nvidia.gpu" }
20-
- { shard: 2, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
21-
- { shard: 3, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
22-
- { shard: 4, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
23-
- { shard: 5, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
24-
- { shard: 6, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
25-
- { shard: 7, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
26-
- { shard: 8, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
27-
- { shard: 9, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
28-
- { shard: 10, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
29-
- { shard: 11, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
30-
- { shard: 12, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
31-
- { shard: 13, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
32-
- { shard: 14, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
33-
- { shard: 15, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
34-
fail-fast: false
35-
runs-on: ${{ matrix.runner }}
36-
steps:
37-
- name: Setup SSH (Click me for login details)
38-
uses: pytorch/test-infra/.github/actions/setup-ssh@main
39-
with:
40-
github-secret: ${{ secrets.GITHUB_TOKEN }}
41-
instructions: |
42-
All testing is done inside the container, to start an interactive session run:
43-
docker exec -it $(docker container ps --format '{{.ID}}') bash
44-
45-
- name: Checkout Tutorials
46-
uses: actions/checkout@v3
47-
with:
48-
fetch-depth: 0
49-
50-
- name: Setup Linux
51-
uses: pytorch/pytorch/.github/actions/setup-linux@main
52-
53-
- name: Install nvidia driver, nvidia-docker runtime, set GPU_FLAG
54-
uses: pytorch/test-infra/.github/actions/setup-nvidia@main
55-
56-
- name: Calculate/build docker image
57-
id: calculate-docker-image
58-
uses: pytorch/test-infra/.github/actions/calculate-docker-image@main
59-
with:
60-
docker-image-name: tutorials
61-
62-
- name: Pull docker image
63-
uses: pytorch/test-infra/.github/actions/pull-docker-image@main
64-
with:
65-
docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }}
66-
67-
- name: Build
68-
shell: bash
69-
env:
70-
DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
71-
NUM_WORKERS: ${{ matrix.num_shards }}
72-
WORKER_ID: ${{ matrix.shard }}
73-
COMMIT_ID: ${{ github.sha }}
74-
JOB_TYPE: worker
75-
COMMIT_SOURCE: ${{ github.ref }}
76-
run: |
77-
set -ex
78-
79-
chmod +x ".jenkins/build.sh"
80-
81-
container_name=$(docker run \
82-
${GPU_FLAG:-} \
83-
-e WORKER_ID \
84-
-e NUM_WORKERS \
85-
-e COMMIT_ID \
86-
-e JOB_TYPE \
87-
-e COMMIT_SOURCE \
88-
--env-file="/tmp/github_env_${GITHUB_RUN_ID}" \
89-
--tty \
90-
--detach \
91-
--shm-size=2gb \
92-
--name="${container_name}" \
93-
-v "${GITHUB_WORKSPACE}:/var/lib/workspace" \
94-
-w /var/lib/workspace \
95-
"${DOCKER_IMAGE}"
96-
)
97-
98-
docker exec -u ci-user -t "${container_name}" sh -c ".jenkins/build.sh"
99-
100-
- name: Teardown Linux
101-
uses: pytorch/test-infra/.github/actions/teardown-linux@main
102-
if: always()
103-
104-
manager:
105-
name: pytorch_tutorial_build_manager
106-
needs: worker
107-
runs-on: [self-hosted, linux.2xlarge]
108-
environment: ${{ github.ref == 'refs/heads/main' && 'pytorchbot-env' || '' }}
109-
steps:
110-
- name: Setup SSH (Click me for login details)
111-
uses: pytorch/test-infra/.github/actions/setup-ssh@main
112-
with:
113-
github-secret: ${{ secrets.GITHUB_TOKEN }}
114-
instructions: |
115-
All testing is done inside the container, to start an interactive session run:
116-
docker exec -it $(docker container ps --format '{{.ID}}') bash
117-
118-
- name: Checkout Tutorials
119-
uses: actions/checkout@v3
120-
with:
121-
fetch-depth: 0
122-
123-
- name: Setup Linux
124-
uses: pytorch/pytorch/.github/actions/setup-linux@main
125-
126-
- name: Calculate/build docker image
127-
id: calculate-docker-image
128-
uses: pytorch/test-infra/.github/actions/calculate-docker-image@main
129-
with:
130-
docker-image-name: tutorials
131-
132-
- name: Pull docker image
133-
uses: pytorch/test-infra/.github/actions/pull-docker-image@main
134-
with:
135-
docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }}
136-
137-
- name: Build
138-
shell: bash
139-
env:
140-
DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
141-
NUM_WORKERS: 15
142-
WORKER_ID: ${{ matrix.shard }}
143-
COMMIT_ID: ${{ github.sha }}
144-
JOB_TYPE: manager
145-
COMMIT_SOURCE: ${{ github.ref }}
146-
GITHUB_PYTORCHBOT_TOKEN: ${{ secrets.PYTORCHBOT_TOKEN }}
147-
run: |
148-
set -ex
149-
150-
chmod +x ".jenkins/build.sh"
151-
152-
container_name=$(docker run \
153-
${GPU_FLAG:-} \
154-
-e WORKER_ID \
155-
-e NUM_WORKERS \
156-
-e COMMIT_ID \
157-
-e JOB_TYPE \
158-
-e COMMIT_SOURCE \
159-
-e GITHUB_PYTORCHBOT_TOKEN \
160-
--env-file="/tmp/github_env_${GITHUB_RUN_ID}" \
161-
--tty \
162-
--detach \
163-
--name="${container_name}" \
164-
-v "${GITHUB_WORKSPACE}:/var/lib/workspace" \
165-
-w /var/lib/workspace \
166-
"${DOCKER_IMAGE}"
167-
)
168-
169-
docker exec -u ci-user -t "${container_name}" sh -c ".jenkins/build.sh"
170-
171-
- name: Upload docs preview
172-
uses: seemethere/upload-artifact-s3@v5
173-
if: ${{ github.event_name == 'pull_request' }}
174-
with:
175-
retention-days: 14
176-
s3-bucket: doc-previews
177-
if-no-files-found: error
178-
path: docs
179-
s3-prefix: pytorch/tutorials/${{ github.event.pull_request.number }}
180-
181-
- name: Teardown Linux
182-
uses: pytorch/test-infra/.github/actions/teardown-linux@main
183-
if: always()
14+
build:
15+
uses: ./.github/workflows/_build-tutorials-base.yml
16+
secrets: inherit
17+
with:
18+
USE_NIGHTLY: 0

.jenkins/build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ sudo apt-get install -y pandoc
1919
# NS: Path to python runtime should already be part of docker container
2020
# export PATH=/opt/conda/bin:$PATH
2121

22-
#Install PyTorch Nightly for test.
22+
# Install PyTorch Nightly for test.
23+
if [ "$USE_NIGHTLY" -eq 1 ]; then
24+
sudo pip uninstall -y torch
25+
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu130
26+
pip show torch
27+
fi
28+
2329
# Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
2430
# Install 2.5 to merge all 2.4 PRs - uncomment to install nightly binaries (update the version as needed).
2531
# sudo pip uninstall -y fbgemm-gpu torchrec

0 commit comments

Comments
 (0)