def format_unit(x: Union[float, int]) -> str:
    """Converts an integer to a string with respect of units."""

    base = 1024
    if x < 1:
        return f"{int(x*1000)}m"

    if x < 500:  # assume cpu. No more than 500 cpus. Assuming no 500 bytes memory allocation
        return f"{x}"

    binary_units = ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei"]

    x = int(x)
    for i, unit in enumerate(binary_units):
        if x < base ** (i + 1) or i == len(binary_units) - 1 or x / base ** (i + 1) < 10:
            return f"{x/base**i:.0f}{unit}"
    return f"{x/6**i:.0f}{unit}"
Converts an integer to a string with respect of units.
src/robusta/core/model/pods.py