Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
ac52bb37
Unverified
Commit
ac52bb37
authored
Mar 22, 2022
by
Tan SU
Committed by
GitHub
Mar 22, 2022
Browse files
[fix] config ignore imported modules and functions (#1802)
* [fix] config ignore modules and functions * add unitest
parent
42062ede
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
mmcv/utils/config.py
mmcv/utils/config.py
+3
-0
tests/data/config/l.py
tests/data/config/l.py
+6
-0
tests/data/config/n.py
tests/data/config/n.py
+6
-0
No files found.
mmcv/utils/config.py
View file @
ac52bb37
...
@@ -7,6 +7,7 @@ import platform
...
@@ -7,6 +7,7 @@ import platform
import
shutil
import
shutil
import
sys
import
sys
import
tempfile
import
tempfile
import
types
import
uuid
import
uuid
import
warnings
import
warnings
from
argparse
import
Action
,
ArgumentParser
from
argparse
import
Action
,
ArgumentParser
...
@@ -209,6 +210,8 @@ class Config:
...
@@ -209,6 +210,8 @@ class Config:
name
:
value
name
:
value
for
name
,
value
in
mod
.
__dict__
.
items
()
for
name
,
value
in
mod
.
__dict__
.
items
()
if
not
name
.
startswith
(
'__'
)
if
not
name
.
startswith
(
'__'
)
and
not
isinstance
(
value
,
types
.
ModuleType
)
and
not
isinstance
(
value
,
types
.
FunctionType
)
}
}
# delete imported module
# delete imported module
del
sys
.
modules
[
temp_module_name
]
del
sys
.
modules
[
temp_module_name
]
...
...
tests/data/config/l.py
View file @
ac52bb37
# Copyright (c) OpenMMLab. All rights reserved.
# 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'
]
_base_
=
[
'./l1.py'
,
'./l2.yaml'
,
'./l3.json'
,
'./l4.py'
]
item3
=
False
item3
=
False
item4
=
'test'
item4
=
'test'
tests/data/config/n.py
View file @
ac52bb37
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import
os.path
as
osp
def
func
(
x
):
return
x
test_item1
=
[
1
,
2
]
test_item1
=
[
1
,
2
]
bool_item2
=
True
bool_item2
=
True
str_item3
=
'test'
str_item3
=
'test'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment