Commit 42e7de41 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

fix test_build internal

Summary: Make test work in isolation, and when run internally make it not try the sqlalchemy files.

Reviewed By: shapovalov

Differential Revision: D46352513

fbshipit-source-id: 7417a25d7a5347d937631c9f56ae4e3242dd622e
parent 88429853
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# LICENSE file in the root directory of this source tree. # LICENSE file in the root directory of this source tree.
import importlib import importlib
import os
import sys import sys
import unittest import unittest
import unittest.mock import unittest.mock
...@@ -25,16 +26,23 @@ class TestBuild(unittest.TestCase): ...@@ -25,16 +26,23 @@ class TestBuild(unittest.TestCase):
if module.startswith("pytorch3d"): if module.startswith("pytorch3d"):
sys.modules.pop(module, None) sys.modules.pop(module, None)
# torchvision seems to cause problems if re-imported,
# so make sure it has been imported here.
import torchvision.utils # noqa
root_dir = get_pytorch3d_dir() / "pytorch3d" root_dir = get_pytorch3d_dir() / "pytorch3d"
# Exclude opengl-related files, as Implicitron is decoupled from opengl # Exclude opengl-related files, as Implicitron is decoupled from opengl
# components which will not work without adding a dep on pytorch3d_opengl. # components which will not work without adding a dep on pytorch3d_opengl.
for module_file in root_dir.glob("**/*.py"): ignored_modules = (
if module_file.stem in (
"__init__", "__init__",
"plotly_vis", "plotly_vis",
"opengl_utils", "opengl_utils",
"rasterizer_opengl", "rasterizer_opengl",
): )
if os.environ.get("FB_TEST", False):
ignored_modules += ("orm_types", "sql_dataset", "sql_dataset_provider")
for module_file in root_dir.glob("**/*.py"):
if module_file.stem in ignored_modules:
continue continue
relative_module = str(module_file.relative_to(root_dir))[:-3] relative_module = str(module_file.relative_to(root_dir))[:-3]
module = "pytorch3d." + relative_module.replace("/", ".") module = "pytorch3d." + relative_module.replace("/", ".")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment