Skip to content

Commit 6a20e87

Browse files
authored
Run tests right after each image build (#1576)
Previously, tests waited in a separate `Test` stage until **all** image builds (CPU, GPU, TPU) had finished. Since the GPU build is much slower, the CPU tests sat idle for a long time. Now each branch runs its tests and diff in parallel right after its own build: - **CPU:** `Test CPU Image`, `Test kaggle-environments` (uses the CPU image) and `Diff CPU Image` - **GPU:** `Test on T4x2` and `Diff GPU Image` - **TPU:** `Diff TPU VM Image` only, unchanged (TPU images are tested outside this pipeline, see b/336842777) Declarative pipelines don't allow nested `parallel` blocks inside a parallel branch, so each branch uses a scripted `parallel` inside a single `Test/Diff … Image` stage. Timeouts and `retry(2)` are unchanged. Tests now run on the same agent that built the image, at the same time as the diff. `Label CPU/GPU Staging Images` still waits for all branches to finish.
1 parent 042b92c commit 6a20e87

1 file changed

Lines changed: 62 additions & 65 deletions

File tree

‎Jenkinsfile‎

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,45 @@ pipeline {
3838
'''
3939
}
4040
}
41-
stage('Diff CPU image') {
41+
stage('Test/Diff CPU Image') {
4242
steps {
43-
sh '''#!/bin/bash
44-
set -exo pipefail
43+
script {
44+
parallel(
45+
'Test CPU Image': {
46+
timeout(time: 15, unit: 'MINUTES') {
47+
retry(2) {
48+
sh '''#!/bin/bash
49+
set -exo pipefail
4550
46-
docker pull gcr.io/kaggle-images/python:${PRETEST_TAG}
47-
./diff --target gcr.io/kaggle-images/python:${PRETEST_TAG}
48-
'''
51+
date
52+
docker pull gcr.io/kaggle-images/python:${PRETEST_TAG}
53+
./test --image gcr.io/kaggle-images/python:${PRETEST_TAG}
54+
'''
55+
}
56+
}
57+
},
58+
'Test kaggle-environments': {
59+
timeout(time: 15, unit: 'MINUTES') {
60+
sh '''#!/bin/bash
61+
set -exo pipefail
62+
docker run --rm \
63+
-e PYTHONUNBUFFERED=1 \
64+
--pull always \
65+
gcr.io/kaggle-images/python:${PRETEST_TAG} \
66+
bash -c "git clone https://github.com/Kaggle/kaggle-environments.git /tmp/kaggle-environments && cd /tmp/kaggle-environments && python -m pytest tests/ kaggle_environments/ --tb=short --ignore-glob='*/test_pyxis.py'"
67+
'''
68+
}
69+
},
70+
'Diff CPU Image': {
71+
sh '''#!/bin/bash
72+
set -exo pipefail
73+
74+
docker pull gcr.io/kaggle-images/python:${PRETEST_TAG}
75+
./diff --target gcr.io/kaggle-images/python:${PRETEST_TAG}
76+
'''
77+
}
78+
)
79+
}
4980
}
5081
}
5182
}
@@ -74,14 +105,33 @@ pipeline {
74105
'''
75106
}
76107
}
77-
stage('Diff GPU Image') {
108+
stage('Test/Diff GPU Image') {
78109
steps {
79-
sh '''#!/bin/bash
80-
set -exo pipefail
110+
script {
111+
parallel(
112+
'Test on T4x2': {
113+
timeout(time: 60, unit: 'MINUTES') {
114+
retry(2) {
115+
sh '''#!/bin/bash
116+
set -exo pipefail
81117
82-
docker pull gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
83-
./diff --gpu --target gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
84-
'''
118+
date
119+
docker pull gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
120+
./test --gpu --image gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
121+
'''
122+
}
123+
}
124+
},
125+
'Diff GPU Image': {
126+
sh '''#!/bin/bash
127+
set -exo pipefail
128+
129+
docker pull gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
130+
./diff --gpu --target gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
131+
'''
132+
}
133+
)
134+
}
85135
}
86136
}
87137
}
@@ -117,59 +167,6 @@ pipeline {
117167
}
118168
}
119169

120-
stage('Test') {
121-
parallel {
122-
stage('Test CPU Image') {
123-
options {
124-
timeout(time: 15, unit: 'MINUTES')
125-
}
126-
steps {
127-
retry(2) {
128-
sh '''#!/bin/bash
129-
set -exo pipefail
130-
131-
date
132-
docker pull gcr.io/kaggle-images/python:${PRETEST_TAG}
133-
./test --image gcr.io/kaggle-images/python:${PRETEST_TAG}
134-
'''
135-
}
136-
}
137-
}
138-
stage('Test on T4x2') {
139-
agent { label 'ephemeral-linux-gpu-t4x2' }
140-
options {
141-
timeout(time: 60, unit: 'MINUTES')
142-
}
143-
steps {
144-
retry(2) {
145-
sh '''#!/bin/bash
146-
set -exo pipefail
147-
148-
date
149-
docker pull gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
150-
./test --gpu --image gcr.io/kaggle-private-byod/python:${PRETEST_TAG}
151-
'''
152-
}
153-
}
154-
}
155-
stage('Test kaggle-environments') {
156-
options {
157-
timeout(time: 15, unit: 'MINUTES')
158-
}
159-
steps {
160-
sh '''#!/bin/bash
161-
set -exo pipefail
162-
docker run --rm \
163-
-e PYTHONUNBUFFERED=1 \
164-
--pull always \
165-
gcr.io/kaggle-images/python:${PRETEST_TAG} \
166-
bash -c "git clone https://github.com/Kaggle/kaggle-environments.git /tmp/kaggle-environments && cd /tmp/kaggle-environments && python -m pytest tests/ kaggle_environments/ --tb=short --ignore-glob='*/test_pyxis.py'"
167-
'''
168-
}
169-
}
170-
}
171-
}
172-
173170
stage('Label CPU/GPU Staging Images') {
174171
steps {
175172
sh '''#!/bin/bash

0 commit comments

Comments
 (0)