1+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2+ # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
3+
14# Copyright (c) Meta Platforms, Inc. and affiliates.
25# All rights reserved.
36import argparse
@@ -17,16 +20,16 @@ class JobConfig:
1720 Semantics:
1821 - Default config is loaded from a toml file. If no toml file is provided,
1922 then the default config is loaded from argparse defaults.
23+ - if toml file has missing keys, they are filled with argparse defaults.
2024 """
2125
2226 def parse_args (self , args_list : list = sys .argv [1 :]):
2327 args = JobConfig .init_args_from_command_line (args_list )
2428 config_file = getattr (args , "job.config_file" , None )
25- if config_file is None :
26- args_dict = self ._args_to_two_level_dict (args )
27- else :
29+ args_dict = self ._args_to_two_level_dict (args )
30+ if config_file is not None :
2831 with open (config_file , "rb" ) as f :
29- args_dict = tomllib .load (f )
32+ args_dict | = tomllib .load (f )
3033 for k , v in args_dict .items ():
3134 class_type = type (k .title (), (), v )
3235 setattr (self , k , class_type ())
0 commit comments