from typing import Dict


def config_str_to_dict(config_str: str) -> Dict[str, str]:
    """Converts a Gin.config_str() to a dict for logging with comet.ml"""

    predicate = lambda x: len(x) > 0 and not x.startswith("#")
    to_kv = lambda x: [l.strip() for l in x.split("=")]
    lines = config_str.splitlines()
    return {k: v for k, v in map(to_kv, filter(predicate, lines))}