change a lot
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import inspect
|
||||
from omegaconf.dictconfig import DictConfig
|
||||
from omegaconf import OmegaConf
|
||||
from types import ModuleType
|
||||
import warnings
|
||||
from types import ModuleType
|
||||
|
||||
from omegaconf import OmegaConf
|
||||
from omegaconf.dictconfig import DictConfig
|
||||
|
||||
|
||||
class _Registry:
|
||||
def __init__(self, name):
|
||||
@@ -136,8 +138,11 @@ class Registry(_Registry):
|
||||
if module_name is None:
|
||||
module_name = module_class.__name__
|
||||
if not force and module_name in self._module_dict:
|
||||
raise KeyError(f'{module_name} is already registered '
|
||||
f'in {self.name}')
|
||||
if self._module_dict[module_name] == module_class:
|
||||
warnings.warn(f'{module_name} is already registered in {self.name}, but is the same class')
|
||||
return
|
||||
raise KeyError(f'{module_name}:{self._module_dict[module_name]} is already registered in {self.name}'
|
||||
f'so {module_class} can not be registered')
|
||||
self._module_dict[module_name] = module_class
|
||||
|
||||
def register_module(self, name=None, force=False, module=None):
|
||||
|
||||
Reference in New Issue
Block a user