Repository navigation
Add plugin system for external model packages using entry points - #315
Merged
nikhil-sarin merged 11 commits intoFeb 12, 2026
Merged
nikhil-sarin merged 11 commits into
nikhil-sarin merged 11 commits into
Conversation
Implements a plugin system that allows external packages to register custom model modules using Python setuptools entry points. This enables developers to extend Redback with new models without modifying the core codebase. Key changes: - Added plugin discovery functions in model_library.py using entry points - Supports two entry point groups: 'redback.model.modules' and 'redback.model.base_modules' - Maintains full backward compatibility with existing models - Added comprehensive documentation in PLUGIN_GUIDE.md - Created example plugin demonstrating usage - Added unit tests for plugin system functionality - Updated setup.py with entry_points configuration example The plugin system automatically discovers and loads models from installed packages at import time, making them available in all_models_dict alongside built-in models. External packages can register their models by adding entry points in their setup.py or pyproject.toml.
- Remove unused 'importlib' import from model_library.py - Expand test suite from 15 to 50+ comprehensive tests - Add direct tests for discover_model_plugins() and discover_base_model_plugins() - Test both Python 3.10+ (select method) and older (get method) paths - Test error handling: module load failures, entry_points errors - Test multiple plugin discovery and partial success scenarios - Test model library state: all dicts, lists, and module structure - Test backward compatibility: existing imports, model lookups - Test edge cases: empty entry points, missing models - Verify all built-in modules are properly loaded
Major test coverage improvements: - Add stdout capture tests for print statements (lines 58, 110) - Test module processing loop with get_functions_dict integration - Test every builtin module is loaded (11 specific module tests) - Test module name extraction and dict key matching - Test all base models come from base modules - Test no duplicate model names in modules - Add backward compatibility tests for all new exports - Test integer and None key error handling - Verify builtin modules are actual Python module objects - Test modules_dict keys correspond to module names - Comprehensive integration tests with actual module function extraction
The CI workflow explicitly runs specific test files in groups. Group 4 includes test/model_library_test.py but the new plugin_system_test.py was not included in any group. By moving the tests to model_library_test.py, they will now be picked up by the CI test runner and coverage reports. This ensures the 90+ plugin system tests are actually executed during CI, providing proper coverage for the new plugin discovery functionality.
The previous tests heavily relied on mocking which prevented actual code execution in model_library.py. This revision: - Adds TestPluginDiscoveryRealExecution class that calls the real discover_model_plugins() and discover_base_model_plugins() functions without any mocks, exercising lines 39-70, 93-122 - These real calls execute hasattr checks, entry_points() calls, and the select/get branches - Mock tests remain for error handling scenarios (exceptions, warnings) that can't be triggered in normal execution - Simplified and reorganized test classes for better structure - Reduced from 90+ tests to ~85 focused tests that actually exercise code This ensures coverage tools see the actual code execution during test runs.
nikhil-sarin
marked this pull request as ready for review
February 12, 2026 07:01
nikhil-sarin
deleted the
claude/plugin-system-entry-points-01WjDeASXWpeJfd3in1pA1BG
branch
August 21, 2026 07:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a plugin system that allows external packages to register custom model modules using Python setuptools entry points. This enables developers to extend Redback with new models without modifying the core codebase.
Key changes:
The plugin system automatically discovers and loads models from installed packages at import time, making them available in all_models_dict alongside built-in models. External packages can register their models by adding entry points in their setup.py or pyproject.toml.