Skip to content

[Bug] why config file _base_ param can not use other param in f-string? #758

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

Closed
2 tasks done
KevinNuNu opened this issue Nov 23, 2022 · 3 comments · May be fixed by #766
Closed
2 tasks done

[Bug] why config file _base_ param can not use other param in f-string? #758

KevinNuNu opened this issue Nov 23, 2022 · 3 comments · May be fixed by #766
Assignees
Labels
bug Something isn't working

Comments

@KevinNuNu
Copy link
Contributor

Prerequisite

Environment

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
OrderedDict([('sys.platform', 'darwin'), ('Python', '3.8.15 (default, Nov 10 2022, 13:17:42) [Clang 14.0.6 ]'), ('CUDA available', False), ('numpy_random_seed', 2147483648), ('GCC', 'Apple clang version 11.0.0 (clang-1100.0.33.8)'), ('PyTorch', '1.10.1'), ('PyTorch compiling details', 'PyTorch built with:\n - GCC 4.2\n - C++ Version: 201402\n - clang 12.0.0\n - Intel(R) Math Kernel Library Version 2020.0.1 Product Build 20200208 for Intel(R) 64 architecture applications\n - Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)\n - LAPACK is enabled (usually provided by MKL)\n - NNPACK is enabled\n - CPU capability usage: AVX2\n - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=/Applications/Xcode-12.0.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-unused-private-field -Wno-missing-braces -Wno-c++14-extensions -Wno-constexpr-not-const, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.1, USE_CUDA=OFF, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=OFF, \n'), ('TorchVision', '0.11.2'), ('OpenCV', '4.6.0'), ('MMEngine', '0.3.1')])

Reproduces the problem - code sample

test_config.py

mmyolo_configs = './mmyolo/configs'
_base_ = f'{mmyolo_configs}/yolov5/yolov5_s-v61_syncbn_fast_1xb4-300e_balloon.py'

test.py

from mmengine.config import Config

if __name__ == '__main__':
    cfg = Config.fromfile('./test_config.py')
    print(cfg)

Reproduces the problem - command or script

python test.py

Reproduces the problem - error message

Traceback (most recent call last):
File "/Users/wangnu/Documents/GitHub/my_det_engine.mmyolo/test.py", line 5, in
cfg = Config.fromfile('./test_config.py')
File "/Users/wangnu/opt/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/config/config.py", line 172, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename,
File "/Users/wangnu/opt/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/config/config.py", line 401, in _file2dict
for base_cfg_path in Config._get_base_files(temp_config_file.name):
File "/Users/wangnu/opt/anaconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/config/config.py", line 568, in _get_base_files
base_files = eval(compile(base_code, '', mode='eval'))
File "", line 2, in
NameError: name 'mmyolo_configs' is not defined
Exception ignored in: <function _TemporaryFileCloser.del at 0x7fcec570d1f0>
Traceback (most recent call last):
File "/Users/wangnu/opt/anaconda3/envs/mmyolo/lib/python3.8/tempfile.py", line 440, in del
self.close()
File "/Users/wangnu/opt/anaconda3/envs/mmyolo/lib/python3.8/tempfile.py", line 436, in close
unlink(self.name)
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/hv/l3bmh8zd42b9qdr4tmjr6bdw0000gn/T/tmphwtml0mh/tmpn0pg4mv6.py'

Additional information

openmmlab 1.0 mmcv.config.Config.fromfile() is work, so i think there is something wrong in the added code

but i can't solve it

# Handle base files
base_cfg_dict = ConfigDict()
cfg_text_list = list()
for base_cfg_path in Config._get_base_files(temp_config_file.name):
base_cfg_path, scope = Config._get_cfg_path(
base_cfg_path, filename)
_cfg_dict, _cfg_text = Config._file2dict(base_cfg_path)
cfg_text_list.append(_cfg_text)
duplicate_keys = base_cfg_dict.keys() & _cfg_dict.keys()
if len(duplicate_keys) > 0:
raise KeyError('Duplicate key is not allowed among bases. '
f'Duplicate keys: {duplicate_keys}')

@KevinNuNu KevinNuNu added the bug Something isn't working label Nov 23, 2022
@HAOCHENYE
Copy link
Collaborator

Hi, thanks for your feedback, I've tred to post a PR to fix this, will #766 help you?

@KevinNuNu
Copy link
Contributor Author

Hi, thanks for your feedback, I've tred to post a PR to fix this, will #766 help you?

Yes!!! The problem has been fixed, thx~

@KevinNuNu
Copy link
Contributor Author

Hi, when this pr #766 will be merged? @HAOCHENYE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants