The update_config function in openstl/utils/main_utils.py has a logic bug that prevents config file values from overriding argparse
default values.
Current behavior:
def update_config(args, config, exclude_keys=list()):
for k in config.keys():
if args.get(k, False):
if args[k] != config[k] and k not in exclude_keys and args[k] is not None:
print(f'overwrite config key -- {k}: {config[k]} -> {args[k]}') # Only prints, doesn't assign!
else:
args[k] = config[k]
When args['dataname'] has the default value 'mmnist' and config file has dataname = 'custom_dataset', the config value is never
applied because:
- args.get('dataname', False) returns 'mmnist' (truthy)
- args[k] != config[k] is True
- It only prints a message but doesn't update args[k]
Expected behavior:
Config file values should override argparse defaults. The CLI-provided values should only take precedence when explicitly passed by
the user.
Suggested fix:
def update_config(args, config, exclude_keys=list()):
for k in config.keys():
if k in exclude_keys:
continue
if config[k] is not None:
args[k] = config[k]
return args
The update_config function in openstl/utils/main_utils.py has a logic bug that prevents config file values from overriding argparse
default values.
Current behavior:
def update_config(args, config, exclude_keys=list()):
for k in config.keys():
if args.get(k, False):
if args[k] != config[k] and k not in exclude_keys and args[k] is not None:
print(f'overwrite config key -- {k}: {config[k]} -> {args[k]}') # Only prints, doesn't assign!
else:
args[k] = config[k]
When args['dataname'] has the default value 'mmnist' and config file has dataname = 'custom_dataset', the config value is never
applied because:
Expected behavior:
Config file values should override argparse defaults. The CLI-provided values should only take precedence when explicitly passed by
the user.
Suggested fix:
def update_config(args, config, exclude_keys=list()):
for k in config.keys():
if k in exclude_keys:
continue
if config[k] is not None:
args[k] = config[k]
return args