Skip to content

[Enhance] Add support for sequence input in --search-args option #195

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

Merged
merged 3 commits into from
Jan 17, 2023

Conversation

KKIEEK
Copy link
Contributor

@KKIEEK KKIEEK commented Jan 16, 2023

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

mim gridsearch mmcls $CONFIG --work-dir $WORK_DIR --gpus $GPUS \
    --search-args --train_dataloader.dataset.pipeline.0.key val1 val2 ...
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/mim/commands/gridsearch.py", line 288, in gridsearch
    arg_value = get_config(cfg, arg)
  File "/opt/conda/lib/python3.7/site-packages/mim/utils/utils.py", line 515, in get_config
    assert item in cfg, f'attribute {item} not cfg{suffix}'
AssertionError: attribute 1 not cfg.train_dataloader.dataset.pipeline

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/bin/mim", line 8, in <module>
    sys.exit(cli())
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/mim/commands/gridsearch.py", line 146, in cli
    other_args=other_args)
  File "/opt/conda/lib/python3.7/site-packages/mim/commands/gridsearch.py", line 298, in gridsearch
    raise AssertionError(highlighted_error(msg))
AssertionError: Arg train_dataloader.dataset.pipeline.0.key not in the config file. 

Modification

I added logic to handle the case when cfg is instance of Sequence in get_config and set_config functions

BC-breaking (Optional)

Does the modification introduce changes that break the back-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here, and update the documentation.

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.

@KKIEEK KKIEEK changed the title [Enhance] Add support for sequence input in --search-args option [Enhance] Add support for sequence input in --search-args option Jan 16, 2023
@ice-tong
Copy link
Collaborator

Hi @KKIEEK, thanks for you contribution!

This PR looks great to me, and the CI need to be fixed:

image

@KKIEEK KKIEEK force-pushed the feat/gridsearch-seq branch from c3817ef to bb3450c Compare January 17, 2023 04:44
@KKIEEK
Copy link
Contributor Author

KKIEEK commented Jan 17, 2023

@ice-tong I fixed it.

Copy link
Collaborator

@ice-tong ice-tong left a comment

Choose a reason for hiding this comment

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

LGTM

@ice-tong
Copy link
Collaborator

Please @zhouzaida have a look~

@zhouzaida zhouzaida merged commit 8fb7776 into open-mmlab:main Jan 17, 2023
@KKIEEK KKIEEK deleted the feat/gridsearch-seq branch January 17, 2023 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants