Skip to content

Commit

Permalink
Implement repr() for ArrayRecordDataSource.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 516235396
  • Loading branch information
ArrayRecord Team authored and copybara-github committed Mar 13, 2023
1 parent eda7e29 commit 7ede6e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/array_record_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __getitem__(self, record_keys: Sequence[int]) -> Sequence[T]:
import bisect
from concurrent import futures
import dataclasses
import hashlib
import itertools
import os
import pathlib
Expand Down Expand Up @@ -310,6 +311,13 @@ def close(self):
reader.close()
self._readers[reader_idx] = None

def __repr__(self) -> str:
"""Storing a hash of paths since paths can be a very long list."""
h = hashlib.sha1()
for p in self._paths:
h.update(p.encode())
return f"ArrayRecordDataSource(hash_of_paths={h.hexdigest()})"


def _get_flag_value(flag: flags.FlagHolder[int]) -> int:
"""Retrieves the flag value or the default if run outside of absl."""
Expand Down

0 comments on commit 7ede6e7

Please sign in to comment.