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

TypeError: FormatCode() got an unexpected keyword argument 'verify' #139

Closed
is opened this issue Sep 24, 2023 · 5 comments
Closed

TypeError: FormatCode() got an unexpected keyword argument 'verify' #139

is opened this issue Sep 24, 2023 · 5 comments
Assignees

Comments

@is
Copy link

is commented Sep 24, 2023

clone源代码

commit b05ad8d (HEAD -> main, origin/main, origin/HEAD)

pip install -e .[all]
xtuner train xxxx

都是下面这个错误信息.

Traceback (most recent call last):
  File "/opt/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/config/config.py", line 1475, in pretty_text
    text, _ = FormatCode(
              ^^^^^^^^^^^
TypeError: FormatCode() got an unexpected keyword argument 'verify'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/jovyan/work/xtuner/xtuner/tools/train.py", line 246, in <module>
    main()
  File "/data/jovyan/work/xtuner/xtuner/tools/train.py", line 235, in main
    runner = Runner.from_cfg(cfg)
             ^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/runner/runner.py", line 445, in from_cfg
    runner = cls(
             ^^^^
  File "/opt/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/runner/runner.py", line 386, in __init__
    self._log_env(env_cfg)
  File "/opt/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/runner/runner.py", line 2356, in _log_env
    self.logger.info(f'Config:\n{self.cfg.pretty_text}')
                                 ^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/config/config.py", line 1478, in pretty_text
    raise SyntaxError('Failed to format the config file, please '
SyntaxError: Failed to format the config file, please check the syntax of: 

@is
Copy link
Author

is commented Sep 24, 2023

/data/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/config/config.py

1468         if self._format_python_code:
1469             # copied from setup.cfg
1470             yapf_style = dict(
1471                 based_on_style='pep8',
1472                 blank_line_before_nested_class_or_def=True,
1473                 split_before_expression_after_opening_paren=True)
1474             try:
1475                 text, _ = FormatCode(
1476                     text, style_config=yapf_style, verify=True)
1477             except:  # noqa: E722
1478                 raise SyntaxError('Failed to format the config file, please '
1479                                   f'check the syntax of: \n{text}')
1480         return text

@LZHgrla
Copy link
Collaborator

LZHgrla commented Sep 25, 2023

SyntaxError: Failed to format the config file, please check the syntax of: 

It seems that there is a syntax error in your config, could you please provide your config and we will check it.

@LZHgrla LZHgrla self-assigned this Sep 25, 2023
@is
Copy link
Author

is commented Sep 25, 2023

  20 from addict import Dict
  21 from rich.console import Console
  22 from rich.text import Text
  23 from yapf.yapflib.yapf_api import FormatCode
......
1475                 text, _ = FormatCode(
1476                     text, style_config=yapf_style, verify=True)
Traceback (most recent call last):
  File "/opt/conda/envs/xtuner/lib/python3.11/site-packages/mmengine/config/config.py", line 1475, in pretty_text
    text, _ = FormatCode(
              ^^^^^^^^^^^
TypeError: FormatCode() got an unexpected keyword argument 'verify'

我看的问题,推测是FormatCode这个函数,没有verify=True这个参数.

我看我本地安装的yapf是0.40.2

我没有编辑config,直接用缺省的qwen-*几个试了一下,都是同样的错误信息。

@is
Copy link
Author

is commented Sep 25, 2023

1475                 text, _ = FormatCode(
1476                     text, style_config=yapf_style, verify=True)

改成

1475                 text, _ = FormatCode(
1476                     text, style_config=yapf_style)

就能正常运行了.

@LZHgrla
Copy link
Collaborator

LZHgrla commented Sep 25, 2023

是的,确实是yapf版本的问题,0.40.2移除了verify参数。

open-mmlab/mmengine#1365 已经解决了这一问题,可以考虑从源码重新安装MMEngine

pip uninstall mmengine; pip install git+https://github.com/open-mmlab/mmengine.git

@is is closed this as completed Sep 25, 2023
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

No branches or pull requests

2 participants