2525
2626 steps :
2727 - uses : actions/checkout@v7
28- - uses : actions/setup-python@v6
28+ - uses : actions/setup-python@v7
2929 with :
3030 python-version : ${{ matrix.python }}
3131 - run : python -m pip install -U uv
@@ -56,41 +56,59 @@ jobs:
5656 # the key must never match, even when restarting workflows, as that
5757 # will cause durations to get out of sync between groups, the
5858 # combined durations will be loaded if available
59- key : test2 -durations-split-${{ github.run_id }}-${{ github.run_number}}-${{ matrix.python }}-${{ matrix.group }}
59+ key : test4 -durations-split-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.python }}-${{ matrix.group }}
6060 restore-keys : |
61- test2-durations-combined-${{ matrix.python }}-${{ github.sha }}
62- test2-durations-combined-${{ matrix.python }}
63- - run : pytest --cov=deepmd source/tests --ignore=source/tests/tf2 --splits 12 --group ${{ matrix.group }} --store-durations --clean-durations --durations-path=.test_durations --splitting-algorithm least_duration
61+ test4-durations-combined-${{ matrix.python }}-${{ github.sha }}
62+ test4-durations-combined-${{ matrix.python }}
63+ - name : Prepare independent duration inputs
64+ run : |
65+ for output in main tf2 jax2tf consistent_tf2; do
66+ if [ -f .test_durations ]; then
67+ cp .test_durations ".test_durations_${output}"
68+ fi
69+ done
70+ # Keep fixture-sharing classes/modules together, then balance those
71+ # indivisible units by their recorded durations.
72+ - 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
6473 env :
6574 NUM_WORKERS : 0
6675 DP_CI_IMPORT_PADDLE_BEFORE_TF : 1
6776 FLAGS_use_stride_compute_kernel : 0
6877 - name : Test TF2 eager mode
6978 run : |
7079 run_pytest_allow_no_tests() {
80+ local durations_path=$1
81+ shift
7182 set +e
72- pytest "$@"
83+ pytest "$@" \
84+ --store-durations \
85+ --clean-durations \
86+ --durations-path="$durations_path"
7387 local status=$?
7488 set -e
7589 if [ "$status" -eq 5 ]; then
7690 # pytest-split may leave an individual shard with no selected
7791 # tests after path/-k filtering. Other shards still cover the
7892 # selected tests, so do not fail the whole matrix for exit 5.
93+ printf '{}\n' > "$durations_path"
7994 return 0
8095 fi
8196 return "$status"
8297 }
8398
84- run_pytest_allow_no_tests --cov=deepmd --cov-append \
99+ run_pytest_allow_no_tests .test_durations_tf2 \
100+ --cov=deepmd --cov-append \
85101 source/tests/tf2 \
86102 --splits 12 \
87103 --group ${{ matrix.group }}
88- run_pytest_allow_no_tests --cov=deepmd --cov-append \
104+ run_pytest_allow_no_tests .test_durations_jax2tf \
105+ --cov=deepmd --cov-append \
89106 source/tests/consistent/io/test_io.py \
90107 source/jax2tf_tests \
91108 --splits 12 \
92109 --group ${{ matrix.group }}
93- run_pytest_allow_no_tests --cov=deepmd --cov-append \
110+ run_pytest_allow_no_tests .test_durations_consistent_tf2 \
111+ --cov=deepmd --cov-append \
94112 source/tests/consistent \
95113 -k tf2 \
96114 --splits 12 \
@@ -100,7 +118,8 @@ jobs:
100118 DP_TEST_TF2_ONLY : 1
101119 DP_DTYPE_PROMOTION_STRICT : 1
102120 DP_CI_IMPORT_PADDLE_BEFORE_TF : 1
103- - run : mv .test_durations .test_durations_${{ matrix.group }}
121+ - name : Combine shard durations
122+ run : jq -s 'reduce .[] as $durations ({}; . * $durations)' .test_durations_main .test_durations_tf2 .test_durations_jax2tf .test_durations_consistent_tf2 > .test_durations_${{ matrix.group }}
104123 - name : Upload partial durations
105124 uses : actions/upload-artifact@v7
106125 with :
@@ -132,15 +151,15 @@ jobs:
132151 # key won't match during the first run for the given commit, but
133152 # restore-key will if there's a previous stored durations file,
134153 # so cache will both be loaded and stored
135- key : test2 -durations-combined-${{ matrix.python }}-${{ github.sha }}
136- restore-keys : test2 -durations-combined-${{ matrix.python }}
154+ key : test4 -durations-combined-${{ matrix.python }}-${{ github.sha }}
155+ restore-keys : test4 -durations-combined-${{ matrix.python }}
137156 - name : Download artifacts
138157 uses : actions/download-artifact@v8
139158 with :
140159 pattern : split-${{ matrix.python }}-*
141160 merge-multiple : true
142161 - name : Combine test durations
143- run : jq -s add .test_durations_* > .test_durations
162+ run : jq -s 'reduce .[] as $durations ({}; . * $durations)' .test_durations_* > .test_durations
144163 pass :
145164 name : Pass testing Python
146165 needs : [testpython, update_durations]
0 commit comments