Skip to content

Commit

Permalink
[PT FE] Retry hf related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mvafin committed Aug 12, 2024
1 parent 2593fea commit d89c33b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/model_hub_tests/pytorch/test_hf_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from datasets import Audio, load_dataset
from huggingface_hub import hf_hub_download, model_info
from huggingface_hub.utils import HfHubHTTPError, LocalEntryNotFoundError
from requests import RequestException
from PIL import Image
import pytest
import torch
Expand Down Expand Up @@ -56,7 +56,7 @@ def setup_class(self):
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=(RequestException,), delay=1)
def load_model(self, name, type):
name, _, name_suffix = name.partition(':')

Expand Down
4 changes: 2 additions & 2 deletions tests/model_hub_tests/pytorch/test_timm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
import timm
import torch
from huggingface_hub.utils import HfHubHTTPError, LocalEntryNotFoundError
from requests import RequestException
from models_hub_common.utils import get_models_list, retry

from torch_utils import TestTorchConvertModel
Expand Down Expand Up @@ -48,7 +48,7 @@ def filter_timm(timm_list: list) -> list:


class TestTimmConvertModel(TestTorchConvertModel):
@retry(3, exceptions=(HfHubHTTPError, LocalEntryNotFoundError), delay=1)
@retry(3, exceptions=(RequestException,), 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
from openvino._offline_transformations import paged_attention_transformation
from openvino._pyopenvino.op import _PagedAttentionExtension
from optimum.intel import OVModelForCausalLM
from requests import RequestException
from models_hub_common.utils import retry
import models_hub_common.utils as utils
import pytest
import os
import re

@retry(3, exceptions=(RequestException,), 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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import openvino as ov
from openvino._offline_transformations import stateful_to_stateless_transformation
from optimum.intel import OVModelForCausalLM
from requests import RequestException
from models_hub_common.utils import retry
import models_hub_common.utils as utils
import pytest
import os
Expand All @@ -23,6 +25,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=(RequestException,), 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."
Expand Down

0 comments on commit d89c33b

Please sign in to comment.