test & compilation fixes

Summary:
Fixes mostly related to the "main" build on circleci.
-Avoid error to do with tuple copy from initializer_list which is `explicit` on old compiler.
-Add better reporting to copyright test.
-Move to PackedTensorAccessor64 from the deprecated PackedTensorAccessor
-Avoid some warnings about mismatched comparisons.

The "main" build is the only one that runs the test_build stuff. In that area
-Fix my bad copyright fix D26275931 (3463f418b8) / 965c9c
-Add test that all tutorials are valid json.

Reviewed By: nikhilaravi

Differential Revision: D26366466

fbshipit-source-id: c4ab8b7e6647987069f7cb7144aa6ab7c24bcdac
This commit is contained in:
Jeremy Reizenstein
2021-02-11 11:04:30 -08:00
committed by Facebook GitHub Bot
parent e13e63a811
commit 5ac2f42184
5 changed files with 69 additions and 44 deletions

View File

@@ -1,4 +1,5 @@
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
import json
import os
import unittest
from collections import Counter
@@ -39,18 +40,33 @@ class TestBuild(unittest.TestCase):
+ " All rights reserved.\n"
)
files_missing_copyright_header = []
for extension in extensions:
for i in root_dir.glob(f"**/*.{extension}"):
if str(i).endswith(
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(i).endswith("pytorch3d/csrc/pulsar/include/fastermath.h"):
if str(path).endswith("pytorch3d/csrc/pulsar/include/fastermath.h"):
continue
with open(i) as f:
with open(path) as f:
firstline = f.readline()
if firstline.startswith(("# -*-", "#!")):
firstline = f.readline()
self.assertTrue(
firstline.endswith(expect), f"{i} missing copyright header."
)
if not firstline.endswith(expect):
files_missing_copyright_header.append(str(path))
if len(files_missing_copyright_header) != 0:
self.fail("\n".join(files_missing_copyright_header))
@unittest.skipIf(in_conda_build, "In conda build")
def test_valid_ipynbs(self):
# Check that the ipython notebooks are valid json
test_dir = Path(__file__).resolve().parent
tutorials_dir = test_dir.parent / "docs" / "tutorials"
tutorials = sorted(tutorials_dir.glob("*.ipynb"))
for tutorial in tutorials:
with open(tutorial) as f:
json.load(f)