Skip to content

Commit b520cec

Browse files
committed
[wwb] Add safe load models/datasets for stable CI
1 parent 39a31c0 commit b520cec

File tree

15 files changed

+344
-229
lines changed

15 files changed

+344
-229
lines changed

.github/workflows/linux.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,16 @@ jobs:
542542
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).RAG.test }}
543543
timeout: 30
544544
- name: 'WWB tests'
545+
env:
546+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
547+
HF_HUB_DOWNLOAD_TIMEOUT: 60
545548
cmd: 'python -m pytest -v ./tools/who_what_benchmark/tests -m "not nanollava"'
546549
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).WWB.test }}
547550
timeout: 120
548551
- name: 'WWB tests (nanollava)'
552+
env:
553+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
554+
HF_HUB_DOWNLOAD_TIMEOUT: 60
549555
cmd: |
550556
python -m pip install transformers==4.48.0
551557
python -m pytest -v ./tools/who_what_benchmark/tests -m nanollava

.github/workflows/mac.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,16 @@ jobs:
468468
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).RAG.test }}
469469
timeout: 30
470470
- name: 'WWB tests'
471+
env:
472+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
473+
HF_HUB_DOWNLOAD_TIMEOUT: 60
471474
cmd: 'python -m pytest -v ./tools/who_what_benchmark/tests -m "not nanollava"'
472475
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).WWB.test }}
473476
timeout: 120
474477
- name: 'WWB tests (nanollava)'
478+
env:
479+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
480+
HF_HUB_DOWNLOAD_TIMEOUT: 60
475481
cmd: |
476482
python -m pip install transformers==4.48.0
477483
python -m pytest -v ./tools/who_what_benchmark/tests -m nanollava

.github/workflows/manylinux_2_28.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ jobs:
176176
for py_version in "3.10" "3.11" "3.12" "3.13"
177177
do
178178
rm -rf ${{ env.BUILD_DIR }}/CMakeCache.txt
179-
179+
180180
python_exec_path=$(python$py_version -c "import sys; print(sys.executable)")
181181
182182
echo "Configuring cmake for python$py_version"
@@ -187,12 +187,12 @@ jobs:
187187
-S ${{ env.SRC_DIR }} \
188188
-B ${{ env.BUILD_DIR }}
189189
echo "Configuring cmake done for python$py_version"
190-
190+
191191
/usr/bin/cmake --build ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --parallel $(nproc) --verbose
192192
/usr/bin/cmake --install ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --prefix ${{ env.INSTALL_DIR }}
193193
done
194194
/usr/bin/cmake --install ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --prefix ${{ env.INSTALL_TOOLS_DIR }} --component tools_bin
195-
/usr/bin/cmake --install ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --prefix ${{ env.INSTALL_TESTS_DIR }} --component tests
195+
/usr/bin/cmake --install ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --prefix ${{ env.INSTALL_TESTS_DIR }} --component tests
196196
env:
197197
CXXFLAGS: "-Wno-dangling-reference -fno-lto" # bug in gcc-14: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113485
198198
CFLAGS: "-Wno-dangling-reference -fno-lto" # bug in gcc-14: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113485
@@ -209,7 +209,7 @@ jobs:
209209
name: genai_archive_${{ matrix.build-type }}
210210
path: ${{ env.BUILD_DIR }}/${{ env.GENAI_ARCHIVE_NAME }}
211211
if-no-files-found: 'error'
212-
212+
213213
- name: Upload Tools
214214
if: always()
215215
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
@@ -360,7 +360,7 @@ jobs:
360360
CXXFLAGS: "-Wno-dangling-reference -fno-lto" # bug in gcc-14: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113485
361361
CFLAGS: "-Wno-dangling-reference -fno-lto" # bug in gcc-14: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107532, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113485
362362
LDFLAGS: "-fno-lto" # bug in gcc-14: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113485
363-
363+
364364
- name: Build GenAI Node.js bindings
365365
run: /usr/bin/cmake --build ${{ env.BUILD_DIR }} --config ${{ matrix.build-type }} --parallel $(nproc) --verbose
366366

