Fetch args from only --base
(args)
| 287 | |
| 288 | |
| 289 | def process_config_to_args(args): |
| 290 | """Fetch args from only --base""" |
| 291 | |
| 292 | configs = [OmegaConf.load(cfg) for cfg in args.base] |
| 293 | config = OmegaConf.merge(*configs) |
| 294 | |
| 295 | args_config = config.pop("args", OmegaConf.create()) |
| 296 | for key in args_config: |
| 297 | if isinstance(args_config[key], omegaconf.DictConfig) or isinstance(args_config[key], omegaconf.ListConfig): |
| 298 | arg = OmegaConf.to_object(args_config[key]) |
| 299 | else: |
| 300 | arg = args_config[key] |
| 301 | if hasattr(args, key): |
| 302 | setattr(args, key, arg) |
| 303 | |
| 304 | if "model" in config: |
| 305 | model_config = config.pop("model", OmegaConf.create()) |
| 306 | args.model_config = model_config |
| 307 | if "deepspeed" in config: |
| 308 | deepspeed_config = config.pop("deepspeed", OmegaConf.create()) |
| 309 | args.deepspeed_config = OmegaConf.to_object(deepspeed_config) |
| 310 | if "data" in config: |
| 311 | data_config = config.pop("data", OmegaConf.create()) |
| 312 | args.data_config = data_config |
| 313 | |
| 314 | return args |