[Fix] Exception while building registered function (#491)
parent
68b6b542eb
commit
94412f72d8
|
@ -114,7 +114,8 @@ def build_from_cfg(
|
|||
# If `obj_cls` inherits from `ManagerMixin`, it should be
|
||||
# instantiated by `ManagerMixin.get_instance` to ensure that it
|
||||
# can be accessed globally.
|
||||
if issubclass(obj_cls, ManagerMixin): # type: ignore
|
||||
if inspect.isclass(obj_cls) and \
|
||||
issubclass(obj_cls, ManagerMixin): # type: ignore
|
||||
obj = obj_cls.get_instance(**args) # type: ignore
|
||||
else:
|
||||
obj = obj_cls(**args) # type: ignore
|
||||
|
|
|
@ -339,6 +339,13 @@ class TestRegistry:
|
|||
registries = self._build_registry()
|
||||
DOGS, HOUNDS, LITTLE_HOUNDS, MID_HOUNDS, SAMOYEDS = registries[:5]
|
||||
|
||||
@DOGS.register_module()
|
||||
def bark(times=1):
|
||||
return ' '.join(['woof'] * times)
|
||||
|
||||
bark_cfg = cfg_type(dict(type='bark', times=3))
|
||||
assert DOGS.build(bark_cfg) == 'woof woof woof'
|
||||
|
||||
@DOGS.register_module()
|
||||
class GoldenRetriever:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue