def format_bytes(bytes_value):
    """Format bytes to a human-readable string."""
    for unit in ["B", "KB", "MB", "GB", "TB"]:
        if bytes_value < 1024.0:
            return f"{bytes_value:.2f} {unit}"
        bytes_value /= 1024.0
    return f"{bytes_value:.2f} PB"
Format bytes to a human-readable string.
docs/usage/memory_sentinel.py