Skip to content

Add plugin system for external model packages using entry points - #315

Merged
nikhil-sarin merged 11 commits into
masterfrom
claude/plugin-system-entry-points-01WjDeASXWpeJfd3in1pA1BG
Feb 12, 2026
Merged

nikhil-sarin merged 11 commits into
masterfrom
claude/plugin-system-entry-points-01WjDeASXWpeJfd3in1pA1BG

Conversation

@nikhil-sarin

Copy link
Copy Markdown
Owner

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.

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.
@nikhil-sarin nikhil-sarin added the enhancement New feature or request label Nov 15, 2025
nikhil-sarin and others added 10 commits November 16, 2025 16:11
- 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
nikhil-sarin marked this pull request as ready for review February 12, 2026 07:01
@nikhil-sarin nikhil-sarin changed the title [WIP] - Add plugin system for external model packages using entry points Add plugin system for external model packages using entry points Feb 12, 2026
@nikhil-sarin
nikhil-sarin merged commit 7d2f632 into master Feb 12, 2026
17 of 18 checks passed
@nikhil-sarin
nikhil-sarin deleted the claude/plugin-system-entry-points-01WjDeASXWpeJfd3in1pA1BG branch August 21, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants