Skip to content

Commit ee4d98b

Browse files
Olivia-liufacebook-github-bot
authored andcommitted
Remove getter for event_blocks (#581)
Summary: Pull Request resolved: #581 Remove the getter function because it's more Pythonic to just access the attributes (I read this [article](https://realpython.com/python-getter-setter/#:~:text=In%20OOP%2C%20the%20getter%20and,use%20getter%20and%20setter%20methods.) says so). Reviewed By: Jack-Khuu Differential Revision: D49853351 fbshipit-source-id: 54c5f5fef3ad52887a58d252a780fb98ea4e4334
1 parent 1297f7d commit ee4d98b

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

sdk/inspector/inspector.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class Inspector:
364364
APIs for examining model architecture and performance stats.
365365
366366
Public Attributes:
367-
event_blocks: List["EventBlocks"]. Structured data accessible through Inspector for analysis.
367+
event_blocks: List["EventBlocks"]. Structured data from ETDump (correlated with ETRecord if provided).
368368
369369
Private Attributes:
370370
_etrecord: Optional[ETRecord]. File under etrecord_path deserialized into an object.
@@ -461,12 +461,6 @@ def find_total_for_module(self, module_name: str):
461461
break
462462
return total
463463

464-
def get_event_blocks(self) -> List[EventBlock]:
465-
"""
466-
Returns EventBlocks containing contents from ETDump (correlated to ETRecord if provided)
467-
"""
468-
return self.event_blocks
469-
470464
def get_op_list(
471465
self, event_block: str, show_delegated_ops: Optional[bool] = True
472466
) -> Dict[str, List[Event]]:

sdk/inspector/tests/inspector_test.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_inspector_constructor(self):
7575
# Because we mocked parse_etrecord() to return None, this method shouldn't be called
7676
mock_gen_graphs_from_etrecord.assert_not_called()
7777

78-
def test_inspector_get_event_blocks_and_print_data_tabular(self):
78+
def test_inspector_print_data_tabular(self):
7979
# Create a context manager to patch functions called by Inspector.__init__
8080
with patch.object(inspector, "parse_etrecord", return_value=None), patch.object(
8181
inspector, "gen_etdump_object", return_value=None
@@ -88,14 +88,11 @@ def test_inspector_get_event_blocks_and_print_data_tabular(self):
8888
etrecord_path=ETRECORD_PATH,
8989
)
9090

91-
# Test get_event_blocks() method. The mock inspector instance should start with having an empty event blocks list
92-
event_block_list = [
91+
# The mock inspector instance starts with having an empty event blocks list.
92+
# Add non-empty event blocks to test print_data_tabular().
93+
inspector_instance.event_blocks = [
9394
EventBlock(name=EVENT_BLOCK_NAME, events=self._gen_random_events())
9495
]
95-
# Add non-empty event blocks to test get_event_blocks() and print_data_tabular()
96-
inspector_instance.event_blocks = event_block_list
97-
self.assertEqual(inspector_instance.get_event_blocks(), event_block_list)
98-
9996
# Call print_data_tabular(), make sure it doesn't crash
10097
with redirect_stdout(None):
10198
inspector_instance.print_data_tabular()

0 commit comments

Comments
 (0)