Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support help and required argument for the configs #294

Merged
merged 5 commits into from
Aug 11, 2022

Conversation

yxdyc
Copy link
Collaborator

@yxdyc yxdyc commented Aug 8, 2022

As the title said, now we can set argument as

cfg.fedopt.optimizer.type = Argument(
        'SGD', description="optimizer type for FedOPT")

And the main.py will print help info as follows:
image

@yxdyc yxdyc added the enhancement New feature or request label Aug 8, 2022
@yxdyc yxdyc requested review from xieyxclack and DavdGao August 8, 2022 05:08
Copy link
Collaborator

@xieyxclack xieyxclack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please see the inline comments for minor suggestions. THX!

@@ -3,7 +3,7 @@ def wrap_attacker_trainer(base_trainer, config):
Args:
base_trainer (core.trainers.GeneralTorchTrainer): the trainer that
will be wrapped;
config (yacs.config.CfgNode): the configure;
config (core.configs.config.CN): the configure;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core.configs -> federatedscope.core.configs?

@@ -68,7 +67,7 @@ def run(self):
def get_scheduler(init_cfg):
"""To instantiate an scheduler object for conducting HPO
Arguments:
init_cfg (yacs.Node): configuration.
init_cfg (core.configs.config.CN): configuration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@@ -88,8 +87,8 @@ class Scheduler(object):
def __init__(self, cfg):
"""
Arguments:
cfg (yacs.Node): dict like object, where each key-value pair
corresponds to a field and its choices.
cfg (ycore.configs.config.CN): dict like object, where each
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typos

parser.add_argument('opts',
help='See federatedscope/core/configs for all options',
default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parse_res = parser.parse_args(args)
from federatedscope.core.configs.config import global_cfg
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should move the import to the top of the file

parse_res = parser.parse_args(args)
from federatedscope.core.configs.config import global_cfg
init_cfg = global_cfg.clone()
if len(sys.argv) == 1 or parse_res.help == "all":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add some comments for these if sentences

@@ -23,7 +23,10 @@
},
"source": [
"## Configurations\n",
"**FederatedScope** organize the configuration through `yacs.config.cfgNode` and can be found in `federatedscope.configs`. Please refer to the [official documentation](https://federatedscope.io/refs/index) for specific instructions on how to configure `cfg`."
"**FederatedScope** organize the configuration through `core.configs.config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a formatting issue?

@@ -49,7 +49,9 @@
"For more larger datasets, please refer examples in `scripts/personalization_exp_scripts`.\n",
"\n",
"### Configuration\n",
"**FederatedScope** organizes the configuration through an extension of `yacs.config.cfgNode`. Please refer to our [official documentation](https://federatedscope.io/docs/own-case/) for specific instructions on how to configure the initial `global_cfg` and customize your own configuration. By default, we provide built-in personalization-related configurations in `federatedscope/core/configs/`."
"**FederatedScope** organizes the configuration through an extension of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@@ -0,0 +1,600 @@
# An extended configuration system based on [yacs],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add these to LICENSE too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please see the inline comments for minor suggestions. THX!

I made modifications according to the comments

- modified according to yuexiang's comments.
LICENSE Outdated
Code in federatedscope/core/configs/yacs_config.py, the basic code of yacs
adopts Apache 2.0 License

# Copyright (c) 2018-present, Facebook, Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncomment

- modified according to yuexiang's comments
@DavdGao
Copy link
Collaborator

DavdGao commented Aug 9, 2022

@yxdyc Here is some of my concerns:

  • Does it mean that we need to set the arguments by python federatedscope/main.py --fedopt.optimizer.lr==0.1 in the future?
  • Is it compatible with the old scripts? e.g., python federatedscope/main.py fedopt.optimizer=0.1
  • In current master branch some namespaces support customized arguments. For example, users can add new arguments under the namespace train.optimizer, finetune.optimizer and fedopt.optimizer (we have set new_allowed=True), which haven't been pre-defined in our config files. I'm not sure if the new mechanism still supports it.

@yxdyc
Copy link
Collaborator Author

yxdyc commented Aug 10, 2022

@yxdyc Here is some of my concerns:

  • Does it mean that we need to set the arguments by python federatedscope/main.py --fedopt.optimizer.lr==0.1 in the future?
  • Is it compatible with the old scripts? e.g., python federatedscope/main.py fedopt.optimizer=0.1
  • In current master branch some namespaces support customized arguments. For example, users can add new arguments under the namespace train.optimizer, finetune.optimizer and fedopt.optimizer (we have set new_allowed=True), which haven't been pre-defined in our config files. I'm not sure if the new mechanism still supports it.

Thanks for the questions. I have added de_arguments for compatibility with historical codes

Copy link
Collaborator

@xieyxclack xieyxclack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we can add descriptions of configs later. Thanks!

@xieyxclack xieyxclack merged commit dd012a8 into alibaba:master Aug 11, 2022
Schichael pushed a commit to Schichael/FederatedScope_thesis that referenced this pull request Sep 7, 2022
- support help and required argument for the configs
- added de-arguments for compatibility with historical codes
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants