Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICV-mmengine_basecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schiffel
ICV-mmengine_basecode
Commits
16058fdb
Unverified
Commit
16058fdb
authored
2 years ago
by
Zaida Zhou
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Fix] Fix RecursionError when key is invalid (#220)
* [Fix] Fix RecursionError when key is invalid * refine comments
parent
50078256
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmengine/registry/registry.py
+9
-2
9 additions, 2 deletions
mmengine/registry/registry.py
tests/test_registry/test_registry.py
+10
-0
10 additions, 0 deletions
tests/test_registry/test_registry.py
with
19 additions
and
2 deletions
mmengine/registry/registry.py
+
9
−
2
View file @
16058fdb
...
...
@@ -301,7 +301,7 @@ class Registry:
Args:
key (str): Name of the registered item, e.g., the class name in
string format.
string format.
Returns:
Type or None: Return the corresponding class if ``key`` exists,
...
...
@@ -355,7 +355,14 @@ class Registry:
scope_name
=
scope
else
:
root
=
self
.
_get_root_registry
()
obj_cls
=
root
.
get
(
key
)
if
scope
!=
root
.
_scope
and
scope
not
in
root
.
_children
:
# If not skip directly, `root.get(key)` will recursively
# call itself until RecursionError is thrown.
pass
else
:
obj_cls
=
root
.
get
(
key
)
if
obj_cls
is
not
None
:
logger
:
MMLogger
=
MMLogger
.
get_current_instance
()
logger
.
info
(
...
...
This diff is collapsed.
Click to expand it.
tests/test_registry/test_registry.py
+
10
−
0
View file @
16058fdb
...
...
@@ -281,6 +281,16 @@ class TestRegistry:
assert
HOUNDS
.
get
(
'
samoyed.little_samoyed.LittlePedigreeSamoyed
'
)
is
LittlePedigreeSamoyed
# invalid keys
# GoldenRetrieverererer can not be found at LITTLE_HOUNDS modules
assert
LITTLE_HOUNDS
.
get
(
'
GoldenRetrieverererer
'
)
is
None
# samoyedddd is not a child of DOGS
assert
DOGS
.
get
(
'
samoyedddd.PedigreeSamoyed
'
)
is
None
# samoyed is a child of DOGS but LittlePedigreeSamoyed can not be found
# at SAMOYEDS modules
assert
DOGS
.
get
(
'
samoyed.LittlePedigreeSamoyed
'
)
is
None
assert
LITTLE_HOUNDS
.
get
(
'
mid_hound.PedigreeSamoyedddddd
'
)
is
None
def
test_search_child
(
self
):
# Hierarchical Registry
# DOGS
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment