From: src.ce.core.dependency_injection.abstract_container
This class defines the contract for dependency injection containers that manage object instances. Implementations should provide mechanisms to register and retrieve instances based on provider keys and type constraints.
The container acts as a central registry that decouples object creation and dependencies from their usage, enabling more modular and testable code.
The instance is retrieved based on the provider key and must be a subclass of the given type.
provider_key
The key identifying the provider for the instance.
subclass_of
The class (or type) of the instance to be retrieved. The type T must be a subclass of
Providable
.
An instance of the type specified by subclass_of
.
InstanceNotFoundError
If no instance matching the provider key is found.
TypeMismatchError
If the found instance is not a subclass of the specified type.
This module defines the DIContainer
class which is the central dependency injection
container for the application. It also includes the AppModule
which configures
the core bindings for the application.
The container is responsible for: - Loading and validating the application configuration - Creating a registry of available components - Binding core services (like the ticket system client) - Providing methods to retrieve configured instances and pipelines
From: src.ce.core.dependency_injection.container
binder
The Injector binder used to configure bindings.
config
The application configuration to validate.
registry
The registry of available components.
The validator instance.
OTOBOClient
using the system configuration.config
The application configuration containing system parameters.
Configured OTOBO client.
From: src.ce.core.dependency_injection.container
This container manages the application's dependency graph using Injector. It binds core components like configuration, registry, and orchestrator, and provides methods to retrieve configured instances.
config
Validated application configuration
registry
Registry of available components
id
The unique identifier of the instance configuration to retrieve.
The configuration object for the specified instance.
KeyError
If no configuration is found for the given ID.
Looks up the configuration by ID, retrieves the corresponding class from the registry,
and creates an instance of that class. The instance must be a subclass of Providable
and of the type specified by subclass_of
.
id
Unique identifier of the instance configuration.
subclass_of
The expected base class or interface of the instance (a subclass of Providable
).
Instantiated object of the requested type.
KeyError
If configuration for the given id
is not found, or if the provider key
in the configuration is not found in the registry.
The pipeline is built from the configuration identified by predictor_id
. It consists of:
PipelineConfig
)Pipe
objects for each step in the pipeline.The pipeline itself is an instance of Pipeline
(a subclass of Pipe
), which chains the steps.
predictor_id
The unique identifier of the pipeline configuration.
The constructed pipeline instance (a Pipeline
object).
KeyError
If the configuration for predictor_id
is not found, or if the provider key
in the configuration is not found in the registry.
This function initializes a Registry
instance and registers essential classes
required for the application's dependency injection system. The registered classes
include integration adapters, data preparers, and AI inference services.
The following classes are registered:
OTOBOAdapter
: Handles integration with the OTOBO ticket system.SubjectBodyPreparer
: Prepares subject and body content for ticket processing.HFLocalAIInferenceService
: Provides local AI inference using Hugging Face models.A configured registry instance with all necessary classes registered.
From: src.ce.core.dependency_injection.registry
This registry allows classes to be registered and later retrieved by their unique keys. It enforces type checking during retrieval to ensure compatibility with expected interfaces.
_registry
list[type[Providable]]Internal list storing registered classes.
instance_classes
list[Type[Providable]]List of classes to register. Each class must implement the Providable
interface.
The class must implement the Providable
interface which requires:
get_provider_key()
method returning a unique string identifier.get_description()
method returning a descriptive string.instance_class
type[T]The class to register. Must be a subclass of Providable
.
registry_instance_key
strThe unique key identifying the class to retrieve.
instance_class
type[T]The expected class/interface type for validation.
The registered class matching the key.
KeyError
If no class is registered under the specified key.
TypeError
If the registered class is not a subclass of the expected type.
registry_instance_key
strThe key to check.
True if the key exists, False otherwise.
The output format is:
key: description
One entry per line.
Formatted string of all registered keys and descriptions, or "No registered types found." if the registry is empty.
List of all registered keys.
registry_instance_key
strThe key to look up.
The class registered under the key.
KeyError
If the key is not found in the registry.