Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PT FE] Retry hf related tests (#26030)

Maxim Vafin96c866180657
diff --git a/tests/model_hub_tests/pytorch/test_hf_transformers.py b/tests/model_hub_tests/pytorch/test_hf_transformers.py
index 447077e3711..d09df964b83 100644
--- a/tests/model_hub_tests/pytorch/test_hf_transformers.py
+++ b/tests/model_hub_tests/pytorch/test_hf_transformers.py
@@ -5,7 +5,6 @@ import os
from datasets import Audio, load_dataset
from huggingface_hub import hf_hub_download, model_info
-from huggingface_hub.utils import HfHubHTTPError, LocalEntryNotFoundError
from PIL import Image
import pytest
import torch
@@ -56,7 +55,7 @@ class TestTransformersModel(TestTorchConvertModel):
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
self.image = Image.open(requests.get(url, stream=True).raw)
- @retry(3, exceptions=(HfHubHTTPError, LocalEntryNotFoundError), delay=1)
+ @retry(3, exceptions=(OSError,), delay=1)
def load_model(self, name, type):
name, _, name_suffix = name.partition(':')
diff --git a/tests/model_hub_tests/pytorch/test_timm.py b/tests/model_hub_tests/pytorch/test_timm.py
index 69de16177cd..8c11d32517c 100644
--- a/tests/model_hub_tests/pytorch/test_timm.py
+++ b/tests/model_hub_tests/pytorch/test_timm.py
@@ -6,7 +6,6 @@ import os
import pytest
import timm
import torch
-from huggingface_hub.utils import HfHubHTTPError, LocalEntryNotFoundError
from models_hub_common.utils import get_models_list, retry
from torch_utils import TestTorchConvertModel
@@ -48,7 +47,7 @@ torch.manual_seed(0)
class TestTimmConvertModel(TestTorchConvertModel):
- @retry(3, exceptions=(HfHubHTTPError, LocalEntryNotFoundError), delay=1)
+ @retry(3, exceptions=(OSError,), delay=1)
def load_model(self, model_name, model_link):
m = timm.create_model(model_name, pretrained=True)
cfg = timm.get_pretrained_cfg(model_name)
diff --git a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py
index f65213afd1b..dc65324d4f0 100644
--- a/tests/model_hub_tests/transformation_tests/test_pa_transformation.py
+++ b/tests/model_hub_tests/transformation_tests/test_pa_transformation.py
@@ -4,11 +4,13 @@
from openvino._offline_transformations import paged_attention_transformation
from openvino._pyopenvino.op import _PagedAttentionExtension
from optimum.intel import OVModelForCausalLM
+from models_hub_common.utils import retry
import models_hub_common.utils as utils
import pytest
import os
import re
+@retry(3, exceptions=(OSError,), delay=1)
def run_pa(tmp_path, model_id, model_link, use_block_indices_inputs, use_score_outputs):
model = OVModelForCausalLM.from_pretrained(model_id, export=True, trust_remote_code=True)
diff --git a/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py b/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py
index 8de04e8241a..c3aaa082322 100644
--- a/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py
+++ b/tests/model_hub_tests/transformation_tests/test_stateful_to_stateless_transformation.py
@@ -4,6 +4,7 @@
import openvino as ov
from openvino._offline_transformations import stateful_to_stateless_transformation
from optimum.intel import OVModelForCausalLM
+from models_hub_common.utils import retry
import models_hub_common.utils as utils
import pytest
import os
@@ -23,6 +24,7 @@ def check_desc_tensors(tensors1, tensors2):
assert t1.get_partial_shape() == t2.get_partial_shape()
assert t1.get_element_type() == t2.get_element_type()
+@retry(3, exceptions=(OSError,), delay=1)
def run_stateful_to_stateless_in_runtime(tmp_path, model_id, model_link):
model = OVModelForCausalLM.from_pretrained(model_id, export=True, stateful=True, compile=False)
assert len(model.model.get_sinks()), f"Input model is not in the expected stateful form because it doesn't have any sinks."