Testing
pamiq_core.testing.connect_components ¶
connect_components(
agent: Agent[Any, Any] | None = None,
trainers: Trainer | Mapping[str, Trainer] | None = None,
buffers: Mapping[str, DataBuffer[Any]] | None = None,
models: Mapping[str, TrainingModel[Any]] | None = None,
) -> ConnectedComponents
Connect PAMIQ Core components for testing or development.
This function wires together the core components (agent, trainers, buffers, models) by establishing the appropriate connection relationships between them. It handles the creation of data users from buffers, extraction of inference models from training models, and proper attachment of all related components.
PARAMETER | DESCRIPTION |
---|---|
agent
|
Optional agent to connect with models and data collectors
TYPE:
|
trainers
|
Optional trainer or mapping of trainers to connect with models and data |
buffers
|
Optional mapping of data buffers to create data users from
TYPE:
|
models
|
Optional mapping of training models to connect with trainers and agent
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ConnectedComponents
|
ConnectedComponents containing the connected component dictionaries |
Source code in src/pamiq_core/testing.py
pamiq_core.testing.ConnectedComponents ¶
Bases: NamedTuple
Container for connected PAMIQ components.
ATTRIBUTE | DESCRIPTION |
---|---|
data_users |
Dictionary of data users created from buffers
TYPE:
|
data_collectors |
Dictionary of data collectors associated with data users
TYPE:
|
training_models |
Dictionary of training models
TYPE:
|
inference_models |
Dictionary of inference models derived from training models
TYPE:
|
pamiq_core.testing.create_mock_models ¶
create_mock_models(
has_inference_model: bool = True, inference_thread_only: bool = False
) -> tuple[Mock, Mock]
Create mock training and inference models for testing.
Creates mocked instances of TrainingModel and InferenceModel with the specified configuration, properly connecting them when has_inference_model is True.
PARAMETER | DESCRIPTION |
---|---|
has_inference_model
|
Whether the training model should have an inference model
TYPE:
|
inference_thread_only
|
Whether the model is for inference thread only
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple[Mock, Mock]
|
A tuple containing (training_model, inference_model) mocks |
Source code in src/pamiq_core/testing.py
pamiq_core.testing.create_mock_buffer ¶
Create a mock data buffer for testing.
Creates a MagicMock instance that mocks a DataBuffer with the specified max_size parameter. This is useful for testing components that depend on DataBuffer without implementing a full buffer.
PARAMETER | DESCRIPTION |
---|---|
max_size
|
Maximum size of the buffer. Defaults to 1.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
MagicMock
|
A MagicMock object that mocks a DataBuffer. |