Skip to content

Commit

Permalink
fix(arg): Fix argument setting via CLI
Browse files Browse the repository at this point in the history
Arguments set via CLI meanwhile config file has no FL method specific struct can be overrided properly now.
  • Loading branch information
KarhouTam committed Oct 5, 2024
1 parent 4618750 commit d0fe5a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ Defaults are set in both [`config/defaults.yaml`](config/defaults.yaml) and [`sr
> ```
>
> ```shell
> python main.py method=fedprox # fedprox.mu = 1
> python main.py --config-name your_config method=fedprox # fedprox.mu = 0.01
> python main.py method=fedprox # fedprox.mu = 1
> python main.py --config-name your_config method=fedprox # fedprox.mu = 0.01
> python main.py --config-name your_config method=fedprox fedprox.mu=0.001 # fedprox.mu = 0.001
> ```
### Monitor 📈
Expand Down
11 changes: 10 additions & 1 deletion src/utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,17 @@ def _merge_configs(defaults: DictConfig, config: DictConfig) -> DictConfig:

final_args = _merge_configs(final_args, config)

if hasattr(config, method_name):
final_args[method_name] = config[method_name]

if get_method_args_func is not None:
final_args[method_name] = DictConfig(get_method_args_func([]).__dict__)
default_method_args = DictConfig(get_method_args_func([]).__dict__)
if hasattr(final_args, method_name):
for key in default_method_args.keys():
if key not in final_args[method_name].keys():
final_args[method_name][key] = default_method_args[key]
else:
final_args[method_name] = default_method_args

assert final_args.mode in [
"serial",
Expand Down

0 comments on commit d0fe5a3

Please sign in to comment.