Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Enhance] Support multiple --cfg-options. #759

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

mzr1996
Copy link
Member

@mzr1996 mzr1996 commented Nov 24, 2022

Motivation

Sometimes, we want to create a bash script with some default --cfg-options, like

python tools/train.py $1 --cfg-options default_hooks.checkpoint.save_best=True ${@:2}

but when we use the script, and pass another --cfg-options to it, the last one will overwrite the previous completely.

Modification

According to the extend action of Python, I modified the DictAction in MMEngine, and now it supports multiple --cfg-options and will concat these options.

BC-breaking (Optional)

Almost not, unless users exactly use multiple options and want the last one to overwrite the previous one.

Use cases (Optional)

python tools/train.py $1 --cfg-options default_hooks.checkpoint.save_best=True --cfg-options train_cfg.max_epochs=300

And we will get both options.

Checklist

  1. Pre-commit or other linting tools are used to fix the potential lint issues.
  2. The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  3. If the modification has potential influence on downstream projects, this PR should be tested with downstream projects, like MMDet or MMCls.
  4. The documentation has been modified accordingly, like docstring or example tutorials.

@HAOCHENYE HAOCHENYE added the enhancement New feature or request label Nov 24, 2022
HAOCHENYE
HAOCHENYE previously approved these changes Nov 24, 2022
Copy link
Collaborator

@HAOCHENYE HAOCHENYE left a comment

Choose a reason for hiding this comment

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

Approved!!!
image

@mzr1996
Copy link
Member Author

mzr1996 commented Dec 5, 2022

Please add this usage at https://github.com/open-mmlab/mmengine/blob/main/docs/zh_cn/tutorials/config.md#%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%BF%AE%E6%94%B9%E9%85%8D%E7%BD%AE

Updated

C1rN09
C1rN09 previously approved these changes Dec 5, 2022
Copy link
Collaborator

@C1rN09 C1rN09 left a comment

Choose a reason for hiding this comment

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

LGTM!

@zhouzaida
Copy link
Collaborator

This PR can be merged after resolving the conflicts and updating the English docs.

@zhouzaida zhouzaida merged commit fe26c65 into open-mmlab:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants