Skip to content

Commit 7a471e1

Browse files
MarkDaoustcopybara-github
authored andcommitted
Add logging to the api traversal filtering.
I often find myself stepping through here with a debugger. Just write some logs instead. This will help any investigation into why a symbol was or was not included in the resulting API. PiperOrigin-RevId: 439970734
1 parent 6744078 commit 7a471e1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tools/tensorflow_docs/api_generator/traverse.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
import inspect
1717
import sys
1818

19+
import logging
1920
from google.protobuf.message import Message as ProtoMessage
2021

22+
# To see the logs pass: --logger_levels=tensorflow_docs:DEBUG --alsologtostderr
23+
_LOGGER = logging.getLogger(__name__)
24+
2125
__all__ = ['traverse']
2226

2327

@@ -162,9 +166,18 @@ def _traverse_internal(root, visitors, stack, path):
162166
filtered_children.append((name, child))
163167
children = filtered_children
164168

169+
_LOGGER.debug('path: %s', path)
170+
_LOGGER.debug('children: %s', [n for n, c in children])
165171
# Apply all callbacks, allowing each to filter the children
166172
for visitor in visitors:
167-
children = visitor(path, root, list(children))
173+
old_names = [n for n, c in children]
174+
children = visitor(path, root, children)
175+
children = list(children)
176+
new_names = [n for n, c in children]
177+
178+
if old_names != new_names:
179+
_LOGGER.debug('filter: %s', visitor)
180+
_LOGGER.debug('children: %s', new_names)
168181

169182
for name, child in children:
170183
# Break cycles

0 commit comments

Comments
 (0)