MCPcopy
hub / github.com/ray-project/ray / decode

Function decode

python/ray/_common/utils.py:461–479  ·  view source on GitHub ↗

Make this unicode in Python 3, otherwise leave it as bytes. Args: byte_str: The byte string to decode. allow_none: If true, then we will allow byte_str to be None in which case we will return an empty string. TODO(rkn): Remove this flag. This is only here

(byte_str: str, allow_none: bool = False, encode_type: str = "utf-8")

Source from the content-addressed store, hash-verified

459
460
461def decode(byte_str: str, allow_none: bool = False, encode_type: str = "utf-8"):
462 """Make this unicode in Python 3, otherwise leave it as bytes.
463
464 Args:
465 byte_str: The byte string to decode.
466 allow_none: If true, then we will allow byte_str to be None in which
467 case we will return an empty string. TODO(rkn): Remove this flag.
468 This is only here to simplify upgrading to flatbuffers 1.10.0.
469 encode_type: The encoding type to use for decoding. Defaults to "utf-8".
470
471 Returns:
472 A byte string in Python 2 and a unicode string in Python 3.
473 """
474 if byte_str is None and allow_none:
475 return ""
476
477 if not isinstance(byte_str, bytes):
478 raise ValueError(f"The argument {byte_str} must be a bytes object.")
479 return byte_str.decode(encode_type)
480
481
482class TimerBase(ABC):

Callers 2

run_string_as_driverFunction · 0.90
workersMethod · 0.90

Calls 1

decodeMethod · 0.45

Tested by 1

run_string_as_driverFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…