def parse_config(raw_args, name: str, resources: dict) -> tuple[dict, str]:
    """Parse config and related resource args."""
    parser = argparse.ArgumentParser(f"{name} config")

    # parse config arg
    config_name = f"{name}_config"
    resource_map_name = f"{name}_resource_map"
    parser.add_argument(f"--{config_name}", type=str, help=f"{name} config", required=True)
    parser.add_argument(f"--{resource_map_name}", type=str, help=f"{name} resource path")

    args, extra_args = parser.parse_known_args(raw_args)
    args = vars(args)

    # load config json
    with open(args[config_name]) as f:
        config = json.load(f)

    if args[resource_map_name] is None:
        return config, extra_args

    # load resource map json
    with open(args[resource_map_name]) as f:
        resource_map = json.load(f)

    # replace resource paths in config
    for resource_key, resource_name in resource_map:
        set_nested_dict_value(config, resource_key, resources[resource_name])

    return config, extra_args
Parse config and related resource args.
olive/systems/utils/arg_parser.py