Skip to content

Commit

Permalink
Add warnings for duplicate registry names
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleNyima authored and rwightman committed Nov 8, 2023
1 parent 0bc9a63 commit ef72c3c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions timm/models/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ def register_model(fn: Callable[..., Any]) -> Callable[..., Any]:
mod.__all__ = [model_name] # type: ignore

# add entries to registry dict/sets
if model_name in _model_entrypoints:
warnings.warn(
f'Overwriting {model_name} in registry with {fn.__module__}.{model_name}. This is because the name being '
'registered conflicts with an existing name. Please check if this is not expected.',
stacklevel=2,
)
_model_entrypoints[model_name] = fn
_model_to_module[model_name] = module_name
_module_to_models[module_name].add(model_name)
Expand Down

0 comments on commit ef72c3c

Please sign in to comment.