Auto Inject Proxy
GitHub Link to Code.
Auto-injection proxy for pipeline managers.
This module provides the AutoInjectProxy class that automatically detects whether a method needs PipelineData and injects it as the first parameter when needed. This eliminates the need for manual wrapper methods while maintaining clean manager APIs.
- class mdxplain.pipeline.manager.auto_inject_proxy.AutoInjectProxy(manager: Any, pipeline_data: PipelineData)
Proxy that automatically injects PipelineData into manager methods.
This proxy analyzes method signatures to determine if a method expects PipelineData as any parameter. If so, it automatically injects the PipelineData instance at the correct position when called through the proxy.
Methods that don’t expect PipelineData are called directly without modification, allowing for both stateful pipeline operations and stateless utility functions within the same manager.
Examples
>>> from mdxplain.pipeline import PipelineManager >>> pipeline = PipelineManager() >>> >>> # Methods with pipeline_data parameter get auto-injection >>> pipeline.trajectory.load_trajectories('../data') # pipeline_data injected >>> >>> # Utility methods without pipeline_data work normally >>> valid = pipeline.trajectory.validate_selection('res CA') # no injection
- __init__(manager: Any, pipeline_data: PipelineData)
Initialize the auto-injection proxy.
Parameters
- managerobject
The manager instance to wrap with auto-injection
- pipeline_dataPipelineData
The PipelineData instance to inject into methods
Returns
- None
Initializes the proxy with manager and data references