def split_schemes()

in train/pantheon_env.py [0:0]


def split_schemes(schemes):
    """
    Split a comma-separated list of schemes.

    For instance, "bbr,mvfst_rl_fixed{cc_env_fixed_cwnd=2,10}" will become:
        ["bbr", "mvfst_rl_fixed{cc_env_fixed_cwnd=2,10}"]
    """
    split = schemes.split(",")
    # Note that we cannot simply return `split` now, as commas may appear
    # within a given scheme. We need to "re-join" some items in that split. We
    # use the "{" and "}" markers for this purpose.
    opening_pos = -1  # position of most recent "{" seen in `split`
    all_schemes = []
    for i, scheme in enumerate(split):
        if "{" in scheme and "}" not in scheme:
            # First component of a scheme: remember its position.
            assert opening_pos == -1
            opening_pos = i
        elif "}" in scheme and "{" not in scheme:
            # Last component of a scheme: re-join all intermediate components.
            assert opening_pos >= 0
            all_schemes.append(",".join(split[opening_pos : i + 1]))
            opening_pos = -1
        elif opening_pos >= 0:
            # Intermediate component: do nothing until we find the last one.
            pass
        else:
            # That scheme was not split initially, we can simply keep it.
            all_schemes.append(scheme)
    assert opening_pos == -1, schemes  # ensure all { are closed with }
    return all_schemes