Skip to content

Commit b2f469f

Browse files
committed
try
1 parent a67c771 commit b2f469f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

_unittests/ut_torch_models/test_llm_phi2.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import unittest
22
import torch
3-
from onnx_diagnostic.ext_test_case import ExtTestCase, ignore_warnings, requires_transformers
3+
from onnx_diagnostic.ext_test_case import (
4+
ExtTestCase,
5+
ignore_warnings,
6+
requires_transformers,
7+
requires_python,
8+
)
49
from onnx_diagnostic.torch_models.llms import get_phi2
510
from onnx_diagnostic.helpers import string_type
611
from onnx_diagnostic.torch_export_patches import bypass_export_some_errors
@@ -25,6 +30,7 @@ def test_export_phi2_1(self):
2530
assert ep
2631

2732
@ignore_warnings(UserWarning)
33+
@requires_python((3, 12))
2834
def test_export_phi2_2_bypassed(self):
2935
data = get_phi2(num_hidden_layers=2)
3036
model, inputs, ds = data["model"], data["inputs"], data["dynamic_shapes"]

onnx_diagnostic/ext_test_case.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,18 @@ def has_cuda() -> bool:
399399
return torch.cuda.device_count() > 0
400400

401401

402+
def requires_python(version: Tuple[int,...], msg: str = ""):
403+
"""
404+
Skips a test if python is too old.
405+
406+
:param msg: to overwrite the message
407+
:param version: minimum version
408+
"""
409+
if sys.version_info[:len(version)] < version:
410+
return unittest.skip(msg or f"python not recent enough {sys.version_info} < {version}")
411+
return lambda x: x
412+
413+
402414
def requires_cuda(msg: str = "", version: str = "", memory: int = 0):
403415
"""
404416
Skips a test if cuda is not available.

0 commit comments

Comments
 (0)