mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
let build tests run in conda
Summary: Much of the code is actually available during the conda tests, as long as we look in the right place. We enable some of them. Reviewed By: nikhilaravi Differential Revision: D30249357 fbshipit-source-id: 01c57b6b8c04442237965f23eded594aeb90abfb
This commit is contained in:
parent
b0dd0c8821
commit
ae1387b523
@ -29,6 +29,8 @@ def get_pytorch3d_dir() -> Path:
|
||||
"""
|
||||
if os.environ.get("INSIDE_RE_WORKER") is not None:
|
||||
return Path(__file__).resolve().parent
|
||||
elif os.environ.get("CONDA_BUILD_STATE", "") == "TEST":
|
||||
return Path(os.environ["SRC_DIR"])
|
||||
else:
|
||||
return Path(__file__).resolve().parent.parent
|
||||
|
||||
|
@ -9,22 +9,20 @@ import os
|
||||
import unittest
|
||||
from collections import Counter
|
||||
|
||||
from common_testing import get_pytorch3d_dir, get_tests_dir
|
||||
from common_testing import get_pytorch3d_dir
|
||||
|
||||
|
||||
# This file groups together tests which look at the code without running it.
|
||||
# When running the tests inside conda's build, the code is not available.
|
||||
in_conda_build = os.environ.get("CONDA_BUILD_STATE", "") == "TEST"
|
||||
in_re_worker = os.environ.get("INSIDE_RE_WORKER") is not None
|
||||
|
||||
|
||||
class TestBuild(unittest.TestCase):
|
||||
@unittest.skipIf(in_conda_build or in_re_worker, "In conda build, or RE worker")
|
||||
@unittest.skipIf(in_re_worker, "In RE worker")
|
||||
def test_name_clash(self):
|
||||
# For setup.py, all translation units need distinct names, so we
|
||||
# cannot have foo.cu and foo.cpp, even in different directories.
|
||||
test_dir = get_tests_dir()
|
||||
source_dir = test_dir.parent / "pytorch3d"
|
||||
source_dir = get_pytorch3d_dir() / "pytorch3d"
|
||||
|
||||
stems = []
|
||||
for extension in [".cu", ".cpp"]:
|
||||
@ -35,10 +33,9 @@ class TestBuild(unittest.TestCase):
|
||||
for k, v in counter.items():
|
||||
self.assertEqual(v, 1, f"Too many files with stem {k}.")
|
||||
|
||||
@unittest.skipIf(in_conda_build or in_re_worker, "In conda build, or RE worker")
|
||||
@unittest.skipIf(in_re_worker, "In RE worker")
|
||||
def test_copyright(self):
|
||||
test_dir = get_tests_dir()
|
||||
root_dir = test_dir.parent
|
||||
root_dir = get_pytorch3d_dir()
|
||||
|
||||
extensions = ("py", "cu", "cuh", "cpp", "h", "hpp", "sh")
|
||||
|
||||
@ -48,11 +45,19 @@ class TestBuild(unittest.TestCase):
|
||||
|
||||
for extension in extensions:
|
||||
for path in root_dir.glob(f"**/*.{extension}"):
|
||||
if str(path).endswith(
|
||||
"pytorch3d/transforms/external/kornia_angle_axis_to_rotation_matrix.py"
|
||||
):
|
||||
continue
|
||||
if str(path).endswith("pytorch3d/csrc/pulsar/include/fastermath.h"):
|
||||
excluded_files = (
|
||||
"pytorch3d/transforms/external/kornia_angle_axis_to_rotation_matrix.py",
|
||||
"pytorch3d/csrc/pulsar/include/fastermath.h",
|
||||
)
|
||||
if in_conda_build:
|
||||
excluded_files += (
|
||||
"run_test.py",
|
||||
"run_test.sh",
|
||||
"conda_test_runner.sh",
|
||||
"conda_test_env_vars.sh",
|
||||
)
|
||||
|
||||
if str(path).endswith(excluded_files):
|
||||
continue
|
||||
with open(path) as f:
|
||||
firstline = f.readline()
|
||||
@ -64,7 +69,7 @@ class TestBuild(unittest.TestCase):
|
||||
if len(files_missing_copyright_header) != 0:
|
||||
self.fail("\n".join(files_missing_copyright_header))
|
||||
|
||||
@unittest.skipIf(in_conda_build or in_re_worker, "In conda build, or RE worker")
|
||||
@unittest.skipIf(in_re_worker, "In RE worker")
|
||||
def test_valid_ipynbs(self):
|
||||
# Check that the ipython notebooks are valid json
|
||||
root_dir = get_pytorch3d_dir()
|
||||
|
Loading…
x
Reference in New Issue
Block a user