10000 Add infra to run CPython tests under Dynamo by guilhermeleobas · Pull Request #150787 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Add infra to run CPython tests under Dynamo #150787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Prev Previous commit
Next Next commit
Update
[ghstack-poisoned]
  • Loading branch information
guilhermeleobas committed May 6, 2025
commit c4ee847bedc0cd41b7a549c99db83e84217ae414
23 changes: 11 additions & 12 deletions torch/_dynamo/test_case.py
6F1E
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import inspect
import logging
import os
import pathlib
import re
import sys
import unittest
Expand Down Expand Up @@ -174,20 +175,18 @@ def tearDownClass(cls) -> None:
@classmethod
def setUpClass(cls) -> None:
# Skip test if python versions doesn't match
m = re.search(r"\b\d+_\d+\b", inspect.getfile(cls))
normalized_path = pathlib.PurePath("dynamo/cpython").as_posix()
regex = re.escape(normalized_path) + r"\b\d+_\d{2}\b"
m = re.search(regex, inspect.getfile(cls))
if m:
test_py_ver = tuple(map(int, m.group().split("_")))
else:
raise unittest.TestCase.failureException(
f"Test file {inspect.getfile(cls)} does not contain a valid Python version"
)
py_ver = sys.version_info[:2]
if py_ver != test_py_ver:
expected = ".".join(map(str, test_py_ver))
got = ".".join(map(str, py_ver))
raise unittest.SkipTest(
f"Test requires Python {expected} but got Python {got}"
)
py_ver = sys.version_info[:2]
if py_ver != test_py_ver:
expected = ".".join(map(str, test_py_ver))
got = ".".join(map(str, py_ver))
raise unittest.SkipTest(
f"Test requires Python {expected} but got Python {got}"
)

super().setUpClass()
cls._stack = contextlib.ExitStack() # type: ignore[attr-defined]
Expand Down
Loading
0