Skip to content

config_utils

dump_config(config)

Converts YML config into a string

Parameters:

Name Type Description Default
config dict

Config to dump

required

Returns:

Type Description
str

Config as a string

Source code in omnigibson/utils/config_utils.py
def dump_config(config):
    """
    Converts YML config into a string

    Args:
        config (dict): Config to dump

    Returns:
        str: Config as a string
    """
    return yaml.dump(config)

load_default_config()

Loads a default configuration to use for OmniGibson

Returns:

Type Description
dict

Loaded default configuration file

Source code in omnigibson/utils/config_utils.py
def load_default_config():
    """
    Loads a default configuration to use for OmniGibson

    Returns:
        dict: Loaded default configuration file
    """
    from omnigibson import example_config_path

    return parse_config(f"{example_config_path}/default_cfg.yaml")

parse_config(config)

Parse OmniGibson config file / object

Parameters:

Name Type Description Default
config dict or str

Either config dictionary or path to yaml config to load

required

Returns:

Type Description
dict

Parsed config

Source code in omnigibson/utils/config_utils.py
def parse_config(config):
    """
    Parse OmniGibson config file / object

    Args:
        config (dict or str): Either config dictionary or path to yaml config to load

    Returns:
        dict: Parsed config
    """
    if isinstance(config, collections.abc.Mapping):
        return config
    else:
        assert isinstance(config, str)

    if not os.path.exists(config):
        raise IOError(
            "config path {} does not exist. Please either pass in a dict or a string that represents the file path to the config yaml.".format(
                config
            )
        )
    with open(config, "r") as f:
        config_data = yaml.load(f, Loader=yaml.FullLoader)
    return config_data

parse_str_config(config)

Parse string config

Parameters:

Name Type Description Default
config str

Yaml cfg as a string to load

required

Returns:

Type Description
dict

Parsed config

Source code in omnigibson/utils/config_utils.py
def parse_str_config(config):
    """
    Parse string config

    Args:
        config (str): Yaml cfg as a string to load

    Returns:
        dict: Parsed config
    """
    return yaml.safe_load(config)