From 3c8a86a64f4abafbda33684d65a240d9ad1b2d54 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Tue, 26 Sep 2023 12:28:02 +0200 Subject: [PATCH 1/3] add smoke test for prototype namespace on release versions --- test/smoke_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/smoke_test.py b/test/smoke_test.py index d672d46ad9e..d9d80490540 100644 --- a/test/smoke_test.py +++ b/test/smoke_test.py @@ -1,5 +1,6 @@ """Run smoke tests""" +import re import sys from pathlib import Path @@ -79,6 +80,18 @@ def main() -> None: print(f"torchvision: {torchvision.__version__}") print(f"torch.cuda.is_available: {torch.cuda.is_available()}") + if re.match(r"\d+\.\d+\.\d+(?!a0)", torchvision.__version__): + try: + import torchvision.prototype as _ + except ModuleNotFoundError: + pass + else: + raise AssertionError( + "torchvision.prototype available on a release version. " + "Run\n\n" + "rm -rf torchvision/prototype test/test_prototype* .github/workflows/prototype*" + ) + # Turn 1.11.0aHASH into 1.11 (major.minor only) version = ".".join(torchvision.__version__.split(".")[:2]) if version >= "0.16": From 292c9272911ada1040facd1b20b5041e5f4ef97f Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Tue, 26 Sep 2023 12:34:11 +0200 Subject: [PATCH 2/3] fix version check --- test/smoke_test.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/smoke_test.py b/test/smoke_test.py index d9d80490540..214b4a1621b 100644 --- a/test/smoke_test.py +++ b/test/smoke_test.py @@ -92,9 +92,8 @@ def main() -> None: "rm -rf torchvision/prototype test/test_prototype* .github/workflows/prototype*" ) - # Turn 1.11.0aHASH into 1.11 (major.minor only) - version = ".".join(torchvision.__version__.split(".")[:2]) - if version >= "0.16": + major_minor_version = torchvision.__version__.split(".")[:2] + if major_minor_version >= (0, 16): print(f"{torch.ops.image._jpeg_version() = }") assert torch.ops.image._is_compiled_against_turbo() From ab4d9c3fd2633a545990c7153c88a812a9a72088 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Tue, 26 Sep 2023 13:16:25 +0200 Subject: [PATCH 3/3] address comments --- test/smoke_test.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/smoke_test.py b/test/smoke_test.py index 214b4a1621b..a8f36aacc47 100644 --- a/test/smoke_test.py +++ b/test/smoke_test.py @@ -80,22 +80,21 @@ def main() -> None: print(f"torchvision: {torchvision.__version__}") print(f"torch.cuda.is_available: {torch.cuda.is_available()}") - if re.match(r"\d+\.\d+\.\d+(?!a0)", torchvision.__version__): + # The "a0" after the semantic version should only be present on the main branch or nightly builds, + # but not release branches. + if re.match(r"\d+\.\d+\.\d+(?!a0)\+", torchvision.__version__): try: - import torchvision.prototype as _ + from torchvision import prototype except ModuleNotFoundError: pass else: raise AssertionError( "torchvision.prototype available on a release version. " - "Run\n\n" - "rm -rf torchvision/prototype test/test_prototype* .github/workflows/prototype*" + "Run rm -r torchvision/prototype test/test_prototype* .github/workflows/prototype*" ) - major_minor_version = torchvision.__version__.split(".")[:2] - if major_minor_version >= (0, 16): - print(f"{torch.ops.image._jpeg_version() = }") - assert torch.ops.image._is_compiled_against_turbo() + print(f"{torch.ops.image._jpeg_version() = }") + assert torch.ops.image._is_compiled_against_turbo() smoke_test_torchvision() smoke_test_torchvision_read_decode()