-
Notifications
You must be signed in to change notification settings - Fork 286
[CI] [GHA] Use OV_CACHE
in the WWB tests
#2781
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
base: master
Are you sure you want to change the base?
Changes from 13 commits
6495cfd
29a668c
229ef95
dd2140f
2bc0ada
72ab81a
a6028ee
ffbafd1
57916ca
01a91ed
916d33d
2dcc9ba
19e5943
31bc592
f8f7437
42d1eb0
e305656
0470bf1
404461e
464d2f9
9dfa38b
a8d0882
a6d802a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,26 @@ | ||||||||||||||||||||||
from pathlib import Path | ||||||||||||||||||||||
import os | ||||||||||||||||||||||
import tempfile | ||||||||||||||||||||||
from datetime import datetime | ||||||||||||||||||||||
from importlib import metadata | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
SHOULD_CLEANUP = os.environ.get("CLEANUP_CACHE", "").lower() in ("1", "true", "yes") | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def get_wwb_cache_dir(temp_dir=tempfile.TemporaryDirectory()) -> Path: | ||||||||||||||||||||||
if "OV_CACHE" in os.environ: | ||||||||||||||||||||||
date_subfolder = datetime.now().strftime("%Y%m%d") | ||||||||||||||||||||||
ov_cache = os.path.join(os.environ["OV_CACHE"], date_subfolder) | ||||||||||||||||||||||
try: | ||||||||||||||||||||||
optimum_intel_version = metadata.version("optimum-intel") | ||||||||||||||||||||||
transformers_version = metadata.version("transformers") | ||||||||||||||||||||||
ov_cache = os.path.join(ov_cache, f"optimum-intel-{optimum_intel_version}_transformers-{transformers_version}") | ||||||||||||||||||||||
Comment on lines
+14
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
except metadata.PackageNotFoundError: | ||||||||||||||||||||||
pass | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
ov_cache = temp_dir.name | ||||||||||||||||||||||
return Path(ov_cache).joinpath("wwb_cache") | ||||||||||||||||||||||
akashchi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
WWB_CACHE_PATH = get_wwb_cache_dir() |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,14 +5,14 @@ | |||||
import shutil | ||||||
import pytest | ||||||
import logging | ||||||
import tempfile | ||||||
import re | ||||||
from constants import WWB_CACHE_PATH, SHOULD_CLEANUP | ||||||
|
||||||
|
||||||
logging.basicConfig(level=logging.INFO) | ||||||
logger = logging.getLogger(__name__) | ||||||
|
||||||
MODEL_CACHE = tempfile.mkdtemp() | ||||||
MODEL_CACHE = WWB_CACHE_PATH | ||||||
OV_IMAGE_MODELS = ["echarlaix/tiny-random-stable-diffusion-xl", | ||||||
"yujiepan/stable-diffusion-3-tiny-random", | ||||||
"katuni4ka/tiny-random-flux", | ||||||
|
@@ -38,13 +38,14 @@ def run_wwb(args): | |||||
|
||||||
def setup_module(): | ||||||
for model_id in OV_IMAGE_MODELS: | ||||||
MODEL_PATH = os.path.join(MODEL_CACHE, model_id.replace("/", "--")) | ||||||
MODEL_PATH = MODEL_CACHE.joinpath(model_id.replace("/", "--")) | ||||||
akashchi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
subprocess.run(["optimum-cli", "export", "openvino", "--model", model_id, MODEL_PATH], capture_output=True, text=True) | ||||||
|
||||||
|
||||||
def teardown_module(): | ||||||
logger.info("Remove models") | ||||||
shutil.rmtree(MODEL_CACHE) | ||||||
if SHOULD_CLEANUP: | ||||||
logger.info("Removing models") | ||||||
shutil.rmtree(MODEL_CACHE) | ||||||
|
||||||
|
||||||
def get_similarity(output: str) -> float: | ||||||
|
@@ -121,11 +122,12 @@ def test_image_model_genai(model_id, model_type, tmp_path): | |||||
pytest.xfail("Ticket 173169") | ||||||
|
||||||
GT_FILE = tmp_path / "gt.csv" | ||||||
MODEL_PATH = os.path.join(MODEL_CACHE, model_id.replace("/", "--")) | ||||||
MODEL_PATH = MODEL_CACHE.joinpath(model_id.replace("/", "--")) | ||||||
akashchi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
MODEL_PATH = MODEL_PATH if MODEL_PATH.exists() else model_id | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fallback logic reassigns MODEL_PATH from a Path object to a string, creating inconsistent types. Consider using
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The underlying |
||||||
|
||||||
run_wwb([ | ||||||
"--base-model", | ||||||
model_id, | ||||||
MODEL_PATH, | ||||||
"--num-samples", | ||||||
"1", | ||||||
"--gt-data", | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a
conftest.py
.should_cleanup
andwwb_cache_path
could be session fixtures.