Skip to content

Commit fbd330f

Browse files
workflows+gradle: capture and run ML tests that require non self-hosted environment on ubuntu-latest (#35585)
* .github+sdks: run ml tests that require non self-hosted env * .github: trigger post commit python * Update sdks/python/pytest.ini Co-authored-by: Danny McCormick <dannymccormick@google.com> * .github+sdks: add descriptive comments about runner changes * workflows+gradle: use `require_docker_in_docker` marker --------- Co-authored-by: Danny McCormick <dannymccormick@google.com>
1 parent f7071ef commit fbd330f

4 files changed

Lines changed: 55 additions & 5 deletions

File tree

.github/workflows/beam_PostCommit_Python.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,20 @@ env:
5454
jobs:
5555
beam_PostCommit_Python:
5656
name: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ matrix.python_version }})
57-
runs-on: [self-hosted, ubuntu-20.04, highmem22]
57+
runs-on: ${{ matrix.os }}
5858
timeout-minutes: 240
5959
strategy:
6060
fail-fast: false
6161
matrix:
6262
job_name: [beam_PostCommit_Python]
6363
job_phrase: [Run Python PostCommit]
6464
python_version: ['3.9', '3.10', '3.11', '3.12']
65+
# Run on both self-hosted and GitHub-hosted runners.
66+
# Some tests (marked require_docker_in_docker) can't run on Beam's
67+
# self-hosted runners due to Docker-in-Docker environment constraint.
68+
# These tests will only execute on ubuntu-latest (GitHub-hosted).
69+
# Context: https://github.com/apache/beam/pull/35585
70+
os: [[self-hosted, ubuntu-20.04, highmem22], [ubuntu-latest]]
6571
if: |
6672
github.event_name == 'workflow_dispatch' ||
6773
github.event_name == 'pull_request_target' ||
@@ -99,6 +105,11 @@ jobs:
99105
arguments: |
100106
-Pjava21Home=$JAVA_HOME_21_X64 \
101107
-PuseWheelDistribution \
108+
-Pposargs="${{
109+
contains(matrix.os, 'self-hosted') &&
110+
'-m ''not require_non_self_hosted''' ||
111+
'-m ''require_non_self_hosted'''
112+
}}" \
102113
-PpythonVersion=${{ matrix.python_version }} \
103114
env:
104115
CLOUDSDK_CONFIG: ${{ env.KUBELET_GCLOUD_CONFIG_PATH}}
@@ -115,4 +126,4 @@ jobs:
115126
commit: '${{ env.prsha || env.GITHUB_SHA }}'
116127
comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }}
117128
files: '**/pytest*.xml'
118-
large_files: true
129+
large_files: true

.github/workflows/beam_PreCommit_Python_ML.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,20 @@ env:
5858
jobs:
5959
beam_PreCommit_Python_ML:
6060
name: ${{ matrix.job_name }} (${{ matrix.job_phrase }} ${{ matrix.python_version }})
61-
runs-on: [self-hosted, ubuntu-20.04, main]
61+
runs-on: ${{ matrix.os }}
6262
timeout-minutes: 180
6363
strategy:
6464
fail-fast: false
6565
matrix:
6666
job_name: ['beam_PreCommit_Python_ML']
6767
job_phrase: ['Run Python_ML PreCommit']
6868
python_version: ['3.9','3.10','3.11','3.12']
69+
# Run on both self-hosted and GitHub-hosted runners.
70+
# Some tests (marked require_docker_in_docker) can't run on Beam's
71+
# self-hosted runners due to Docker-in-Docker environment constraint.
72+
# These tests will only execute on ubuntu-latest (GitHub-hosted).
73+
# Context: https://github.com/apache/beam/pull/35585
74+
os: [[self-hosted, ubuntu-20.04, main], [ubuntu-latest]]
6975
if: |
7076
github.event_name == 'push' ||
7177
github.event_name == 'pull_request_target' ||
@@ -96,7 +102,11 @@ jobs:
96102
with:
97103
gradle-command: :sdks:python:test-suites:tox:py${{steps.set_py_ver_clean.outputs.py_ver_clean}}:testPy${{steps.set_py_ver_clean.outputs.py_ver_clean}}ML
98104
arguments: |
99-
-Pposargs=apache_beam/ml/ \
105+
-Pposargs="${{
106+
contains(matrix.os, 'self-hosted') &&
107+
'apache_beam/ml/ -m ''not require_non_self_hosted''' ||
108+
'apache_beam/ml/ -m ''require_non_self_hosted'''
109+
}}" \
100110
-PpythonVersion=${{ matrix.python_version }}
101111
- name: Archive Python Test Results
102112
uses: actions/upload-artifact@v4
@@ -111,4 +121,4 @@ jobs:
111121
commit: '${{ env.prsha || env.GITHUB_SHA }}'
112122
comment_mode: ${{ github.event_name == 'issue_comment' && 'always' || 'off' }}
113123
files: '**/pytest*.xml'
114-
large_files: true
124+
large_files: true

sdks/python/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ markers =
7070
uses_mock_api: tests that uses the mock API cluster.
7171
uses_feast: tests that uses feast in some way
7272
gemini_postcommit: gemini postcommits that need additional deps.
73+
require_docker_in_docker: tests that require running Docker inside Docker (Docker-in-Docker), which is not supported on Beam’s self-hosted runners. Context: https://github.com/apache/beam/pull/35585
7374

7475
# Default timeout intended for unit tests.
7576
# If certain tests need a different value, please see the docs on how to

sdks/python/test-suites/direct/common.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,33 @@ task feastIntegrationTest {
419419
}
420420
}
421421

422+
// Integration tests that require Docker-in-Docker capabilities.
423+
// These tests are marked with the `require_docker_in_docker` pytest marker
424+
// because they rely on Docker-in-Docker configurations that are not supported
425+
// on Beam's self-hosted GitHub Actions runners. Docker-in-Docker works on
426+
// ubuntu-latest GitHub-hosted runners but not on self-hosted environments due
427+
// to containerization architecture differences.
428+
// Context: https://github.com/apache/beam/pull/35585
429+
task dockerInDockerIntegrationTest {
430+
dependsOn 'installGcpTest'
431+
dependsOn ':sdks:python:sdist'
432+
433+
doLast {
434+
def testOpts = basicTestOpts
435+
def argMap = [
436+
"test_opts": testOpts,
437+
"suite": "postCommitIT-direct-py${pythonVersionSuffix}",
438+
"collect": "require_docker_in_docker",
439+
"runner": "TestDirectRunner",
440+
]
441+
def cmdArgs = mapToArgString(argMap)
442+
exec {
443+
executable 'sh'
444+
args '-c', ". ${envdir}/bin/activate && ${runScriptsDir}/run_integration_test.sh $cmdArgs"
445+
}
446+
}
447+
}
448+
422449
// Add all the RunInference framework IT tests to this gradle task that runs on Direct Runner Post commit suite.
423450
project.tasks.register("inferencePostCommitIT") {
424451
dependsOn = [
@@ -429,6 +456,7 @@ project.tasks.register("inferencePostCommitIT") {
429456
'transformersInferenceTest',
430457
'testcontainersTest',
431458
'feastIntegrationTest',
459+
'dockerInDockerIntegrationTest',
432460
// (TODO) https://github.com/apache/beam/issues/25799
433461
// uncomment tfx bsl tests once tfx supports protobuf 4.x
434462
// 'tfxInferenceTest',

0 commit comments

Comments
 (0)