Skip to content

Commit b326e39

Browse files
committed
support 3x tf CI test
Signed-off-by: chensuyue <suyue.chen@intel.com>
1 parent 6874a9b commit b326e39

File tree

5 files changed

+157
-2
lines changed

5 files changed

+157
-2
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
include =
6+
*/neural_compressor/common/*
7+
*/neural_compressor/tensorflow/*
8+
exclude_lines =
9+
pragma: no cover
10+
raise NotImplementedError
11+
raise TypeError
12+
if self.device == "gpu":
13+
if device == "gpu":
14+
except ImportError:
15+
except Exception as e:

.azure-pipelines/scripts/ut/3x/run_3x_pt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pip install coverage
1111
pip install pytest
1212
pip list
1313

14-
export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.pt
14+
export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.3x_pt
1515
lpot_path=$(python -c 'import neural_compressor; import os; print(os.path.dirname(neural_compressor.__file__))')
1616
cd /neural-compressor/test || exit 1
1717
find ./3x/torch/* -name "test*.py" | sed 's,\.\/,coverage run --source='"${lpot_path}"' --append ,g' | sed 's/$/ --verbose/'> run.sh
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
python -c "import neural_compressor as nc;print(nc.version.__version__)"
3+
test_case="run 3x TensorFlow"
4+
echo "${test_case}"
5+
6+
# install requirements
7+
echo "set up UT env..."
8+
pip install -r /neural-compressor/requirements_tf.txt
9+
pip install coverage
10+
pip install pytest
11+
pip list
12+
13+
export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.3x_tf
14+
lpot_path=$(python -c 'import neural_compressor; import os; print(os.path.dirname(neural_compressor.__file__))')
15+
cd /neural-compressor/test || exit 1
16+
find ./3x/tensorflow/* -name "test*.py" | sed 's,\.\/,coverage run --source='"${lpot_path}"' --append ,g' | sed 's/$/ --verbose/'> run.sh
17+
18+
LOG_DIR=/neural-compressor/log_dir
19+
mkdir -p ${LOG_DIR}
20+
ut_log_name=${LOG_DIR}/ut_3x_tf.log
21+
22+
echo "cat run.sh..."
23+
sort run.sh -o run.sh
24+
cat run.sh | tee ${ut_log_name}
25+
echo "------UT start-------"
26+
bash -x run.sh 2>&1 | tee -a ${ut_log_name}
27+
cp .coverage ${LOG_DIR}/.coverage
28+
29+
echo "------UT end -------"
30+
31+
if [ $(grep -c "FAILED" ${ut_log_name}) != 0 ] || [ $(grep -c "core dumped" ${ut_log_name}) != 0 ] || [ $(grep -c "ModuleNotFoundError:" ${ut_log_name}) != 0 ] || [ $(grep -c "OK" ${ut_log_name}) == 0 ];then
32+
echo "Find errors in UT test, please check the output..."
33+
exit 1
34+
fi
35+
echo "UT finished successfully! "

.azure-pipelines/ut-3x-pt.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pr:
1212
- neural_compressor/torch
1313
- test/3x/torch
1414
- setup.py
15-
- requirements.txt
1615
- requirements_pt.txt
1716

1817
pool: ICX-16C

.azure-pipelines/ut-3x-tf.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
trigger: none
2+
3+
pr:
4+
autoCancel: true
5+
drafts: false
6+
branches:
7+
include:
8+
- master
9+
paths:
10+
include:
11+
- neural_compressor/common
12+
- neural_compressor/tensorflow
13+
- test/3x/tensorflow
14+
- setup.py
15+
- requirements_tf.txt
16+
17+
pool: ICX-16C
18+
19+
variables:
20+
IMAGE_NAME: "neural-compressor"
21+
IMAGE_TAG: "py38"
22+
UPLOAD_PATH: $(Build.SourcesDirectory)/log_dir
23+
DOWNLOAD_PATH: $(Build.SourcesDirectory)/log_dir
24+
ARTIFACT_NAME: "UT_coverage_report_3x_tf"
25+
REPO: $(Build.Repository.Uri)
26+
27+
stages:
28+
- stage: TensorFlow
29+
displayName: Unit Test 3x TensorFlow
30+
dependsOn: []
31+
jobs:
32+
- job:
33+
displayName: Unit Test 3x TensorFlow
34+
steps:
35+
- template: template/ut-template.yml
36+
parameters:
37+
dockerConfigName: "commonDockerConfig"
38+
utScriptFileName: "3x/run_3x_tf"
39+
uploadPath: $(UPLOAD_PATH)
40+
utArtifact: "ut_coverage_3x"
41+
42+
43+
- stage: TensorFlow_baseline
44+
displayName: Unit Test 3x TensorFlow baseline
45+
dependsOn: []
46+
jobs:
47+
- job:
48+
displayName: Unit Test 3x TensorFlow baseline
49+
steps:
50+
- template: template/ut-template.yml
51+
parameters:
52+
dockerConfigName: "gitCloneDockerConfig"
53+
utScriptFileName: "3x/run_3x_tf"
54+
uploadPath: $(UPLOAD_PATH)
55+
utArtifact: "ut_coverage_3x_baseline"
56+
repo: $(REPO)
57+
58+
- stage: Coverage
59+
displayName: "Coverage Combine"
60+
pool:
61+
vmImage: "ubuntu-latest"
62+
dependsOn: [TensorFlow, TensorFlow_baseline]
63+
jobs:
64+
- job: CollectDatafiles
65+
steps:
66+
- script: |
67+
if [[ ! $(docker images | grep -i ${IMAGE_NAME}:${IMAGE_TAG}) ]]; then
68+
docker build -f ${BUILD_SOURCESDIRECTORY}/.azure-pipelines/docker/Dockerfile.devel -t ${IMAGE_NAME}:${IMAGE_TAG} .
69+
fi
70+
docker images | grep -i ${IMAGE_NAME}
71+
if [[ $? -ne 0 ]]; then
72+
echo "NO Such Repo"
73+
exit 1
74+
fi
75+
displayName: "Build develop docker image"
76+
77+
- task: DownloadPipelineArtifact@2
78+
inputs:
79+
artifact:
80+
path: $(DOWNLOAD_PATH)
81+
82+
- script: |
83+
echo "--- create container ---"
84+
docker run -d -it --name="collectLogs" -v ${BUILD_SOURCESDIRECTORY}:/neural-compressor ${IMAGE_NAME}:${IMAGE_TAG} /bin/bash
85+
echo "--- docker ps ---"
86+
docker ps
87+
echo "--- collect logs ---"
88+
docker exec collectLogs /bin/bash +x -c "cd /neural-compressor/.azure-pipelines/scripts \
89+
&& bash install_nc.sh 3x_tf \
90+
&& bash ut/3x/collect_log_3x.sh 3x_tf"
91+
displayName: "collect logs"
92+
93+
- task: PublishPipelineArtifact@1
94+
condition: succeededOrFailed()
95+
inputs:
96+
targetPath: $(UPLOAD_PATH)
97+
artifact: $(ARTIFACT_NAME)
98+
publishLocation: "pipeline"
99+
100+
- task: Bash@3
101+
condition: always()
102+
inputs:
103+
targetType: "inline"
104+
script: |
105+
docker exec collectLogs bash -c "rm -fr /neural-compressor/* && rm -fr /neural-compressor/.* || true"
106+
displayName: "Docker clean up"

0 commit comments

Comments
 (0)