MCPcopy Create free account
hub / github.com/pytorch/pytorch / decode1

Method decode1

torch/utils/data/datapipes/utils/decoder.py:295–310  ·  view source on GitHub ↗
(self, key, data)

Source from the content-addressed store, hash-verified

293 return isinstance(obj_to_check, (io.BufferedIOBase, io.RawIOBase))
294
295 def decode1(self, key, data):
296 if not data:
297 return data
298
299 # if data is a stream handle, we need to read all the content before decoding
300 if Decoder._is_stream_handle(data):
301 ds = data
302 # The behavior of .read can differ between streams (e.g. HTTPResponse), hence this is used instead
303 data = b"".join(data)
304 ds.close()
305
306 for f in self.handlers:
307 result = f(key, data)
308 if result is not None:
309 return result
310 return data
311
312 def decode(self, data):
313 result = {}

Callers 1

decodeMethod · 0.95

Calls 4

_is_stream_handleMethod · 0.80
fFunction · 0.50
joinMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected