This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable NeuralChat Unit Test process (#195)
- Loading branch information
1 parent
d3206e6
commit 49336d3
Showing
43 changed files
with
380 additions
and
453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
.github/workflows/script/unitTest/coverage/.engine-coveragerc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[run] | ||
branch = True | ||
|
||
[report] | ||
omit = | ||
*/**/fake*yaml | ||
*/intel_extension_for_transformers/neural_chat/** | ||
*/intel_extension_for_transformers/transformers/** | ||
*/intel_extension_for_transformers/llm/evaluation/** | ||
*/intel_extension_for_transformers/llm/finetuning/** | ||
*/intel_extension_for_transformers/llm/inference/** | ||
*/intel_extension_for_transformers/llm/quantization/** | ||
exclude_lines = | ||
pragma: no cover |
24 changes: 24 additions & 0 deletions
24
.github/workflows/script/unitTest/coverage/.neural-chat-coveragerc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[run] | ||
branch = True | ||
|
||
[report] | ||
omit = | ||
*/**/fake*yaml | ||
*/**/fake.py | ||
*/intel_extension_for_transformers/llm/amp/** | ||
*/intel_extension_for_transformers/llm/evaluation/** | ||
*/intel_extension_for_transformers/llm/quantization/** | ||
*/intel_extension_for_transformers/llm/library/** | ||
*/intel_extension_for_transformers/llm/operator/** | ||
*/intel_extension_for_transformers/llm/runtime/** | ||
*/intel_extension_for_transformers/transformers/** | ||
exclude_lines = | ||
pragma: no cover | ||
raise NotImplementedError | ||
raise TypeError | ||
if self.device == "gpu": | ||
if device == "gpu": | ||
except ImportError: | ||
except Exception as e: | ||
onnx_version < ONNX18_VERSION | ||
onnx_version >= ONNX18_VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.github/workflows/script/unitTest/run_unit_test_neuralchat.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
source /intel-extension-for-transformers/.github/workflows/script/change_color.sh | ||
export COVERAGE_RCFILE="/intel-extension-for-transformers/.github/workflows/script/unitTest/coverage/.neural-chat-coveragerc" | ||
LOG_DIR=/log_dir | ||
mkdir -p ${LOG_DIR} | ||
WORKING_DIR="/intel-extension-for-transformers/intel_extension_for_transformers/neural_chat/tests" | ||
# get parameters | ||
PATTERN='[-a-zA-Z0-9_]*=' | ||
PERF_STABLE_CHECK=true | ||
|
||
for i in "$@"; do | ||
case $i in | ||
--test_name=*) | ||
test_name=`echo $i | sed "s/${PATTERN}//"`;; | ||
*) | ||
echo "Parameter $i not recognized."; exit 1;; | ||
esac | ||
done | ||
|
||
function pytest() { | ||
local coverage_log_dir=$1 | ||
mkdir -p ${coverage_log_dir} | ||
|
||
cd ${WORKING_DIR} || exit 1 | ||
JOB_NAME=unit_test | ||
ut_log_name=${LOG_DIR}/${JOB_NAME}.log | ||
export GLOG_minloglevel=2 | ||
|
||
itrex_path=$(python -c 'import intel_extension_for_transformers; import os; print(os.path.dirname(intel_extension_for_transformers.__file__))') | ||
find . -name "test*.py" | sed 's,\.\/,coverage run --source='"${itrex_path}"' --append ,g' | sed 's/$/ --verbose/' >run.sh | ||
coverage erase | ||
|
||
# run UT | ||
$BOLD_YELLOW && echo "cat run.sh..." && $RESET | ||
cat run.sh | tee ${ut_log_name} | ||
$BOLD_YELLOW && echo "------UT start-------" && $RESET | ||
bash run.sh 2>&1 | tee -a ${ut_log_name} | ||
$BOLD_YELLOW && echo "------UT end -------" && $RESET | ||
|
||
# run coverage report | ||
coverage report -m --rcfile=${COVERAGE_RCFILE} | tee ${coverage_log_dir}/coverage.log | ||
coverage html -d ${coverage_log_dir}/htmlcov --rcfile=${COVERAGE_RCFILE} | ||
coverage xml -o ${coverage_log_dir}/coverage.xml --rcfile=${COVERAGE_RCFILE} | ||
|
||
# check UT status | ||
if [ $(grep -c "FAILED" ${ut_log_name}) != 0 ] || [ $(grep -c "OK" ${ut_log_name}) == 0 ]; then | ||
$BOLD_RED && echo "Find errors in UT test, please check the output..." && $RESET | ||
exit 1 | ||
fi | ||
$BOLD_GREEN && echo "UT finished successfully! " && $RESET | ||
} | ||
|
||
function main() { | ||
bash /intel-extension-for-transformers/.github/workflows/script/unitTest/env_setup.sh | ||
wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb | ||
dpkg -i libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb | ||
cd ${WORKING_DIR} || exit 1 | ||
if [ -f "requirements.txt" ]; then | ||
python -m pip install --default-timeout=100 -r requirements.txt | ||
pip list | ||
else | ||
echo "Not found requirements.txt file." | ||
fi | ||
echo "test on ${test_name}" | ||
if [[ $test_name == "PR-test" ]]; then | ||
pytest "${LOG_DIR}/coverage_pr" | ||
elif [[ $test_name == "baseline" ]]; then | ||
pytest "${LOG_DIR}/coverage_base" | ||
fi | ||
} | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
name: NeuralChat Unit Test | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
paths: | ||
- intel_extension_for_transformers/neural_chat/tests/** | ||
- .github/workflows/unit-test-neuralchat.yml | ||
- .github/workflows/script/unitTest/** | ||
workflow_dispatch: | ||
|
||
# If there is a new commit, the previous jobs will be canceled | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
DOCKER_CONFIG_NAME: "commonDockerConfig" | ||
REPO_NAME: "intel-extension-for-transformers" | ||
REPO_TAG: "py38" | ||
DOCKER_FILE_NAME: "devel" | ||
CONTAINER_NAME: "utTest" | ||
EXTRA_CONTAINER_NAME: "modelTest" | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: [self-hosted, Linux, X64, itrex-node] | ||
strategy: | ||
matrix: | ||
include: | ||
- test_branch: ${{ github.ref }} | ||
test_name: "PR-test" | ||
- test_branch: "main" | ||
test_name: "baseline" | ||
steps: | ||
- name: Docker Clean Up | ||
run: | | ||
docker ps -a | ||
if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then | ||
docker start ${{ env.CONTAINER_NAME }} | ||
echo "remove left files through container ..." | ||
docker exec ${{ env.CONTAINER_NAME }} bash -c "ls -a /intel-extension-for-transformers && rm -fr /intel-extension-for-transformers/* && rm -fr /intel-extension-for-transformers/.* || true" | ||
fi | ||
if [[ $(docker ps -a | grep -i '${{ env.EXTRA_CONTAINER_NAME }}'$) ]]; then | ||
docker start ${{ env.EXTRA_CONTAINER_NAME }} | ||
echo "remove left files through container ..." | ||
docker exec ${{ env.EXTRA_CONTAINER_NAME }} bash -c "ls -a /intel-extension-for-transformers && rm -fr /intel-extension-for-transformers/* && rm -fr /intel-extension-for-transformers/.* || true" | ||
fi | ||
- name: Checkout out Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: "recursive" | ||
ref: ${{ matrix.test_branch }} | ||
fetch-tags: true | ||
|
||
- name: Docker Build | ||
run: | | ||
docker build -f ${{ github.workspace }}/.github/workflows/docker/${{ env.DOCKER_FILE_NAME }}.dockerfile -t ${{ env.REPO_NAME }}:${{ env.REPO_TAG }} . | ||
- name: Docker Run | ||
run: | | ||
if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then | ||
docker stop ${{ env.CONTAINER_NAME }} | ||
docker rm -vf ${{ env.CONTAINER_NAME }} || true | ||
fi | ||
docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \ | ||
-v ${{ github.workspace }}:/intel-extension-for-transformers \ | ||
${{ env.REPO_NAME }}:${{ env.REPO_TAG }} | ||
- name: Env build | ||
run: | | ||
docker exec ${{ env.CONTAINER_NAME }} \ | ||
bash /intel-extension-for-transformers/.github/workflows/script/prepare_env.sh | ||
- name: Binary build | ||
run: | | ||
docker exec ${{ env.CONTAINER_NAME }} \ | ||
bash -c "cd /intel-extension-for-transformers/.github/workflows/script \ | ||
&& bash install_binary.sh \ | ||
&& pip install intel_extension_for_pytorch wget sentencepiece \ | ||
&& pip install transformers>=4.32.0 \ | ||
&& pip install peft torch num2words speechbrain paddlepaddle \ | ||
&& pip install paddlespeech==1.4.1 shortuuid gptcache evaluate \ | ||
&& pip install fschat pydub python-multipart PyPDF2 langchain \ | ||
&& pip install python-docx scikit-learn farm-haystack librosa beautifulsoup4 \ | ||
&& pip install InstructorEmbedding chromadb pydantic fastapi starlette \ | ||
&& pip install yacs uvicorn optimum optimum[habana] \ | ||
&& pip install sentence_transformers unstructured markdown rouge_score \ | ||
&& pip install --upgrade accelerate" | ||
- name: Run UT | ||
run: | | ||
docker exec ${{ env.CONTAINER_NAME }} \ | ||
bash -c "cd /intel-extension-for-transformers/.github/workflows/script/unitTest \ | ||
&& bash run_unit_test_neuralchat.sh --test_name=${{ matrix.test_name }}" | ||
- name: Collect log | ||
if: ${{ !cancelled() }} | ||
run: | | ||
docker exec ${{ env.CONTAINER_NAME }} \ | ||
bash -c "cd /intel-extension-for-transformers && \ | ||
mv /log_dir . " | ||
- name: Publish pipeline artifact | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: "UnitTest${{ matrix.test_name }}" | ||
path: ${{ github.workspace }}/log_dir | ||
|
||
|
||
Genreate-Report: | ||
runs-on: itrex-node-spell | ||
needs: [unit-test] | ||
steps: | ||
- name: Checkout out Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: "recursive" | ||
|
||
- name: Download UT PR Log | ||
uses: actions/download-artifact@v3 | ||
with: | ||
path: ${{ github.workspace }}/log_dir | ||
|
||
- name: Display structure of downloaded files | ||
run: cd ${{ github.workspace }}/log_dir && ls -R | ||
|
||
- name: Calculte coverage | ||
run: | | ||
cd ${{ github.workspace }}/.github/workflows/script/unitTest/coverage | ||
/usr/bin/bash calc_coverage.sh ${{ github.workspace }}/log_dir | ||
- name: Publish pipeline artifact | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ !cancelled() }} | ||
with: | ||
name: Neural Chat Unit Test | ||
path: ${{ github.workspace }}/log_dir | ||
retention-days: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.