Skip to content

Commit

Permalink
[Tests] Remove raising error when graph is not existed (#2744)
Browse files Browse the repository at this point in the history
### Changes

Remove raising an error in the test when a graph does not exist.

### Reason for changes

To return the feature with re/generating reference graphs using
`NNCF_TEST_REGEN_DOT`

### Related tickets

N/A

### Tests

N/A
  • Loading branch information
kshpv authored Jun 18, 2024
1 parent 5384965 commit 5c9a417
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/openvino/native/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import torch
from packaging import version

import nncf
from nncf import Dataset
from nncf.openvino.graph.nncf_graph_builder import GraphConverter
from tests.openvino.conftest import OPENVINO_NATIVE_TEST_ROOT
Expand Down Expand Up @@ -96,13 +95,15 @@ def get_openvino_version() -> str:
def get_actual_reference_for_current_openvino(rel_path: Path) -> Path:
"""
Get path to actual reference file.
If from all of the OpenVINO versions such rel_path is not existed,
than the path for current OpenVINO version is returned.
:param rel_path: Relative path to reference file.
:return: Path to reference file or raise RuntimeError.
:return: Path to a reference file.
"""
root_dir = OPENVINO_NATIVE_TEST_ROOT / "data"
current_ov_version = version.parse(get_openvino_version())
current_ov_version = get_openvino_version()

def is_valid_version(dir_path: Path) -> bool:
try:
Expand All @@ -113,11 +114,10 @@ def is_valid_version(dir_path: Path) -> bool:

ref_versions = filter(is_valid_version, root_dir.iterdir())
ref_versions = sorted(ref_versions, key=lambda x: version.parse(x.name), reverse=True)
ref_versions = filter(lambda x: version.parse(x.name) <= current_ov_version, ref_versions)
ref_versions = filter(lambda x: version.parse(x.name) <= version.parse(current_ov_version), ref_versions)

for root_version in ref_versions:
file_name = root_version / rel_path
if file_name.is_file():
return file_name

raise nncf.InternalError(f"Not found file {root_dir}/{current_ov_version}/{rel_path}")
return root_dir / current_ov_version / rel_path

0 comments on commit 5c9a417

Please sign in to comment.