Skip to content

Commit ef72c3c

Browse files
LittleNyimarwightman
authored andcommitted
Add warnings for duplicate registry names
1 parent 0bc9a63 commit ef72c3c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

timm/models/_registry.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ def register_model(fn: Callable[..., Any]) -> Callable[..., Any]:
8686
mod.__all__ = [model_name] # type: ignore
8787

8888
# add entries to registry dict/sets
89+
if model_name in _model_entrypoints:
90+
warnings.warn(
91+
f'Overwriting {model_name} in registry with {fn.__module__}.{model_name}. This is because the name being '
92+
'registered conflicts with an existing name. Please check if this is not expected.',
93+
stacklevel=2,
94+
)
8995
_model_entrypoints[model_name] = fn
9096
_model_to_module[model_name] = module_name
9197
_module_to_models[module_name].add(model_name)

0 commit comments

Comments
 (0)