Skip to content

Warn when overwriting existing loader in register_loader#908

Open
swagat-mishra28 wants to merge 1 commit into
neuroinformatics-unit:mainfrom
swagat-mishra28:fix-loader-registry-warning
Open

Warn when overwriting existing loader in register_loader#908
swagat-mishra28 wants to merge 1 commit into
neuroinformatics-unit:mainfrom
swagat-mishra28:fix-loader-registry-warning

Conversation

@swagat-mishra28
Copy link
Copy Markdown

@swagat-mishra28 swagat-mishra28 commented Mar 18, 2026

Closes #903

Summary

While reviewing the loader registration mechanism in movement/io/load.py, I noticed that
register_loader() silently overwrites existing entries in the _LOADER_REGISTRY
when a loader is registered multiple times for the same source_software.

This behaviour can make debugging difficult, as an existing loader may be replaced
without any indication.

This PR improves transparency by emitting a warning when a loader is being
overwritten, while preserving the current behaviour that allows overwriting.

Changes

  • Added a warning in register_loader() when a loader for the same
    source_software already exists in _LOADER_REGISTRY.
  • The loader is still overwritten to maintain backward compatibility.

Example:

if source_software in _LOADER_REGISTRY:
    logger.warning(
        f"Loader for '{source_software}' is being overwritten."
    )

Testing

All tests were executed after the change:

pytest --ignore=tests/test_unit/test_napari_plugin

Result:

1011 passed, 4 deselected, 2 xfailed

Please let me know if you would prefer raising an error instead of a warning for duplicate loader registrations.

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loader registry silently overwrites loaders for the same source software

1 participant