Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverage command #33

Merged
merged 17 commits into from
Jun 24, 2024
2 changes: 1 addition & 1 deletion .github/workflows/model_test_cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
matrix:
include:
- modelName: "opt-125m"
datasets: "piqa"
datasets: "lambada_openai"
device: "cpu"
tasks: "text-generation"
fail-fast: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/model_test_hpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
matrix:
include:
- modelName: "opt-125m"
datasets: "piqa"
datasets: "lambada_openai"
device: "hpu"
tasks: "text-generation"
fail-fast: true
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/scripts/install_evals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

echo -e "\n Install GenAIEval ... "
cd /GenAIEval
python -m pip install --no-cache-dir -r requirements.txt
python setup.py bdist_wheel
pip install dist/opea_eval*.whl

pip list
6 changes: 3 additions & 3 deletions .github/workflows/scripts/unittest/calc_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

source ../../change_color
source ../change_color
LOG_DIR=$1
coverage_compare="${LOG_DIR}/coverage_compare.html"
coverage_log_pr="${LOG_DIR}/UnitTestPR-test/coverage_pr"
coverage_log_base="${LOG_DIR}/UnitTestbaseline/coverage_base"
coverage_log_pr="${LOG_DIR}/UnitTestPR-test/pr"
coverage_log_base="${LOG_DIR}/UnitTestbaseline/base"

function get_coverage_data() {
# Input argument
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scripts/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function pytest() {
ut_log_name="${LOG_DIR}/unit_test_$1.log"
export GLOG_minloglevel=2

genaieval_path=$(python -c 'import GenAIEval; import os; print(os.path.dirname(GenAIEval.__file__))')
find . -name "test*.py" | sed 's,\.\/,coverage run --source='"${genaieval_path}"' --append ,g' | sed 's/$/ --verbose/' >run.sh
genaieval_path=$(python3 -c 'import evals; print(evals.__path__[0])')
find . -name "test*.py" | sed "s,\.\/,coverage run --source=\"${genaieval_path}\" --append ,g" | sed 's/$/ --verbose/' >run.sh
coverage erase

# run UT
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- GenAIEval/**
- setup.py
- tests/**
- .github/workflows/scripts/unittest/**
workflow_dispatch:

# If there is a new commit, the previous jobs will be canceled
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:

- name: Install Dependencies
run: |
docker exec ${{ env.CONTAINER_NAME }} bash -c "cd /GenAIEval && pip install -r requirements.txt && python setup.py install"
docker exec ${{ env.CONTAINER_NAME }} bash -c "bash /GenAIEval/.github/workflows/scripts/install_evals.sh"

- name: Run UT
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(
dtype: Optional[Union[str, torch.dtype]] = "auto",
batch_size: Optional[Union[int, str]] = 1,
max_batch_size: Optional[int] = 64,
trust_remote_code: Optional[bool] = False,
trust_remote_code: Optional[bool] = True,
use_fast_tokenizer: Optional[bool] = True,
add_bos_token: Optional[bool] = False,
prefix_token_id: Optional[int] = None,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_lm_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ def test_lm_eval(self):
model="hf",
user_model=user_model,
tokenizer=tokenizer,
tasks="piqa",
tasks="lambada_openai",
device="cpu",
batch_size=1,
limit=5,
trust_remote_code=True,
)
results = evaluate(args)
self.assertEqual(results["results"]["piqa"]["acc,none"], 0.6)
self.assertEqual(results["results"]["lambada_openai"]["acc,none"], 0.6)


if __name__ == "__main__":
Expand Down