diff --git a/tests/openvino/conftest.py b/tests/openvino/conftest.py index 738ba7efc44..b107b3db32a 100644 --- a/tests/openvino/conftest.py +++ b/tests/openvino/conftest.py @@ -32,6 +32,14 @@ def data(request): return Path(option) +@pytest.fixture(name="omz_cache_dir") +def models(request): + option = request.config.getoption("--data") + if option is None: + return Path(MODELS_PATH) + return Path(option) + + # Custom markers specifying tests to be run only if a specific option # is present on the pytest command line must be registered here. MARKS_VS_OPTIONS = {**COMMON_SCOPE_MARKS_VS_OPTIONS} @@ -46,4 +54,6 @@ def pytest_collection_modifyitems(config, items): OPENVINO_NATIVE_TEST_ROOT = OPENVINO_TEST_ROOT / "native" AC_CONFIGS_DIR = OPENVINO_TEST_ROOT / "data" / "ac_configs" OPENVINO_DATASET_DEFINITIONS_PATH = OPENVINO_TEST_ROOT / "data" / "ov_dataset_definitions.yml" -DATASET_PATH = "~/.cache/nncf/datasets" +NNCF_CACHE_PATH = Path("~/.cache/nncf") +DATASET_PATH = NNCF_CACHE_PATH / "datasets" +MODELS_PATH = NNCF_CACHE_PATH / "models" diff --git a/tests/openvino/native/quantization/test_fq_params_calculation.py b/tests/openvino/native/quantization/test_fq_params_calculation.py index 180eb7190c9..3e4ca766e41 100644 --- a/tests/openvino/native/quantization/test_fq_params_calculation.py +++ b/tests/openvino/native/quantization/test_fq_params_calculation.py @@ -133,8 +133,8 @@ def test_overflow_fix_scales(overflow_fix): ids=[QuantizationPreset.PERFORMANCE.value, QuantizationPreset.MIXED.value], ) @pytest.mark.parametrize("model_name", OMZ_MODELS) -def test_omz_models_fq_scales(model_name, preset, inplace_statistics, tmp_path): - download_model(model_name, tmp_path) +def test_omz_models_fq_scales(model_name, preset, inplace_statistics, tmp_path, omz_cache_dir): + download_model(model_name, tmp_path, omz_cache_dir) convert_model(model_name, tmp_path) model_path = tmp_path / "public" / model_name / "FP32" / f"{model_name}.xml" model = ov.Core().read_model(model_path) diff --git a/tests/openvino/native/quantization/test_graphs.py b/tests/openvino/native/quantization/test_graphs.py index 9073a4bb581..949e2b6d08c 100644 --- a/tests/openvino/native/quantization/test_graphs.py +++ b/tests/openvino/native/quantization/test_graphs.py @@ -77,11 +77,11 @@ def test_depthwise_models_fq_placement(model_creator_func): @pytest.mark.parametrize("model_name_params", OMZ_MODELS_QUANTIZE_PARAMS.items(), ids=list(OMZ_MODELS_QUANTIZE_PARAMS)) -def test_omz_models_fq_placement(model_name_params, tmp_path): +def test_omz_models_fq_placement(model_name_params, tmp_path, omz_cache_dir): model_name, q_params = model_name_params params_str = "_".join([param.value for param in q_params.values()]) q_params.update({"inplace_statistics": True}) - download_model(model_name, tmp_path) + download_model(model_name, tmp_path, omz_cache_dir) convert_model(model_name, tmp_path) model_path = tmp_path / "public" / model_name / "FP32" / f"{model_name}.xml" model = ov.Core().read_model(model_path) @@ -116,10 +116,10 @@ def test_transformer_models_fq_placement(model_creator_func, tmp_path): @pytest.mark.parametrize("model_name_params", OMZ_MODELS_SQ_PARAMS.items(), ids=list(OMZ_MODELS_SQ_PARAMS)) -def test_omz_models_sq_placement(model_name_params, tmp_path): +def test_omz_models_sq_placement(model_name_params, tmp_path, omz_cache_dir): model_name, q_params = model_name_params q_params.update({"inplace_statistics": True}) - download_model(model_name, tmp_path) + download_model(model_name, tmp_path, omz_cache_dir) convert_model(model_name, tmp_path) model_path = tmp_path / "public" / model_name / "FP32" / f"{model_name}.xml" model = ov.Core().read_model(model_path) diff --git a/tests/openvino/native/quantization/test_sanity.py b/tests/openvino/native/quantization/test_sanity.py index 2bbe4ad38d5..911ce9a3854 100644 --- a/tests/openvino/native/quantization/test_sanity.py +++ b/tests/openvino/native/quantization/test_sanity.py @@ -46,11 +46,11 @@ @pytest.mark.parametrize( "model, dataset, ref_metrics, advanced_params", OMZ_MODELS, ids=[model[0] for model in OMZ_MODELS] ) -def test_compression(data_dir, tmp_path, model, dataset, ref_metrics, advanced_params): +def test_compression(data_dir, tmp_path, model, dataset, ref_metrics, advanced_params, omz_cache_dir): extracted_data_dir = os.path.dirname(get_dataset_for_test(dataset, data_dir)) config_path = AC_CONFIGS_DIR / f"{model}.yml" - download_model(model, tmp_path) + download_model(model, tmp_path, omz_cache_dir) convert_model(model, tmp_path) model_path = tmp_path / "public" / model / "FP32" / f"{model}.xml" diff --git a/tests/openvino/native/test_nncf_graph_builder.py b/tests/openvino/native/test_nncf_graph_builder.py index 8b21431aa67..1f75de1f084 100644 --- a/tests/openvino/native/test_nncf_graph_builder.py +++ b/tests/openvino/native/test_nncf_graph_builder.py @@ -45,8 +45,8 @@ def test_compare_nncf_graph_synthetic_models(model_cls_to_test): @pytest.mark.parametrize("model_name", OMZ_MODELS) -def test_compare_nncf_graph_omz_models(tmp_path, model_name): - download_model(model_name, tmp_path) +def test_compare_nncf_graph_omz_models(tmp_path, omz_cache_dir, model_name): + download_model(model_name, tmp_path, omz_cache_dir) convert_model(model_name, tmp_path) model_path = tmp_path / "public" / model_name / "FP32" / f"{model_name}.xml" model = ov.Core().read_model(model_path) diff --git a/tests/openvino/omz_helpers.py b/tests/openvino/omz_helpers.py index 713f84be5ba..77787fd6aa7 100644 --- a/tests/openvino/omz_helpers.py +++ b/tests/openvino/omz_helpers.py @@ -25,8 +25,8 @@ def run_command(command: List[str]): return cmd_output -def download_model(name, path): - com_line = ["omz_downloader", "--name", name, "-o", str(path)] +def download_model(name, path, omz_cache_dir): + com_line = ["omz_downloader", "--name", name, "-o", str(path), "--cache_dir", str(omz_cache_dir)] _ = run_command(com_line) diff --git a/tests/openvino/pot/quantization/test_sanity.py b/tests/openvino/pot/quantization/test_sanity.py index dc413236d39..36ad34d9b66 100644 --- a/tests/openvino/pot/quantization/test_sanity.py +++ b/tests/openvino/pot/quantization/test_sanity.py @@ -32,11 +32,11 @@ @pytest.mark.parametrize("model, dataset, ref_metrics", OMZ_MODELS, ids=[model[0] for model in OMZ_MODELS]) -def test_compression(data_dir, tmp_path, model, dataset, ref_metrics): +def test_compression(data_dir, tmp_path, omz_cache_dir, model, dataset, ref_metrics): extracted_data_dir = os.path.dirname(get_dataset_for_test(dataset, data_dir)) config_path = AC_CONFIGS_DIR / f"{model}.yml" - download_model(model, tmp_path) + download_model(model, tmp_path, omz_cache_dir) convert_model(model, tmp_path) model_path = tmp_path / "public" / model / "FP32" / f"{model}.xml"