Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4892099

Browse files
committedNov 16, 2023
use work directory in klx-training-pre-pr-check.yml
1 parent 32db33e commit 4892099

File tree

1 file changed

+62
-32
lines changed

1 file changed

+62
-32
lines changed
 

‎.github/workflows/klx-training-pre-pr-check.yml

+62-32
Original file line numberDiff line numberDiff line change
@@ -23,78 +23,108 @@ jobs:
2323
uses: actions/checkout@master
2424
with:
2525
fetch-depth: 1
26+
27+
# 2. Create tmp directory
28+
- name: Retrieve the current timestamp
29+
id: work-timestamp
30+
run: echo "WORK_TIMESTAMP=$(date +"%Y-%m%d-%H%M%S")" >> "$GITHUB_OUTPUT"
2631

27-
# 2. Setup basic information in test_conf.py
32+
- name: Set work directory variable
33+
id: work-directory
34+
env:
35+
WORK_TIMESTAMP: ${{ steps.work-timestamp.outputs.WORK_TIMESTAMP }}
36+
run: echo "WORK_DIRECTORY=$(realpath ${PWD}/..)/FlagPerf-$WORK_TIMESTAMP" >> "$GITHUB_OUTPUT"
37+
38+
- name: Create work directory and copy the whole directory
39+
env:
40+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
41+
run: |
42+
mkdir ${WORK_DIRECTORY} &&
43+
cp -r * ${WORK_DIRECTORY}
44+
45+
# 3. Setup basic information in test_conf.py
2846
- name: Setup test_conf.py
47+
env:
48+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
2949
run: |
30-
echo "VENDOR = 'kunlunxin'" >> training/run_benchmarks/config/test_conf.py &&
31-
echo "ACCE_CONTAINER_OPT = '--device=/dev/xpu0 --device=/dev/xpu1 --device=/dev/xpu2 --device=/dev/xpu3 --device=/dev/xpu4 --device=/dev/xpu5 --device=/dev/xpu6 --device=/dev/xpu7 --device=/dev/xpuctrl'" >> training/run_benchmarks/config/test_conf.py &&
32-
echo "ACCE_VISIBLE_DEVICE_ENV_NAME = 'XPU_VISIBLE_DEVICES'" >> training/run_benchmarks/config/test_conf.py &&
50+
export TEST_CONF_FILEPATH=${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py
51+
echo "VENDOR = 'kunlunxin'" >> ${TEST_CONF_FILEPATH} &&
52+
echo "ACCE_CONTAINER_OPT = '--device=/dev/xpu0 --device=/dev/xpu1 --device=/dev/xpu2 --device=/dev/xpu3 --device=/dev/xpu4 --device=/dev/xpu5 --device=/dev/xpu6 --device=/dev/xpu7 --device=/dev/xpuctrl'" >> ${TEST_CONF_FILEPATH} &&
53+
echo "ACCE_VISIBLE_DEVICE_ENV_NAME = 'XPU_VISIBLE_DEVICES'" >> ${TEST_CONF_FILEPATH} &&
3354
echo "PIP_SOURCE = 'https://pypi.tuna.tsinghua.edu.cn/simple'" &&
34-
echo "FLAGPERF_PATH = '${PWD}/training'" >> training/run_benchmarks/config/test_conf.py &&
35-
echo "FLAGPERF_LOG_PATH = '${PWD}/training/result/'" >> training/run_benchmarks/config/test_conf.py &&
36-
cat training/run_benchmarks/config/test_conf.py
55+
echo "FLAGPERF_PATH = '${WORK_DIRECTORY}/training'" >> ${TEST_CONF_FILEPATH} &&
56+
echo "FLAGPERF_LOG_PATH = '${WORK_DIRECTORY}/training/result/'" >> ${TEST_CONF_FILEPATH} &&
57+
cat ${TEST_CONF_FILEPATH}
3758
38-
# 3. Setup cases in test_conf.py
59+
# 4. Setup cases in test_conf.py
3960
- name: Setup 1x1 case and 1x8 case in test_conf.py
4061
if: ${{ inputs.case1x1 != '' && inputs.case1x8 != '' }}
62+
env:
63+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
4164
run: |
42-
echo "CASES = { '${{ inputs.case1x1 }}' : '${{ inputs.dataset_path }}', '${{ inputs.case1x8 }}' : '${{ inputs.dataset_path }}' }" >> training/run_benchmarks/config/test_conf.py &&
43-
cat training/run_benchmarks/config/test_conf.py
65+
echo "CASES = { '${{ inputs.case1x1 }}' : '${{ inputs.dataset_path }}', '${{ inputs.case1x8 }}' : '${{ inputs.dataset_path }}' }" >> ${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py &&
66+
cat ${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py
4467
- name: Setup 1x1 case in test_conf.py
4568
if: ${{ inputs.case1x1 != '' && inputs.case1x8 == '' }}
69+
env:
70+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
4671
run: |
47-
echo "CASES = { '${{ inputs.case1x1 }}' : '${{ inputs.dataset_path }}' }" >> training/run_benchmarks/config/test_conf.py &&
48-
cat training/run_benchmarks/config/test_conf.py
72+
echo "CASES = { '${{ inputs.case1x1 }}' : '${{ inputs.dataset_path }}' }" >> ${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py &&
73+
cat ${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py
4974
- name: Setup 1x8 case in test_conf.py
5075
if: ${{ inputs.case1x1 == '' && inputs.case1x8 != '' }}
76+
env:
77+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
5178
run: |
52-
echo "CASES = { '${{ inputs.case1x1 }}' : '${{ inputs.dataset_path }}' }" >> training/run_benchmarks/config/test_conf.py &&
53-
cat training/run_benchmarks/config/test_conf.py
79+
echo "CASES = { '${{ inputs.case1x1 }}' : '${{ inputs.dataset_path }}' }" >> ${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py &&
80+
cat ${WORK_DIRECTORY}/training/run_benchmarks/config/test_conf.py
5481
- name: Setup empty cases in test_conf.py
5582
if: ${{ inputs.case1x1 == '' && inputs.case1x8 == '' }}
83+
env:
84+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
5685
run: |
5786
echo "At least one of case1x1 and case1x8 is not empty!" &&
5887
ls non_existent_file.txt
5988
60-
# 4. Setup cluster_conf.py
89+
# 5. Setup cluster_conf.py
6190
- name: Setup cluster_conf.py
91+
env:
92+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
6293
run: |
63-
echo "HOSTS = ['127.0.0.1']" >> training/run_benchmarks/config/cluster_conf.py &&
64-
cat training/run_benchmarks/config/cluster_conf.py
94+
echo "HOSTS = ['127.0.0.1']" >> ${WORK_DIRECTORY}/training/run_benchmarks/config/cluster_conf.py &&
95+
cat ${WORK_DIRECTORY}/training/run_benchmarks/config/cluster_conf.py
6596
66-
# 5. Run test
97+
# 6. Run test
6798
- name: Run test
99+
env:
100+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
68101
run: |
69-
pushd training &&
102+
pushd ${WORK_DIRECTORY}/training &&
70103
python3 run_benchmarks/run.py 2>&1 | tee tmp_run.log &&
71104
popd
72105
73-
# 6. Verify test result
106+
# 7. Verify test result
74107
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
75108
- name: Get run result name
76109
id: run-result-name
77-
run: echo "RUN_RESULT_NAME=$(cat training/tmp_run.log | grep 'Initialize logger with log path:' | egrep -o 'run[0-9]+')" >> "$GITHUB_OUTPUT"
110+
env:
111+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
112+
run: echo "RUN_RESULT_NAME=$(cat ${WORK_DIRECTORY}/training/tmp_run.log | grep 'Initialize logger with log path:' | egrep -o 'run[0-9]+')" >> "$GITHUB_OUTPUT"
78113

79114
- name: Verify 1x1 case result
80115
if: ${{ inputs.case1x1 != '' }}
81116
env:
117+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
82118
RUN_RESULT_NAME: ${{ steps.run-result-name.outputs.RUN_RESULT_NAME }}
83119
run: |
84-
cat training/result/${RUN_RESULT_NAME}/${{ inputs.case1x1 != '' }}/round1/127.0.0.1_noderank0/rank0.out.log
85-
grep "FINISHED" "training/result/${RUN_RESULT_NAME}/${{ inputs.case1x1 != '' }}/round1/127.0.0.1_noderank0/rank0.out.log"
120+
cat ${WORK_DIRECTORY}/training/result/${RUN_RESULT_NAME}/${{ inputs.case1x1 }}/round1/127.0.0.1_noderank0/rank0.out.log
121+
grep "FINISHED" "${WORK_DIRECTORY}/training/result/${RUN_RESULT_NAME}/${{ inputs.case1x1 }}/round1/127.0.0.1_noderank0/rank0.out.log"
86122
87123
- name: Verify 1x8 case result
88124
if: ${{ inputs.case1x8 != '' }}
89125
env:
126+
WORK_DIRECTORY: ${{ steps.work-directory.outputs.WORK_DIRECTORY }}
90127
RUN_RESULT_NAME: ${{ steps.run-result-name.outputs.RUN_RESULT_NAME }}
91128
run: |
92-
cat training/result/${RUN_RESULT_NAME}/${{ inputs.case1x8 != '' }}/round1/127.0.0.1_noderank0/rank0.out.log
93-
grep "FINISHED" "training/result/${RUN_RESULT_NAME}/${{ inputs.case1x8 != '' }}/round1/127.0.0.1_noderank0/rank0.out.log"
94-
95-
# 7. Clean job
96-
- name: Remove tmp_run.log, restore test_conf.py and cluster_conf.py
97-
run: |
98-
rm -f training/tmp_run.log &&
99-
git checkout training/run_benchmarks/config/test_conf.py &&
100-
git checkout training/run_benchmarks/config/cluster_conf.py
129+
cat ${WORK_DIRECTORY}/training/result/${RUN_RESULT_NAME}/${{ inputs.case1x8 }}/round1/127.0.0.1_noderank0/rank0.out.log
130+
grep "FINISHED" "${WORK_DIRECTORY}/training/result/${RUN_RESULT_NAME}/${{ inputs.case1x8 }}/round1/127.0.0.1_noderank0/rank0.out.log"

0 commit comments

Comments
 (0)
Please sign in to comment.