pyrit.setup.initializers.PyRITInitializer#
- class PyRITInitializer[source]#
Bases:
ABCAbstract base class for PyRIT configuration initializers.
PyRIT initializers provide a structured way to configure default values and global settings during PyRIT initialization. They replace the need for initialization scripts with type-safe, validated, and discoverable classes.
All initializers must implement the name, description, and initialize properties/methods. The validate method can be overridden if custom validation logic is needed.
Methods
__init__()Initialize the PyRIT initializer with no parameters.
Get information about what default values and global variables this initializer sets.
get_info()Get information about this initializer class.
Execute the initialization logic.
Execute initialization while tracking what changes are made.
validate()Validate the initializer configuration before execution.
Attributes
Get a description of what this initializer configures.
Get the execution order for this initializer.
Get the human-readable name for this initializer.
Get list of required environment variables for this initializer.
- property description: str#
Get a description of what this initializer configures.
Override this property to provide a custom description. Defaults to returning the name of the initializer.
- Returns:
A description of the configuration changes this initializer makes.
- Return type:
- property execution_order: int#
Get the execution order for this initializer.
Initializers are executed in ascending order (lower numbers first). This allows control over dependency ordering - for example, basic configuration can run before more specialized setup.
- Returns:
The execution order. Defaults to 1. Lower numbers execute first.
- Return type:
Example
execution_order = 0: Very early setup (environment, logging)
execution_order = 1: Standard configuration (default)
execution_order = 2: Advanced/specialized setup
execution_order = 10: Final cleanup or overrides
- get_dynamic_default_values_info() Dict[str, Any][source]#
Get information about what default values and global variables this initializer sets. This is useful for debugging what default_values are set by an initializer.
Performs a sandbox run in isolation to discover what would be configured, then restores the original state. This works regardless of whether the initializer has been run before or which instance is queried.
- Returns:
Information about what defaults and globals are set.
- Return type:
Dict[str, Any]
- classmethod get_info() Dict[str, Any][source]#
Get information about this initializer class.
This is a class method so it can be called without instantiating the class: SimpleInitializer.get_info() instead of SimpleInitializer().get_info()
- Returns:
Dictionary containing name, description, class information, and default values.
- Return type:
Dict[str, Any]
- abstract initialize() None[source]#
Execute the initialization logic.
This method should contain all the configuration logic, including calls to set_default_value() and set_global_variable() as needed.
- initialize_with_tracking() None[source]#
Execute initialization while tracking what changes are made.
This method runs initialize() and captures information about what default values and global variables were set. The tracking information is not cached - it’s captured during the actual initialization run.
- abstract property name: str#
Get the human-readable name for this initializer.
- Returns:
A clear, descriptive name for this initializer.
- Return type:
- property required_env_vars: List[str]#
Get list of required environment variables for this initializer.
Override this property to specify which environment variables must be set for this initializer to work correctly.
- Returns:
List of required environment variable names. Defaults to empty list.
- Return type:
List[str]
- validate() None[source]#
Validate the initializer configuration before execution.
This method checks that all required environment variables are set. Subclasses should not override this method.
- Raises:
ValueError – If required environment variables are not set.