Skip to content

Commit

Permalink
Correctly set _paths for implementation of __repr__().
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 516271701
  • Loading branch information
Marvin182 authored and copybara-github committed Mar 13, 2023
1 parent 7ede6e7 commit 9474099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/array_record_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def __init__(
"a Sequence, String, pathlib.Path or FileInstruction."
)
self._read_instructions = _get_read_instructions(paths)
self._paths = [ri.filename for ri in self._read_instructions]
# We open readers lazily when we need to read from them.
self._readers = [None] * len(self._read_instructions)
self._num_records = sum(
Expand Down
7 changes: 7 additions & 0 deletions python/array_record_data_source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ def test_array_record_source_empty_sequence(self):
with self.assertRaises(ValueError):
array_record_data_source.ArrayRecordDataSource([])

def test_repr(self):
ar = array_record_data_source.ArrayRecordDataSource([
self.testdata_dir / "digits.array_record-00000-of-00002",
self.testdata_dir / "digits.array_record-00001-of-00002",
])
self.assertRegex(repr(ar), r"ArrayRecordDataSource\(hash_of_paths=[\w]+\)")


class RunInParallelTest(parameterized.TestCase):

Expand Down

0 comments on commit 9474099

Please sign in to comment.