init_model
Initialization configuration module.
Initializers provide a mechanism to run code at specific points in the EleanorAI lifecycle.
Classes
InitCondition
InitializationError
Bases: Exception
Initialization error.
Raised when there is a problem executing an initialization function.
InitializerModel
Bases: BaseModel
Dynamic initialization settings for the EleanorAI Framework.
Attributes
conditions
class-attribute
instance-attribute
conditions: List[InitCondition] = Field(
default_factory=list,
title="Conditions",
description="A list of conditions that drive when initialization should be run",
)
initializer
class-attribute
instance-attribute
initializer: IoCFactoryModel = Field(
...,
title="Initializer",
description="Initializer code to run when an initialization condition condition is met",
)
max_trigger_count
class-attribute
instance-attribute
max_trigger_count: int = Field(
default=1,
title="Max Trigger Count",
description="Maximum number of times the initializer can be triggered, usually set to 1",
)
model_config
class-attribute
instance-attribute
model_config = ConfigDict(
populate_by_name=True,
use_enum_values=False,
extra="forbid",
strict=False,
)
name
class-attribute
instance-attribute
trigger_count
class-attribute
instance-attribute
trigger_count: int = Field(
default=0,
title="Trigger Count",
description="Number of times the initializer has run (volatile)",
)
Functions
attempt_run
attempt_run(condition: InitCondition) -> None
Determines if the initializer can run based on the condition.
Warning
This method relies on very specific behavior of IocFactoryModel
. When
initializer.class_name
is a function,
IocFactoryModel.ioc()
will execute the function and return the
result, often this will be a None
. If initializer.class_name
is a
class it will return an instance of the class. Both methods are valid
however the behavior is not obvious.
Parameters:
-
condition
(InitCondition
) –The condition to check against.
Returns:
-
None
–None