Skip to content

Commit

Permalink
Make chunkparser more robust.
Browse files Browse the repository at this point in the history
Some clients are sending corrupted data, make the
chunk parser resilient against it.
  • Loading branch information
gcp committed Apr 2, 2019
1 parent f6c18ac commit f5e6e9f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions training/tf/chunkparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,11 @@ def convert_v1_to_v2(self, text_item):
for plane in range(0, 16):
# first 360 first bits are 90 hex chars, encoded MSB
hex_string = text_item[plane][0:90]
array = np.unpackbits(np.frombuffer(
bytearray.fromhex(hex_string), dtype=np.uint8))
try:
array = np.unpackbits(np.frombuffer(
bytearray.fromhex(hex_string), dtype=np.uint8))
except:
return False, None
# Remaining bit that didn't fit. Encoded LSB so
# it needs to be specially handled.
last_digit = text_item[plane][90]
Expand Down

0 comments on commit f5e6e9f

Please sign in to comment.