Skip to content

[PROPOSAL] Plugin Discovery and Namespace Code Structure#130

Open
gustavorps wants to merge 1 commit into
reconurge:mainfrom
gustavorps:feat/ns-and-plugin
Open

[PROPOSAL] Plugin Discovery and Namespace Code Structure#130
gustavorps wants to merge 1 commit into
reconurge:mainfrom
gustavorps:feat/ns-and-plugin

Conversation

@gustavorps

@gustavorps gustavorps commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces a new plugin-based architecture for enrichers in the Flowsint project, leveraging Python's entry points and lazy loading to improve modularity and startup performance. It also adds new workspace package configurations and updates Python version requirements. The most important changes are grouped below:

Plugin architecture and lazy loading

  • Added a PEP 810-style lazy import utility in flowsint.enricher.util.importlib, enabling modules and entry points to be loaded only when first accessed, which reduces unnecessary imports and speeds up startup.
  • Updated flowsint.enricher.__init__.py to discover and lazily load plugins via entry points, printing loaded plugins and registry contents for debugging.
  • Introduced EnricherABC in flowsint.enricher.abc.py, which automatically registers subclasses with the enricher registry, supporting plugin discovery and registration.

Example plugin implementation

  • Added a new example plugin package flowsint-example-plugin with entry point configuration and a sample Enricher class, demonstrating the new plugin system and type annotations for input/output. [1] [2] [3]

Workspace and core package changes

  • Added workspace-compatible pyproject.toml files for flowsint-core-next, flowsint-enrichers-next, and flowsint-types-next, specifying Python version requirements and editable sources for modular development. [1] [2] [3]
  • Added __init__.py files to expose relevant symbols and updated the Python version to 3.13 in .python-version for compatibility with new features. [1] [2] [3]

Redis connection initialization fix

  • Deferred Redis connection in EventEmitter by adding a connect() method, preventing premature connection during module import and fixing issues when importing enrichers. [1] [2]

These changes lay the foundation for a scalable, plugin-based enrichment system with improved dependency management and startup efficiency.

How to test the PR

% cd python

% uv sync

% source .venv/bin/activate

% python -c 'import flowsint.enricher'
{'flowsint.example.enricher.mock:Enricher': <lazy entry point 'flowsint.example.enricher.mock:Enricher'>}
EntryPoint(name='flowsint.example.enricher.mock:Enricher', value='flowsint.example.enricher.mock:Enricher', group='flowsint.enricher')
<class 'flowsint.example.enricher.mock.Enricher'>
{'my_enricher': <class 'flowsint.example.enricher.mock.Enricher'>}

@gustavorps gustavorps changed the title Plugin Discovery and Namespace Code Structure [PROPOSAL] Plugin Discovery and Namespace Code Structure Mar 16, 2026
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.

1 participant