@@ -440,7 +440,7 @@ jobs:
440440
storage_dir: ${{ env.BASE_PRODUCT_TYPE }}_${{ matrix.build-type }}
441441
storage_root: ${{ env.ARTIFACTS_SHARE }}
442442
product_name: ${{ github.event.repository.name }}
443-
443+
444444
genai_tests_wheel:
445445
name: Python (${{ matrix.test.name}}) Tests (wheel)
446446
needs: [ smart_ci, openvino_download, genai_build_wheel ]
@@ -483,10 +483,16 @@ jobs:
483483
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).RAG.test }}
484484
timeout: 30
485485
- name: 'WWB tests'
486+
env:
487+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
488+
HF_HUB_DOWNLOAD_TIMEOUT: 60
486489
cmd: 'python -m pytest -v ./tools/who_what_benchmark/tests -m "not nanollava"'
487490
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).WWB.test }}
488491
timeout: 120
489492
- name: 'WWB tests (nanollava)'
493+
env:
494+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
495+
HF_HUB_DOWNLOAD_TIMEOUT: 60
490496
cmd: |
491497
python -m pip install transformers==4.48.0
492498
python -m pytest -v ./tools/who_what_benchmark/tests -m nanollava

.github/workflows/windows.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,16 @@ jobs:
631631
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).RAG.test }}
632632
timeout: 30
633633
- name: 'WWB tests'
634+
env:
635+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
636+
HF_HUB_DOWNLOAD_TIMEOUT: 60
634637
cmd: 'python -m pytest -s -v tools/who_what_benchmark/tests -m "not nanollava"'
635638
run_condition: ${{ fromJSON(needs.smart_ci.outputs.affected_components).WWB.test }}
636639
timeout: 120
637640
- name: 'WWB tests (nanollava)'
641+
env:
642+
HF_DATASETS_CACHE: /mount/caches/pytest/datasets
643+
HF_HUB_DOWNLOAD_TIMEOUT: 60
638644
cmd: |
639645
python -m pip install transformers==4.48.0
640646
python -m pytest -v ./tools/who_what_benchmark/tests -m nanollava
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import os
2+
import sys
3+
import pytest
4+
import logging
5+
import shutil
6+
import subprocess # nosec B404
7+
8+
from pathlib import Path
9+
from typing import Any, Dict
10+
11+
sys.path.insert(0, f"{os.path.dirname(__file__)}/../../../tests/")
12+
from python_tests.utils.atomic_download import AtomicDownloadManager # noqa
13+
from python_tests.utils.constants import get_ov_cache_dir # noqa
14+
from python_tests.utils.network import retry_request # noqa
15+
16+
logging.basicConfig(level=logging.INFO)
17+
logger = logging.getLogger(__name__)
18+
19+
20+
MODELS: Dict[str, Dict[str, Any]] = {
21+
"bge-small-en-v1.5": {
22+
"name": "BAAI/bge-small-en-v1.5",
23+
"convert_args": ["--trust-remote-code", "--task", "feature-extraction"],
24+
},
25+
"Qwen3-Embedding-0.6B": {
26+
"name": "Qwen/Qwen3-Embedding-0.6B",
27+
"convert_args": ["--trust-remote-code", "--task", "feature-extraction"],
28+
},
29+
"ms-marco-TinyBERT-L2-v2": {
30+
"name": "cross-encoder/ms-marco-TinyBERT-L2-v2",
31+
"convert_args": ["--trust-remote-code", "--task", "text-classification"],
32+
},
33+
"Qwen3-Reranker-0.6B": {
34+
"name": "Qwen/Qwen3-Reranker-0.6B",
35+
"convert_args": ["--trust-remote-code", "--task", "text-generation"],
36+
},
37+
"tiny-random-qwen2vl": {
38+
"name": "katuni4ka/tiny-random-qwen2vl",
39+
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"],
40+
},
41+
"tiny-random-llava-next-video": {
42+
"name": "katuni4ka/tiny-random-llava-next-video",
43+
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"],
44+
},
45+
"nanoLLaVA": {
46+
"name": "qnguyen3/nanoLLaVA",
47+
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"],
48+
},
49+
"tiny-random-llava": {
50+
"name": "katuni4ka/tiny-random-llava",
51+
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"],
52+
},
53+
"tiny-random-stable-diffusion-xl": {"name": "echarlaix/tiny-random-stable-diffusion-xl", "convert_args": []},
54+
"stable-diffusion-3-tiny-random": {"name": "yujiepan/stable-diffusion-3-tiny-random", "convert_args": []},
55+
"tiny-random-flux": {"name": "katuni4ka/tiny-random-flux", "convert_args": []},
56+
"tiny-random-flux-fill": {"name": "katuni4ka/tiny-random-flux-fill", "convert_args": []},
57+
}
58+
59+
60+
def get_ov_cache_converted_models_dir():
61+
return get_ov_cache_dir() / "converted_models"
62+
63+
64+
def convert_model(model_name):
65+
models_dir = get_ov_cache_converted_models_dir()
66+
67+
model_id = model_name.split("/")[1]
68+
convert_args = MODELS[model_id]["convert_args"]
69+
model_path = Path(models_dir) / f"wwb_{model_id}"
70+
71+
manager = AtomicDownloadManager(model_path)
72+
73+
logger.info(f"Start convertion of: {model_name}")
74+
if manager.is_complete():
75+
logger.info("Conversion command is already completed")
76+
return model_path
77+
78+
def convert(temp_path: Path) -> None:
79+
command = [
80+
"optimum-cli",
81+
"export",
82+
"openvino",
83+
"--model",
84+
model_name,
85+
"--weight-format",
86+
"fp16",
87+
*convert_args,
88+
str(temp_path),
89+
]
90+
logger.info(f"Conversion command: {' '.join(command)}")
91+
retry_request(lambda: subprocess.run(command, check=True, text=True, capture_output=True))
92+
93+
try:
94+
manager.execute(convert)
95+
except subprocess.CalledProcessError as error:
96+
logger.exception(f"optimum-cli returned {error.returncode}. Output:\n{error.output}")
97+
raise
98+
return str(model_path)
99+
100+
101+
@pytest.fixture(scope="session", autouse=True)
102+
def module_teardown():
103+
ov_cache_dir = get_ov_cache_dir()
104+
ov_cache_converted_dir = get_ov_cache_converted_models_dir()
105+
logger.info(f"Creating directories: {ov_cache_converted_dir}")
106+
if not ov_cache_converted_dir.exists():
107+
ov_cache_converted_dir.mkdir(exist_ok=True, parents=True)
108+
109+
yield
110+
111+
if os.environ.get("CLEANUP_CACHE", "false").lower() == "true":
112+
if ov_cache_dir.exists():
113+
logger.info(f"Removing temporary directory: {ov_cache_dir}")
114+
shutil.rmtree(ov_cache_dir)
115+
else:
116+
logger.info(f"Skipped temporary directory cleanup because it doesn't exist: {ov_cache_dir}")
117+
118+
119+
def run_wwb(args, env=None):
120+
command = ["wwb"] + args
121+
base_env = {"TRANSFORMERS_VERBOSITY": "debug", "PYTHONIOENCODING": "utf-8", **os.environ}
122+
if env:
123+
base_env.update(env)
124+
try:
125+
return subprocess.check_output(
126+
command,
127+
stderr=subprocess.STDOUT,
128+
encoding="utf-8",
129+
env=base_env,
130+
)
131+
except subprocess.CalledProcessError as error:
132+
logger.error(f"'{' '.join(map(str, command))}' returned {error.returncode}. Output:\n{error.output}")
133+
raise

0 commit comments

Comments
 (0)