Skip to content

Commit ea1c2a7

Browse files
committed
+ tests
1 parent 4f48162 commit ea1c2a7

File tree

8 files changed

+186
-176
lines changed

8 files changed

+186
-176
lines changed

tests/python_tests/samples/conftest.py

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# - "name": the model's name or path
2727
# - "convert_args": a list of arguments for the conversion command
2828
MODELS: Dict[str, Dict[str, Any]] = {
29-
"TinyLlama-1.1B-Chat-v1.0": {
29+
"TinyLlama-1.1B-Chat-v1.0": {
3030
"name": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
3131
"convert_args": ['--weight-format', 'fp16']
3232
},
@@ -46,7 +46,7 @@
4646
"SmolLM2-360M": {
4747
"name": "HuggingFaceTB/SmolLM2-360M",
4848
"convert_args": ['--trust-remote-code']
49-
},
49+
},
5050
"WhisperTiny": {
5151
"name": "openai/whisper-tiny",
5252
"convert_args": ['--trust-remote-code', '--weight-format', 'fp16']
@@ -84,11 +84,11 @@
8484
"LCM_Dreamshaper_v7-int8-ov": {
8585
"name": "OpenVINO/LCM_Dreamshaper_v7-int8-ov",
8686
"convert_args": []
87-
},
87+
},
8888
"llava-1.5-7b-hf": {
8989
"name": "llava-hf/llava-1.5-7b-hf",
9090
"convert_args": ['--trust-remote-code', '--weight-format', 'fp16']
91-
},
91+
},
9292
"llava-v1.6-mistral-7b-hf": {
9393
"name": "llava-hf/llava-v1.6-mistral-7b-hf",
9494
"convert_args": ['--trust-remote-code', '--weight-format', 'fp16']
@@ -129,6 +129,10 @@
129129
"name": "katuni4ka/tiny-random-llava",
130130
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"]
131131
},
132+
"tiny-random-qwen2vl": {
133+
"name": "katuni4ka/tiny-random-qwen2vl",
134+
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"]
135+
},
132136
"bge-small-en-v1.5": {
133137
"name": "BAAI/bge-small-en-v1.5",
134138
"convert_args": ["--trust-remote-code"]
@@ -148,6 +152,10 @@
148152
"tiny-random-SpeechT5ForTextToSpeech": {
149153
"name": "hf-internal-testing/tiny-random-SpeechT5ForTextToSpeech",
150154
"convert_args": ["--model-kwargs", json.dumps({"vocoder": "fxmarty/speecht5-hifigan-tiny"})]
155+
},
156+
"tiny-random-llava-next-video": {
157+
"name": "katuni4ka/tiny-random-llava-next-video",
158+
"convert_args": ["--trust-remote-code", "--task", "image-text-to-text"]
151159
}
152160
}
153161

@@ -164,7 +172,8 @@
164172
"cat.png": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png",
165173
"cat": "https://github.com/openvinotoolkit/openvino_notebooks/assets/29454499/d5fbbd1a-d484-415c-88cb-9986625b7b11",
166174
"3283_1447_000.tar.gz": "https://huggingface.co/datasets/facebook/multilingual_librispeech/resolve/main/data/mls_polish/train/audio/3283_1447_000.tar.gz",
167-
"cmu_us_awb_arctic-wav-arctic_a0001.bin": "https://huggingface.co/datasets/Xenova/cmu-arctic-xvectors-extracted/resolve/main/cmu_us_awb_arctic-wav-arctic_a0001.bin"
175+
"cmu_us_awb_arctic-wav-arctic_a0001.bin": "https://huggingface.co/datasets/Xenova/cmu-arctic-xvectors-extracted/resolve/main/cmu_us_awb_arctic-wav-arctic_a0001.bin",
176+
"video0.pm4": "https://storage.openvinotoolkit.org/repositories/openvino_notebooks/data/data/video/Coco%20Walking%20in%20Berkeley.mp4"
168177
}
169178

170179
SAMPLES_PY_DIR = Path(
@@ -182,23 +191,24 @@
182191
)
183192
)
184193

