From 45db24c396f3970069c4c244b6a66b9af6deab89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=9D=A6?= Date: Tue, 15 Mar 2022 12:55:41 +0800 Subject: [PATCH 1/2] [fix] config ignore modules and functions --- mmcv/utils/config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mmcv/utils/config.py b/mmcv/utils/config.py index 9cd4f5de72..7474da8538 100644 --- a/mmcv/utils/config.py +++ b/mmcv/utils/config.py @@ -7,6 +7,7 @@ import shutil import sys import tempfile +import types import uuid import warnings from argparse import Action, ArgumentParser @@ -209,6 +210,8 @@ def _file2dict(filename, use_predefined_variables=True): name: value for name, value in mod.__dict__.items() if not name.startswith('__') + and not isinstance(value, types.ModuleType) + and not isinstance(value, types.FunctionType) } # delete imported module del sys.modules[temp_module_name] From 529e1bc5b79a222a8b483909783e6592d41237a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=9D=A6?= Date: Fri, 18 Mar 2022 15:15:43 +0800 Subject: [PATCH 2/2] add unitest --- tests/data/config/l.py | 6 ++++++ tests/data/config/n.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/data/config/l.py b/tests/data/config/l.py index 85736f96e0..4a17bfcbcf 100644 --- a/tests/data/config/l.py +++ b/tests/data/config/l.py @@ -1,4 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp + + +def func(x): + return x + _base_ = ['./l1.py', './l2.yaml', './l3.json', './l4.py'] item3 = False item4 = 'test' diff --git a/tests/data/config/n.py b/tests/data/config/n.py index fa7aae266e..8d295984c8 100644 --- a/tests/data/config/n.py +++ b/tests/data/config/n.py @@ -1,4 +1,10 @@ # Copyright (c) OpenMMLab. All rights reserved. +import os.path as osp + + +def func(x): + return x + test_item1 = [1, 2] bool_item2 = True str_item3 = 'test'