def format_size(size: int) -> str:
    """Format a size (in bytes) into a human-readable string. This will use SI
    prefixes. Implementation details are largely copied from
    [millify](https://github.com/azaitsev/millify).

    Args:
        size: The quantity to format.

    Returns:
        str: The formatted quantity.
    """

    units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
    unit_idx = max(
        0,
        min(
            len(units) - 1,
            int(math.floor(0 if size == 0 else math.log10(abs(size)) / 3)),
        ),
    )
    result = f"{int(size / 10 ** (3 * unit_idx)):d}"

    return f"{result}{units[unit_idx]}"
Format a size (in bytes) into a human-readable string. This will use SI
    prefixes. Implementation details are largely copied from
    [millify](https://github.com/azaitsev/millify).

    Args:
        size: The quantity to format.

    Returns:
        str: The formatted quantity.
    
src/core/trulens/core/utils/text.py