194+
185195
@pytest.fixture(scope="session", autouse=True)
186196
def setup_and_teardown(request, tmp_path_factory):
187197
"""Fixture to set up and tear down the temporary directories."""
188-
189-
ov_cache = get_ov_cache_dir(tmp_path_factory.mktemp("ov_cache"))
198+
199+
ov_cache = get_ov_cache_dir(tmp_path_factory.mktemp("ov_cache"))
190200
downloaded_models_dir = get_ov_cache_downloaded_models_dir()
191201
converted_models_dir = get_ov_cache_converted_models_dir()
192202
test_data = ov_cache / "test_data"
193-
203+
194204
logger.info(f"Creating directories: {downloaded_models_dir}, {converted_models_dir}, and {test_data}")
195205
test_data.mkdir(parents=True, exist_ok=True)
196-
206+
197207
request.config.cache.set("OV_CACHE", str(ov_cache))
198208
request.config.cache.set("TEST_DATA", str(test_data))
199-
209+
200210
yield
201-
211+
202212
if os.environ.get("CLEANUP_CACHE", "false").lower() != "false":
203213
if os.path.exists(ov_cache):
204214
logger.info(f"Removing temporary directory: {ov_cache}")
@@ -213,9 +223,9 @@ def download_gguf_model(model: Dict[str, Any], model_path: str) -> None:
213223
model_name = model["name"]
214224
model_gguf_filename = model["gguf_filename"]
215225
dest_dir = Path(model_path)
216-
226+
217227
manager = AtomicDownloadManager(dest_dir)
218-
228+
219229
def download_to_temp(temp_path: Path) -> None:
220230
command = ["huggingface-cli", "download", model_name, model_gguf_filename, "--local-dir", str(temp_path)]
221231
logger.info(f"Downloading command: {' '.join(command)}")
@@ -325,26 +335,27 @@ def download_to_temp(temp_path: Path) -> None:
325335
command = ["huggingface-cli", "download", model_name, "--local-dir", str(temp_path)]
326336
logger.info(f"Downloading command: {' '.join(command)}")
327337
retry_request(lambda: subprocess.run(command, check=True, capture_output=True, text=True, env=sub_env))
328-
338+
329339
manager.execute(download_to_temp)
330-
340+
331341
yield str(model_path)
332-
342+
333343
if os.environ.get("CLEANUP_CACHE", "false").lower() == "true":
334344
if model_cache.exists():
335345
logger.info(f"Removing downloaded model: {model_cache}")
336346
shutil.rmtree(model_cache)
337347

348+
338349
@pytest.fixture(scope="session")
339350
def download_test_content(request):
340351
"""Download the test content from the given URL and return the file path or extracted folder."""
341-
352+
342353
test_data = request.config.cache.get("TEST_DATA", None)
343-
354+
344355
file_name = request.param
345356
file_url = TEST_FILES[file_name]
346357
file_path = os.path.join(test_data, file_name)
347-
358+
348359
if not os.path.exists(file_path):
349360
logger.info(f"Downloading test content from {file_url} to {file_path}...")
350361
os.makedirs(os.path.dirname(file_path), exist_ok=True)
@@ -384,9 +395,9 @@ def download_test_content(request):
384395
@pytest.fixture(scope="session")
385396
def generate_test_content(request):
386397
"""Generate an image of lines and return the file path."""
387-
398+
388399
test_data = request.config.cache.get("TEST_DATA", None)
389-
400+
390401
file_name = request.param
391402
file_path = os.path.join(test_data, file_name)
392403
if not os.path.exists(file_path):
@@ -412,24 +423,24 @@ def generate_test_content(request):
412423
@pytest.fixture(scope="session")
413424
def generate_image_generation_jsonl(request):
414425
"""Generate a JSONL file for image generation prompts."""
415-
426+
416427
test_data = request.config.cache.get("TEST_DATA", None)
417428
file_name, json_entries = request.param
418429
file_path = os.path.join(test_data, file_name)
419-
430+
420431
if not os.path.exists(file_path):
421432
os.makedirs(os.path.dirname(file_path), exist_ok=True)
422-
433+
423434
with open(file_path, "w", encoding="utf-8") as f:
424435
for entry in json_entries:
425436
f.write(json.dumps(entry) + "\n")
426-
437+
427438
logger.info(f"Generated image generation JSONL file at {file_path}")
428439
else:
429440
logger.info(f"Image generation JSONL file already exists at {file_path}")
430-
441+
431442
yield file_path
432-
443+
433444
# Cleanup the JSONL file after tests
434445
if os.environ.get("CLEANUP_CACHE", "false").lower() == "true":
435446
if os.path.exists(file_path):

0 commit comments

Comments
 (0)