-
Notifications
You must be signed in to change notification settings - Fork 635
172 lines (170 loc) · 7.26 KB
/
Copy pathtest_python.yml
File metadata and controls
172 lines (170 loc) · 7.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
on:
push:
branches-ignore:
- "gh-readonly-queue/**"
- "copilot/**"
- "dependabot/**"
- "pre-commit-ci-update-config"
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
name: Test Python
jobs:
testpython:
name: Test Python
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
# Pull requests only run the oldest supported Python version.
# Push and merge queue runs keep the full version matrix.
python: ${{ fromJSON(github.event_name == 'pull_request' && '["3.10"]' || '["3.10", "3.13"]') }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- run: python -m pip install -U uv
- run: |
source/install/uv_with_retry.sh pip install --system openmpi --group pin_tensorflow_cpu --group pin_pytorch_cpu --torch-backend cpu
export TENSORFLOW_ROOT=$(python -c 'import importlib.util,pathlib;print(pathlib.Path(importlib.util.find_spec("tensorflow").origin).parent)')
export PYTORCH_ROOT=$(python -c 'import torch;print(torch.__path__[0])')
source/install/uv_with_retry.sh pip install --system -e .[test,jax,torch] mpi4py --group pin_jax_cpu
source/install/uv_with_retry.sh pip install --system --find-links "https://www.paddlepaddle.org.cn/packages/nightly/cpu/paddlepaddle/" --index-url https://pypi.org/simple --trusted-host www.paddlepaddle.org.cn --trusted-host paddlepaddle.org.cn paddlepaddle==3.4.0.dev20260310
env:
# Please note that uv has some issues with finding
# existing TensorFlow package. Currently, it uses
# TensorFlow in the build dependency, but if it
# changes, setting `TENSORFLOW_ROOT`.
DP_ENABLE_PYTORCH: 1
DP_BUILD_TESTING: 1
HOROVOD_WITH_TENSORFLOW: 1
HOROVOD_WITHOUT_PYTORCH: 1
HOROVOD_WITH_MPI: 1
# https://cmake.org/cmake/help/latest/variable/CMAKE_POLICY_VERSION_MINIMUM.html
CMAKE_POLICY_VERSION_MINIMUM: 3.5
UV_HTTP_TIMEOUT: 120
- run: dp --version
- name: Get durations from cache
uses: actions/cache@v6
with:
path: .test_durations
# the key must never match, even when restarting workflows, as that
# will cause durations to get out of sync between groups, the
# combined durations will be loaded if available
key: test4-durations-split-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.python }}-${{ matrix.group }}
restore-keys: |
test4-durations-combined-${{ matrix.python }}-${{ github.sha }}
test4-durations-combined-${{ matrix.python }}
- name: Prepare independent duration inputs
run: |
for output in main tf2 jax2tf consistent_tf2; do
if [ -f .test_durations ]; then
cp .test_durations ".test_durations_${output}"
fi
done
# Keep fixture-sharing classes/modules together, then balance those
# indivisible units by their recorded durations.
- run: python -m pytest -p source.tests.ci_split --cov=deepmd source/tests --ignore=source/tests/tf2 --ci-splits 12 --ci-group ${{ matrix.group }} --store-durations --clean-durations --durations-path=.test_durations_main
env:
NUM_WORKERS: 0
DP_CI_IMPORT_PADDLE_BEFORE_TF: 1
FLAGS_use_stride_compute_kernel: 0
- name: Test TF2 eager mode
run: |
run_pytest_allow_no_tests() {
local durations_path=$1
shift
set +e
pytest "$@" \
--store-durations \
--clean-durations \
--durations-path="$durations_path"
local status=$?
set -e
if [ "$status" -eq 5 ]; then
# pytest-split may leave an individual shard with no selected
# tests after path/-k filtering. Other shards still cover the
# selected tests, so do not fail the whole matrix for exit 5.
printf '{}\n' > "$durations_path"
return 0
fi
return "$status"
}
run_pytest_allow_no_tests .test_durations_tf2 \
--cov=deepmd --cov-append \
source/tests/tf2 \
--splits 12 \
--group ${{ matrix.group }}
run_pytest_allow_no_tests .test_durations_jax2tf \
--cov=deepmd --cov-append \
source/tests/consistent/io/test_io.py \
source/jax2tf_tests \
--splits 12 \
--group ${{ matrix.group }}
run_pytest_allow_no_tests .test_durations_consistent_tf2 \
--cov=deepmd --cov-append \
source/tests/consistent \
-k tf2 \
--splits 12 \
--group ${{ matrix.group }}
env:
NUM_WORKERS: 0
DP_TEST_TF2_ONLY: 1
DP_DTYPE_PROMOTION_STRICT: 1
DP_CI_IMPORT_PADDLE_BEFORE_TF: 1
- name: Combine shard durations
run: jq -s 'reduce .[] as $durations ({}; . * $durations)' .test_durations_main .test_durations_tf2 .test_durations_jax2tf .test_durations_consistent_tf2 > .test_durations_${{ matrix.group }}
- name: Upload partial durations
uses: actions/upload-artifact@v7
with:
name: split-${{ matrix.python }}-${{ matrix.group }}
path: .test_durations_${{ matrix.group }}
include-hidden-files: true
- name: Upload coverage to Codecov (non-blocking)
uses: codecov/codecov-action@v7
continue-on-error: true
with:
use_oidc: true
permissions:
id-token: write
update_durations:
name: Combine and update integration test durations
runs-on: ubuntu-slim
strategy:
fail-fast: false
matrix:
# Pull requests only run the oldest supported Python version.
# Push and merge queue runs keep the full version matrix.
python: ${{ fromJSON(github.event_name == 'pull_request' && '["3.10"]' || '["3.10", "3.13"]') }}
needs: testpython
steps:
- name: Get durations from cache
uses: actions/cache@v6
with:
path: .test_durations
# key won't match during the first run for the given commit, but
# restore-key will if there's a previous stored durations file,
# so cache will both be loaded and stored
key: test4-durations-combined-${{ matrix.python }}-${{ github.sha }}
restore-keys: test4-durations-combined-${{ matrix.python }}
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: split-${{ matrix.python }}-*
merge-multiple: true
- name: Combine test durations
run: jq -s 'reduce .[] as $durations ({}; . * $durations)' .test_durations_* > .test_durations
pass:
name: Pass testing Python
needs: [testpython, update_durations]
runs-on: ubuntu-slim
if: always()
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}