mirror of
https://github.com/romovpa/claudini.git
synced 2026-06-07 20:33:54 +02:00
5b6058b3c4
Co-Authored-By: Alexander Panfilov <sasha_pusha@mail.de> Co-Authored-By: Claude <noreply@anthropic.com>
31 lines
884 B
Python
31 lines
884 B
Python
"""Method registry: import all optimizer modules to trigger auto-registration."""
|
|
|
|
import importlib
|
|
import pkgutil
|
|
|
|
from claudini.base import TokenOptimizer
|
|
|
|
|
|
def _import_recursive(package):
|
|
"""Recursively import all submodules/subpackages to trigger registration."""
|
|
for finder, name, ispkg in pkgutil.iter_modules(package.__path__, prefix=package.__name__ + "."):
|
|
mod = importlib.import_module(name)
|
|
if ispkg:
|
|
_import_recursive(mod)
|
|
|
|
|
|
def import_all_methods():
|
|
"""Import all subpackages under the parent methods package and their submodules.
|
|
|
|
Importing triggers __init_subclass__ on TokenOptimizer subclasses, populating the registry.
|
|
"""
|
|
parent = importlib.import_module(__package__)
|
|
_import_recursive(parent)
|
|
|
|
|
|
import_all_methods()
|
|
|
|
METHODS: dict[str, type[TokenOptimizer]] = TokenOptimizer._REGISTRY
|
|
|
|
__all__ = ["METHODS"]
|