Skip to content

Commit f8762d6

Browse files
sarahtranfbfacebook-github-bot
authored andcommitted
Fix unit test listing (#1574)
Summary: Pull Request resolved: #1574 On a clean, stable fbcode checkout, running `buck test fbcode//pytorch/captum/tests/utils:test_progress` yields `NO TESTS RAN` consistently. Looking at the TestX dashboard, some Captum tests had not been run since 5/22, which coincides with D75113906, e.g. [pytorch/captum/tests/utils:test_progress - test_nested_simple_progress](https://www.internalfb.com/intern/test/562950126652826?ref_report_id=0): https://www.internalfb.com/intern/px/p/7nGLJ My hypothesis is that the current `BaseTest` assignment in init confuses unit test listing/discovery, however not all the Captum unit tests that extend `BaseTest` are impacted... frankly not sure why. However the repro on the affected tests are consistent Some example tests that are not affected: test_feature_permutation, test_common Affected examples: test_linear_model, test_jacobian, test_infidelity Running from fbcode stable, ~1500 tests run: ``` [sarahtran@8176.od /data/sandcastle/boxes/fbsource (e78e7566fd)]$ buck test fbcode//pytorch/captum/tests/... File changed: fbcode//pytorch/captum/captum/testing/helpers/__init__.py ⃠ Omitted: pytorch/captum/tests/influence/fb/examples/simple:captum.influence.simple_example - main Test has been omitted from this run because of the reason: Fails label filtering because: Negative filters present: slow No missing positive labels. Buck UI: https://www.internalfb.com/buck2/110b3a2a-43f5-4960-9025-108d1a854baf Test UI: https://www.internalfb.com/intern/testinfra/testrun/15199648830072998 Network: Up: 728KiB Down: 621KiB (reSessionID-5fea945a-5dc6-43ad-b7f0-cd3d53656a22) Executing actions. Remaining 0/243 Command: test. Finished 127 cache (100% hit) Time elapsed: 4:02.8s Tests finished: Pass 1561. Fail 0. Fatal 0. Skip 1. Build failure 0 ``` Reviewed By: jjuncho Differential Revision: D75927248 fbshipit-source-id: aa95489178fadcb809f4d5884b4cbaedb3109081
1 parent 7dac7f4 commit f8762d6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

captum/testing/attr/helpers/attribution_delta_util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def assert_attribution_delta(
1919
) -> None:
2020
if not is_layer:
2121
for input, attribution in zip(inputs, attributions):
22+
# Pyre error in OSS environment only
23+
# pyre-ignore[16]: `BaseTest` has no attribute `assertEqual`
2224
test.assertEqual(attribution.shape, input.shape)
2325
if isinstance(inputs, tuple):
2426
bsz = inputs[0].shape[0]
@@ -34,6 +36,8 @@ def assert_delta(
3436
test: BaseTest, delta: Tensor, delta_thresh: Union[Tensor, float] = 0.0006
3537
) -> None:
3638
delta_condition = (delta.abs() < delta_thresh).all()
39+
# Pyre error in OSS environment only
40+
# pyre-ignore[16]: `BaseTest` has no attribute `assertTrue`
3741
test.assertTrue(
3842
delta_condition,
3943
"Sum of SHAP values {} does"

captum/testing/helpers/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44

55
try:
66
from captum.testing.helpers.fb.internal_base import ( # type: ignore
7-
FbBaseTest as _BaseTest,
7+
FbBaseTest as BaseTest,
88
)
99

1010
except ImportError:
1111
# tests/helpers/__init__.py:13: error: Incompatible import of "_BaseTest"
1212
# (imported name has type "type[BaseTest]", local name has type
1313
# "type[FbBaseTest]") [assignment]
14-
from captum.testing.helpers.basic import BaseTest as _BaseTest # type: ignore
15-
16-
BaseTest = _BaseTest
14+
from captum.testing.helpers.basic import BaseTest # type: ignore
1715

1816
__all__ = [
1917
"BaseTest",

0 commit comments

Comments
 (0)