Runner API¶
Entry points for running workloads locally and working with the plugin system.
Public surface¶
api ¶
Stable runner API surface.
Attributes¶
DEFAULT_LB_WORKDIR
module-attribute
¶
DEFAULT_LB_WORKDIR = "{{ (ansible_user == 'root') | ternary('/root', '/home/' ~ ansible_user) }}/.lb"
Classes¶
BaseCollector ¶
BaseCollector(name, interval_seconds=1.0)
Bases: ABC
Abstract base class for all metric collectors.
Initialize the base collector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the collector |
required |
interval_seconds
|
float
|
Sampling interval in seconds |
1.0
|
Source code in lb_runner/metric_collectors/_base_collector.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
Attributes¶
Functions¶
clear_data ¶
clear_data()
Clear all collected data.
Source code in lb_runner/metric_collectors/_base_collector.py
185 186 187 188 | |
get_data ¶
get_data()
Get the collected data.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of dictionaries containing metric data |
Source code in lb_runner/metric_collectors/_base_collector.py
132 133 134 135 136 137 138 139 140 | |
get_dataframe ¶
get_dataframe()
Get the collected data as a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with metrics data |
Source code in lb_runner/metric_collectors/_base_collector.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
get_errors ¶
get_errors()
Return collected metric errors, if any.
Source code in lb_runner/metric_collectors/_base_collector.py
142 143 144 | |
get_summary_stats ¶
get_summary_stats()
Get summary statistics for all numeric metrics.
Returns:
| Type | Description |
|---|---|
Dict[str, Dict[str, float]]
|
Dictionary mapping metric names to their statistics |
Source code in lb_runner/metric_collectors/_base_collector.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
save_data ¶
save_data(filepath, format='csv')
Save collected data to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Path to save the data |
required |
format
|
str
|
Format to save in ('csv', 'json', 'parquet') |
'csv'
|
Source code in lb_runner/metric_collectors/_base_collector.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
start ¶
start()
Start the metric collection in a background thread.
Source code in lb_runner/metric_collectors/_base_collector.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
stop ¶
stop()
Stop the metric collection.
Source code in lb_runner/metric_collectors/_base_collector.py
85 86 87 88 89 90 91 92 93 94 95 96 97 | |
BenchmarkConfig ¶
Bases: BaseModel
Main configuration for benchmark tests.
Attributes¶
collect_system_info
class-attribute
instance-attribute
¶
collect_system_info = Field(default=True, description='Collect system information before running benchmarks')
collectors
class-attribute
instance-attribute
¶
collectors = Field(default_factory=MetricCollectorConfig, description='Configuration for metric collectors')
cooldown_seconds
class-attribute
instance-attribute
¶
cooldown_seconds = Field(default=5, ge=0, description='Cooldown period after test finishes')
data_export_dir
class-attribute
instance-attribute
¶
data_export_dir = Field(default=Path('./data_exports'), description='Directory for raw data exports')
influxdb_bucket
class-attribute
instance-attribute
¶
influxdb_bucket = Field(default='performance', description='InfluxDB Bucket')
influxdb_enabled
class-attribute
instance-attribute
¶
influxdb_enabled = Field(default=False, description='Enable InfluxDB integration')
influxdb_org
class-attribute
instance-attribute
¶
influxdb_org = Field(default='benchmark', description='InfluxDB Organization')
influxdb_token
class-attribute
instance-attribute
¶
influxdb_token = Field(default='', description='InfluxDB API Token')
influxdb_url
class-attribute
instance-attribute
¶
influxdb_url = Field(default='http://localhost:8086', description='InfluxDB URL')
loki
class-attribute
instance-attribute
¶
loki = Field(default_factory=LokiConfig, description='Loki log shipping configuration')
metrics_interval_seconds
class-attribute
instance-attribute
¶
metrics_interval_seconds = Field(default=1.0, gt=0, description='Interval for metric collection in seconds')
output_dir
class-attribute
instance-attribute
¶
output_dir = Field(default=Path('./benchmark_results'), description='Root directory for all benchmark output')
plugin_assets
class-attribute
instance-attribute
¶
plugin_assets = Field(default_factory=dict, description='Resolved plugin Ansible assets/extravars (from runner registry)')
plugin_settings
class-attribute
instance-attribute
¶
plugin_settings = Field(default_factory=dict, description='Dictionary of plugin-specific Pydantic config models')
remote_execution
class-attribute
instance-attribute
¶
remote_execution = Field(default_factory=RemoteExecutionConfig, description='Configuration for remote execution')
remote_hosts
class-attribute
instance-attribute
¶
remote_hosts = Field(default_factory=list, description='List of remote hosts for benchmarking')
repetitions
class-attribute
instance-attribute
¶
repetitions = Field(default=3, gt=0, description='Number of repetitions for each test')
report_dir
class-attribute
instance-attribute
¶
report_dir = Field(default=Path('./reports'), description='Directory for generated reports')
test_duration_seconds
class-attribute
instance-attribute
¶
test_duration_seconds = Field(default=3600, gt=0, description='Default duration for tests in seconds')
warmup_seconds
class-attribute
instance-attribute
¶
warmup_seconds = Field(default=5, ge=0, description='Warmup period before metric collection starts')
workloads
class-attribute
instance-attribute
¶
workloads = Field(default_factory=dict, description='Dictionary of workload definitions')
Functions¶
ensure_output_dirs ¶
ensure_output_dirs()
Ensures all configured output directories exist.
Source code in lb_runner/models/config.py
311 312 313 314 | |
from_dict
classmethod
¶
from_dict(data)
Source code in lb_runner/models/config.py
334 335 336 337 338 | |
from_json
classmethod
¶
from_json(json_str)
Source code in lb_runner/models/config.py
329 330 331 332 | |
load
classmethod
¶
load(filepath)
Source code in lb_runner/models/config.py
343 344 345 | |
save ¶
save(filepath)
Source code in lb_runner/models/config.py
340 341 | |
GrafanaPlatformConfig ¶
Bases: BaseModel
Platform-level Grafana connection settings.
Attributes¶
api_key
class-attribute
instance-attribute
¶
api_key = Field(default=None, description='Grafana API key (optional)')
org_id
class-attribute
instance-attribute
¶
org_id = Field(default=1, ge=1, description='Grafana organization id')
url
class-attribute
instance-attribute
¶
url = Field(default='http://localhost:3000', description='Grafana base URL')
LBEventLogHandler ¶
LBEventLogHandler(run_id, host, workload, repetition, total_repetitions)
Bases: Handler
Logging handler that emits logs as structured LB_EVENT JSON lines to stdout, allowing the controller to capture and stream them.
Source code in lb_runner/services/log_handler.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
Attributes¶
Functions¶
emit ¶
emit(record)
Source code in lb_runner/services/log_handler.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
LocalRunner ¶
LocalRunner(config, registry, progress_callback=None, host_name=None, stop_token=None, collector_registry=None)
Local agent for executing benchmarks on a single node.
Initialize the local runner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BenchmarkConfig
|
Benchmark configuration |
required |
Source code in lb_runner/engine/runner.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
Attributes¶
plugin_registry
instance-attribute
¶
plugin_registry = _resolve_registry(registry, collector_registry)
Functions¶
collect_system_info ¶
collect_system_info()
Collect detailed information about the system.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing system information |
Source code in lb_runner/engine/runner.py
110 111 112 113 114 115 116 117 | |
run_all_benchmarks ¶
run_all_benchmarks()
Run all configured benchmark tests.
Source code in lb_runner/engine/runner.py
306 307 308 309 310 311 312 313 314 315 316 | |
run_benchmark ¶
run_benchmark(test_type, repetition_override=None, total_repetitions=None, run_id=None, pending_reps=None)
Run a complete benchmark test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_type
|
str
|
Name of the workload to run (plugin id) |
required |
repetition_override
|
int | None
|
When set, run only this repetition index. |
None
|
total_repetitions
|
int | None
|
Total repetitions planned (for display purposes). |
None
|
Source code in lb_runner/engine/runner.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
LokiConfig ¶
Bases: BaseModel
Configuration for Loki log shipping.
Attributes¶
backoff_base
class-attribute
instance-attribute
¶
backoff_base = Field(default=0.5, ge=0, description='Base backoff delay in seconds')
backoff_factor
class-attribute
instance-attribute
¶
backoff_factor = Field(default=2.0, ge=1.0, description='Backoff multiplier')
batch_size
class-attribute
instance-attribute
¶
batch_size = Field(default=100, gt=0, description='Logs per batch')
enabled
class-attribute
instance-attribute
¶
enabled = Field(default=False, description='Enable Loki log push')
endpoint
class-attribute
instance-attribute
¶
endpoint = Field(default='http://localhost:3100', description='Loki base URL or push endpoint')
flush_interval_ms
class-attribute
instance-attribute
¶
flush_interval_ms = Field(default=1000, gt=0, description='Flush interval in milliseconds')
labels
class-attribute
instance-attribute
¶
labels = Field(default_factory=dict, description='Static labels sent with Loki logs')
max_queue_size
class-attribute
instance-attribute
¶
max_queue_size = Field(default=10000, gt=0, description='Max pending logs in queue')
max_retries
class-attribute
instance-attribute
¶
max_retries = Field(default=3, ge=0, description='Max retries on failure')
timeout_seconds
class-attribute
instance-attribute
¶
timeout_seconds = Field(default=5.0, gt=0, description='HTTP timeout for Loki push')
MetricCollectorConfig ¶
Bases: BaseModel
Configuration for metric collectors.
Attributes¶
cli_commands
class-attribute
instance-attribute
¶
cli_commands = Field(default_factory=lambda: ['sar -u 1 1', 'vmstat 1 1', 'iostat -d 1 1', 'mpstat 1 1', 'pidstat -h 1 1'], description='List of CLI commands to execute for metric collection')
enable_ebpf
class-attribute
instance-attribute
¶
enable_ebpf = Field(default=False, description='Enable eBPF-based metric collection')
perf_config
class-attribute
instance-attribute
¶
perf_config = Field(default_factory=PerfConfig, description='Configuration for perf profiling')
psutil_interval
class-attribute
instance-attribute
¶
psutil_interval = Field(default=1.0, gt=0, description='Interval for psutil collector in seconds')
PerfConfig ¶
Bases: BaseModel
Configuration for perf profiling.
Attributes¶
cpu
class-attribute
instance-attribute
¶
cpu = Field(default=None, ge=0, description='CPU to profile')
events
class-attribute
instance-attribute
¶
events = Field(default_factory=lambda: ['cpu-cycles', 'instructions', 'cache-references', 'cache-misses', 'branches', 'branch-misses'], description='List of perf events to monitor')
interval_ms
class-attribute
instance-attribute
¶
interval_ms = Field(default=1000, gt=0, description='Sampling interval in milliseconds')
pid
class-attribute
instance-attribute
¶
pid = Field(default=None, gt=0, description='Process ID to profile')
PlatformConfig ¶
Bases: BaseModel
Platform-level configuration for defaults and plugin enablement.
Attributes¶
data_export_dir
class-attribute
instance-attribute
¶
data_export_dir = Field(default=None, description='Default data export directory')
grafana
class-attribute
instance-attribute
¶
grafana = Field(default=None, description='Optional Grafana defaults for the platform')
loki
class-attribute
instance-attribute
¶
loki = Field(default=None, description='Optional Loki defaults for the platform')
output_dir
class-attribute
instance-attribute
¶
output_dir = Field(default=None, description='Default benchmark output directory')
plugins
class-attribute
instance-attribute
¶
plugins = Field(default_factory=dict, description='Plugin enable/disable map (missing entries default to enabled)')
report_dir
class-attribute
instance-attribute
¶
report_dir = Field(default=None, description='Default report directory')
Functions¶
is_plugin_enabled ¶
is_plugin_enabled(name)
Return True when the plugin is enabled or not explicitly disabled.
Source code in lb_runner/models/config.py
376 377 378 | |
load
classmethod
¶
load(filepath)
Source code in lb_runner/models/config.py
383 384 385 | |
save ¶
save(filepath)
Source code in lb_runner/models/config.py
380 381 | |
RemoteExecutionConfig ¶
Bases: BaseModel
Configuration for remote execution via Ansible.
Attributes¶
collect_playbook
class-attribute
instance-attribute
¶
collect_playbook = Field(default=None, description='Path to the Ansible collect playbook')
enabled
class-attribute
instance-attribute
¶
enabled = Field(default=False, description='Enable remote execution')
inventory_path
class-attribute
instance-attribute
¶
inventory_path = Field(default=None, description='Path to a custom Ansible inventory file')
lb_workdir
class-attribute
instance-attribute
¶
lb_workdir = Field(default=DEFAULT_LB_WORKDIR, description='Remote workdir for benchmark install (Ansible-templated)')
run_collect
class-attribute
instance-attribute
¶
run_collect = Field(default=True, description='Execute collection playbooks after tests')
run_playbook
class-attribute
instance-attribute
¶
run_playbook = Field(default=None, description='Path to the Ansible run playbook')
run_setup
class-attribute
instance-attribute
¶
run_setup = Field(default=True, description='Execute setup playbooks before tests')
run_teardown
class-attribute
instance-attribute
¶
run_teardown = Field(default=True, description='Execute teardown playbooks after tests')
setup_playbook
class-attribute
instance-attribute
¶
setup_playbook = Field(default=None, description='Path to the Ansible setup playbook')
teardown_playbook
class-attribute
instance-attribute
¶
teardown_playbook = Field(default=None, description='Path to the Ansible teardown playbook')
upgrade_pip
class-attribute
instance-attribute
¶
upgrade_pip = Field(default=False, description='Upgrade pip inside the benchmark virtual environment during setup')
use_container_fallback
class-attribute
instance-attribute
¶
use_container_fallback = Field(default=False, description='Use container-based fallback for remote execution')
RemoteHostConfig ¶
Bases: BaseModel
Configuration for a remote benchmark host.
Attributes¶
address
class-attribute
instance-attribute
¶
address = Field(description='IP address or hostname of the remote host')
become
class-attribute
instance-attribute
¶
become = Field(default=True, description='Use Ansible become (sudo) for escalated privileges')
become_method
class-attribute
instance-attribute
¶
become_method = Field(default='sudo', description='Ansible become method')
name
class-attribute
instance-attribute
¶
name = Field(description='Unique name for the remote host')
port
class-attribute
instance-attribute
¶
port = Field(default=22, gt=0, description='SSH port for connection')
user
class-attribute
instance-attribute
¶
user = Field(default='root', description='SSH user for connection')
vars
class-attribute
instance-attribute
¶
vars = Field(default_factory=dict, description='Additional Ansible variables for this host')
Functions¶
ansible_host_line ¶
ansible_host_line()
Render an INI-style inventory line for this host (compat helper).
Source code in lb_runner/models/config.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
validate_name_not_empty ¶
validate_name_not_empty()
Source code in lb_runner/models/config.py
137 138 139 140 141 | |
RunEvent
dataclass
¶
RunEvent(run_id, host, workload, repetition, total_repetitions, status, message='', timestamp=0.0, type='status', level='INFO', error_type=None, error_context=None)
A structured event emitted during a run.
RunnerRegistry ¶
RunnerRegistry(workloads, collectors)
Adapter that exposes workload and collector helpers on a single object.
Source code in lb_runner/registry.py
15 16 17 18 19 20 21 | |
Functions¶
available ¶
available(load_entrypoints=False)
Source code in lb_runner/registry.py
26 27 | |
available_collectors ¶
available_collectors(load_entrypoints=False)
Source code in lb_runner/registry.py
37 38 39 40 | |
create_collectors ¶
create_collectors(config)
Source code in lb_runner/registry.py
34 35 | |
create_generator ¶
create_generator(plugin_name, options=None)
Source code in lb_runner/registry.py
29 30 31 32 | |
get ¶
get(name)
Source code in lb_runner/registry.py
23 24 | |
StdoutEmitter ¶
StopToken ¶
StopToken(stop_file=None, enable_signals=True, on_stop=None)
Lightweight cooperative stop controller.
It can be tripped by signals (SIGINT/SIGTERM) or by the presence of a stop
file on disk. Consumers should call should_stop() in long-running loops
and abort work when True.
Source code in lb_runner/engine/stop_token.py
19 20 21 22 23 24 25 26 27 28 29 30 | |
Attributes¶
Functions¶
request_stop ¶
request_stop()
Mark the token as stopped and trigger callback once.
Source code in lb_runner/engine/stop_token.py
58 59 60 61 62 63 64 65 66 67 | |
restore ¶
restore()
Restore original signal handlers.
Source code in lb_runner/engine/stop_token.py
83 84 85 86 87 88 89 90 | |
should_stop ¶
should_stop()
Return True when stop was requested or the stop file exists.
Source code in lb_runner/engine/stop_token.py
69 70 71 72 73 74 75 76 77 78 79 80 81 | |
WorkloadConfig ¶
Bases: BaseModel
Configuration wrapper for workload plugins.
Attributes¶
collectors_enabled
class-attribute
instance-attribute
¶
collectors_enabled = Field(default=True, description='Enable metric collectors for this workload')
enabled
class-attribute
instance-attribute
¶
enabled = Field(default=True, description='Whether this workload is enabled')
intensity
class-attribute
instance-attribute
¶
intensity = Field(default='user_defined', description='Pre-defined intensity level (low, medium, high, user_defined)')
options
class-attribute
instance-attribute
¶
options = Field(default_factory=dict, description='Plugin-specific options for the workload')
Functions¶
aggregate_cli ¶
aggregate_cli(df)
Aggregate metrics collected by CLICollector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame | None
|
DataFrame with CLI metrics |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dictionary of aggregated metrics. |
Source code in lb_runner/metric_collectors/aggregators.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
collect_metrics ¶
collect_metrics(collectors, workload_dir, rep_dir, test_name, repetition, result)
Source code in lb_runner/services/results.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
ensure_run_dirs ¶
ensure_run_dirs(config, run_id)
Create required local output directories for a run.
Source code in lb_runner/services/storage.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
workload_output_dir ¶
workload_output_dir(output_root, workload, ensure=False)
Return the output directory dedicated to a workload inside a run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_root
|
Path
|
Base output directory for the run (already scoped by run_id/host). |
required |
workload
|
str
|
Workload/plugin identifier. |
required |
ensure
|
bool
|
When True, create the directory. |
False
|
Source code in lb_runner/services/storage.py
41 42 43 44 45 46 47 48 49 50 51 52 53 | |
write_outputs ¶
write_outputs(info, json_path, csv_path)
Persist collected info to JSON/CSV if paths are provided.
Source code in lb_runner/services/system_info_io.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
Local runner¶
LocalRunner ¶
LocalRunner(config, registry, progress_callback=None, host_name=None, stop_token=None, collector_registry=None)
Local agent for executing benchmarks on a single node.
Initialize the local runner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BenchmarkConfig
|
Benchmark configuration |
required |
Source code in lb_runner/engine/runner.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
Attributes¶
plugin_registry
instance-attribute
¶
plugin_registry = _resolve_registry(registry, collector_registry)
Functions¶
collect_system_info ¶
collect_system_info()
Collect detailed information about the system.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing system information |
Source code in lb_runner/engine/runner.py
110 111 112 113 114 115 116 117 | |
run_all_benchmarks ¶
run_all_benchmarks()
Run all configured benchmark tests.
Source code in lb_runner/engine/runner.py
306 307 308 309 310 311 312 313 314 315 316 | |
run_benchmark ¶
run_benchmark(test_type, repetition_override=None, total_repetitions=None, run_id=None, pending_reps=None)
Run a complete benchmark test.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
test_type
|
str
|
Name of the workload to run (plugin id) |
required |
repetition_override
|
int | None
|
When set, run only this repetition index. |
None
|
total_repetitions
|
int | None
|
Total repetitions planned (for display purposes). |
None
|
Source code in lb_runner/engine/runner.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
Plugin registry¶
PluginRegistry ¶
PluginRegistry(plugins=None)
In-memory registry for built-in, entry-point, and user plugins.
Source code in lb_plugins/registry.py
23 24 25 26 27 28 29 30 | |
Functions¶
available ¶
available(load_entrypoints=False)
Return available workload plugins.
When load_entrypoints is True, pending entry-point plugins are resolved and registered; otherwise only already-registered plugins are returned.
Source code in lb_plugins/registry.py
71 72 73 74 75 76 77 78 79 80 | |
create_generator ¶
create_generator(plugin_name, options=None)
Source code in lb_plugins/registry.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
get ¶
get(name)
Source code in lb_plugins/registry.py
44 45 46 47 48 49 | |
register ¶
register(plugin)
Register a new plugin.
Source code in lb_plugins/registry.py
32 33 34 35 36 37 38 39 40 41 42 | |
Plugin interface¶
WorkloadPlugin ¶
Bases: ABC
Abstract base class for all workload plugins.
A plugin encapsulates the logic for: 1. Configuration (schema) 2. Execution (Generator creation) 3. Metadata (Name, description) 4. Assets (Ansible playbooks)
Attributes¶
config_cls
abstractmethod
property
¶
config_cls
The Pydantic model used for configuration. The app config service uses this to deserialize raw JSON.
Functions¶
create_generator
abstractmethod
¶
create_generator(config)
Create a new instance of the workload generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BasePluginConfig
|
An instance of self.config_cls |
required |
Source code in lb_plugins/interface.py
74 75 76 77 78 79 80 81 82 | |
export_results_to_csv ¶
export_results_to_csv(results, output_dir, run_id, test_name)
Normalize plugin-specific results into CSV files stored in output_dir.
Default implementation flattens generator_result and metadata into a single CSV. Plugins with richer report formats can override to write multiple CSVs.
Source code in lb_plugins/interface.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
get_ansible_collect_post_extravars ¶
get_ansible_collect_post_extravars()
Return extra vars merged into the plugin collect post-playbook run.
Source code in lb_plugins/interface.py
189 190 191 | |
get_ansible_collect_post_path ¶
get_ansible_collect_post_path()
Return the path to the Ansible collect post-playbook. Executed after the collect phase for plugin-specific log collection.
Source code in lb_plugins/interface.py
178 179 180 181 182 183 | |
get_ansible_collect_pre_extravars ¶
get_ansible_collect_pre_extravars()
Return extra vars merged into the plugin collect pre-playbook run.
Source code in lb_plugins/interface.py
185 186 187 | |
get_ansible_collect_pre_path ¶
get_ansible_collect_pre_path()
Return the path to the Ansible collect pre-playbook. Executed before the collect phase (e.g., to add dynamic hosts to inventory).
Source code in lb_plugins/interface.py
171 172 173 174 175 176 | |
get_ansible_setup_extravars ¶
get_ansible_setup_extravars()
Return extra vars merged into the plugin setup playbook run.
Source code in lb_plugins/interface.py
163 164 165 | |
get_ansible_setup_path ¶
get_ansible_setup_path()
Return the path to the Ansible setup playbook. Executed before the workload runs on remote hosts.
Source code in lb_plugins/interface.py
149 150 151 152 153 154 | |
get_ansible_teardown_extravars ¶
get_ansible_teardown_extravars()
Return extra vars merged into the plugin teardown playbook run.
Source code in lb_plugins/interface.py
167 168 169 | |
get_ansible_teardown_path ¶
get_ansible_teardown_path()
Return the path to the Ansible teardown playbook. Executed after the workload runs (even on failure) on remote hosts.
Source code in lb_plugins/interface.py
156 157 158 159 160 161 | |
get_grafana_assets ¶
get_grafana_assets()
Return Grafana datasources/dashboards provided by this plugin.
Source code in lb_plugins/interface.py
193 194 195 | |
get_preset_config ¶
get_preset_config(level)
Return a configuration object for the specified intensity level. If USER_DEFINED or not implemented, return None.
Source code in lb_plugins/interface.py
123 124 125 126 127 128 | |
get_required_apt_packages ¶
get_required_apt_packages()
Return list of APT packages required by this plugin.
Source code in lb_plugins/interface.py
130 131 132 | |
get_required_local_tools ¶
get_required_local_tools()
Return list of command-line tools required by this plugin for local execution.
Used by lb doctor to verify the local environment.
Source code in lb_plugins/interface.py
142 143 144 145 146 147 | |
get_required_pip_packages ¶
get_required_pip_packages()
Return list of Python packages required by this plugin.
Source code in lb_plugins/interface.py
134 135 136 | |
get_required_uv_extras ¶
get_required_uv_extras()
Return list of UV extras required by this plugin.
Source code in lb_plugins/interface.py
138 139 140 | |
load_config_from_file ¶
load_config_from_file(config_file_path)
Loads and validates plugin configuration from a YAML file.
The method merges common configuration (from the 'common' section)
with plugin-specific configuration (from the 'plugins.self.config_cls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file_path
|
Path
|
The path to the YAML configuration file. |
required |
Returns:
| Type | Description |
|---|---|
BasePluginConfig
|
An instance of |
BasePluginConfig
|
configuration. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the config_file_path does not exist. |
YAMLError
|
If the file content is not valid YAML. |
ValidationError
|
If the merged configuration does not conform to
|
Source code in lb_plugins/interface.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
BasePluginConfig ¶
Bases: BaseModel
Base model for common plugin configuration fields.
Attributes¶
max_retries
class-attribute
instance-attribute
¶
max_retries = Field(default=0, ge=0, description='Maximum number of retries for the workload')
tags
class-attribute
instance-attribute
¶
tags = Field(default_factory=list, description='Tags associated with the workload')
timeout_buffer
class-attribute
instance-attribute
¶
timeout_buffer = Field(default=10, description='Safety buffer in seconds added to expected runtime')
SimpleWorkloadPlugin ¶
Bases: WorkloadPlugin
Lightweight plugin base that relies on class attributes.
Attributes¶
Functions¶
create_generator ¶
create_generator(config)
Source code in lb_plugins/interface.py
278 279 280 281 | |
get_ansible_collect_post_path ¶
get_ansible_collect_post_path()
Source code in lb_plugins/interface.py
313 314 315 316 | |
get_ansible_collect_pre_path ¶
get_ansible_collect_pre_path()
Source code in lb_plugins/interface.py
308 309 310 311 | |
get_ansible_setup_path ¶
get_ansible_setup_path()
Source code in lb_plugins/interface.py
298 299 300 301 | |
get_ansible_teardown_path ¶
get_ansible_teardown_path()
Source code in lb_plugins/interface.py
303 304 305 306 | |
get_grafana_assets ¶
get_grafana_assets()
Source code in lb_plugins/interface.py
283 284 | |
get_required_apt_packages ¶
get_required_apt_packages()
Source code in lb_plugins/interface.py
286 287 | |
get_required_local_tools ¶
get_required_local_tools()
Source code in lb_plugins/interface.py
295 296 | |
get_required_pip_packages ¶
get_required_pip_packages()
Source code in lb_plugins/interface.py
289 290 | |
get_required_uv_extras ¶
get_required_uv_extras()
Source code in lb_plugins/interface.py
292 293 | |
WorkloadIntensity ¶
Plugin assets¶
PluginAssetConfig ¶
Bases: BaseModel
Ansible assets and extravars resolved from a workload plugin.
Attributes¶
collect_post_extravars
class-attribute
instance-attribute
¶
collect_post_extravars = Field(default_factory=dict, description='Collect post extravars')
collect_post_playbook
class-attribute
instance-attribute
¶
collect_post_playbook = Field(default=None, description='Plugin collect post-playbook path')
collect_pre_extravars
class-attribute
instance-attribute
¶
collect_pre_extravars = Field(default_factory=dict, description='Collect pre extravars')
collect_pre_playbook
class-attribute
instance-attribute
¶
collect_pre_playbook = Field(default=None, description='Plugin collect pre-playbook path')
required_uv_extras
class-attribute
instance-attribute
¶
required_uv_extras = Field(default_factory=list, description='UV extras required by plugin runtime')
setup_extravars
class-attribute
instance-attribute
¶
setup_extravars = Field(default_factory=dict, description='Setup extravars')
setup_playbook
class-attribute
instance-attribute
¶
setup_playbook = Field(default=None, description='Plugin setup playbook path')
teardown_extravars
class-attribute
instance-attribute
¶
teardown_extravars = Field(default_factory=dict, description='Teardown extravars')
teardown_playbook
class-attribute
instance-attribute
¶
teardown_playbook = Field(default=None, description='Plugin teardown playbook path')
Configuration models¶
BenchmarkConfig ¶
Bases: BaseModel
Main configuration for benchmark tests.
Attributes¶
collect_system_info
class-attribute
instance-attribute
¶
collect_system_info = Field(default=True, description='Collect system information before running benchmarks')
collectors
class-attribute
instance-attribute
¶
collectors = Field(default_factory=MetricCollectorConfig, description='Configuration for metric collectors')
cooldown_seconds
class-attribute
instance-attribute
¶
cooldown_seconds = Field(default=5, ge=0, description='Cooldown period after test finishes')
data_export_dir
class-attribute
instance-attribute
¶
data_export_dir = Field(default=Path('./data_exports'), description='Directory for raw data exports')
influxdb_bucket
class-attribute
instance-attribute
¶
influxdb_bucket = Field(default='performance', description='InfluxDB Bucket')
influxdb_enabled
class-attribute
instance-attribute
¶
influxdb_enabled = Field(default=False, description='Enable InfluxDB integration')
influxdb_org
class-attribute
instance-attribute
¶
influxdb_org = Field(default='benchmark', description='InfluxDB Organization')
influxdb_token
class-attribute
instance-attribute
¶
influxdb_token = Field(default='', description='InfluxDB API Token')
influxdb_url
class-attribute
instance-attribute
¶
influxdb_url = Field(default='http://localhost:8086', description='InfluxDB URL')
loki
class-attribute
instance-attribute
¶
loki = Field(default_factory=LokiConfig, description='Loki log shipping configuration')
metrics_interval_seconds
class-attribute
instance-attribute
¶
metrics_interval_seconds = Field(default=1.0, gt=0, description='Interval for metric collection in seconds')
output_dir
class-attribute
instance-attribute
¶
output_dir = Field(default=Path('./benchmark_results'), description='Root directory for all benchmark output')
plugin_assets
class-attribute
instance-attribute
¶
plugin_assets = Field(default_factory=dict, description='Resolved plugin Ansible assets/extravars (from runner registry)')
plugin_settings
class-attribute
instance-attribute
¶
plugin_settings = Field(default_factory=dict, description='Dictionary of plugin-specific Pydantic config models')
remote_execution
class-attribute
instance-attribute
¶
remote_execution = Field(default_factory=RemoteExecutionConfig, description='Configuration for remote execution')
remote_hosts
class-attribute
instance-attribute
¶
remote_hosts = Field(default_factory=list, description='List of remote hosts for benchmarking')
repetitions
class-attribute
instance-attribute
¶
repetitions = Field(default=3, gt=0, description='Number of repetitions for each test')
report_dir
class-attribute
instance-attribute
¶
report_dir = Field(default=Path('./reports'), description='Directory for generated reports')
test_duration_seconds
class-attribute
instance-attribute
¶
test_duration_seconds = Field(default=3600, gt=0, description='Default duration for tests in seconds')
warmup_seconds
class-attribute
instance-attribute
¶
warmup_seconds = Field(default=5, ge=0, description='Warmup period before metric collection starts')
workloads
class-attribute
instance-attribute
¶
workloads = Field(default_factory=dict, description='Dictionary of workload definitions')
Functions¶
ensure_output_dirs ¶
ensure_output_dirs()
Ensures all configured output directories exist.
Source code in lb_runner/models/config.py
311 312 313 314 | |
from_dict
classmethod
¶
from_dict(data)
Source code in lb_runner/models/config.py
334 335 336 337 338 | |
from_json
classmethod
¶
from_json(json_str)
Source code in lb_runner/models/config.py
329 330 331 332 | |
load
classmethod
¶
load(filepath)
Source code in lb_runner/models/config.py
343 344 345 | |
save ¶
save(filepath)
Source code in lb_runner/models/config.py
340 341 | |
WorkloadConfig ¶
Bases: BaseModel
Configuration wrapper for workload plugins.
Attributes¶
collectors_enabled
class-attribute
instance-attribute
¶
collectors_enabled = Field(default=True, description='Enable metric collectors for this workload')
enabled
class-attribute
instance-attribute
¶
enabled = Field(default=True, description='Whether this workload is enabled')
intensity
class-attribute
instance-attribute
¶
intensity = Field(default='user_defined', description='Pre-defined intensity level (low, medium, high, user_defined)')
options
class-attribute
instance-attribute
¶
options = Field(default_factory=dict, description='Plugin-specific options for the workload')
RemoteExecutionConfig ¶
Bases: BaseModel
Configuration for remote execution via Ansible.
Attributes¶
collect_playbook
class-attribute
instance-attribute
¶
collect_playbook = Field(default=None, description='Path to the Ansible collect playbook')
enabled
class-attribute
instance-attribute
¶
enabled = Field(default=False, description='Enable remote execution')
inventory_path
class-attribute
instance-attribute
¶
inventory_path = Field(default=None, description='Path to a custom Ansible inventory file')
lb_workdir
class-attribute
instance-attribute
¶
lb_workdir = Field(default=DEFAULT_LB_WORKDIR, description='Remote workdir for benchmark install (Ansible-templated)')
run_collect
class-attribute
instance-attribute
¶
run_collect = Field(default=True, description='Execute collection playbooks after tests')
run_playbook
class-attribute
instance-attribute
¶
run_playbook = Field(default=None, description='Path to the Ansible run playbook')
run_setup
class-attribute
instance-attribute
¶
run_setup = Field(default=True, description='Execute setup playbooks before tests')
run_teardown
class-attribute
instance-attribute
¶
run_teardown = Field(default=True, description='Execute teardown playbooks after tests')
setup_playbook
class-attribute
instance-attribute
¶
setup_playbook = Field(default=None, description='Path to the Ansible setup playbook')
teardown_playbook
class-attribute
instance-attribute
¶
teardown_playbook = Field(default=None, description='Path to the Ansible teardown playbook')
upgrade_pip
class-attribute
instance-attribute
¶
upgrade_pip = Field(default=False, description='Upgrade pip inside the benchmark virtual environment during setup')
use_container_fallback
class-attribute
instance-attribute
¶
use_container_fallback = Field(default=False, description='Use container-based fallback for remote execution')
RemoteHostConfig ¶
Bases: BaseModel
Configuration for a remote benchmark host.
Attributes¶
address
class-attribute
instance-attribute
¶
address = Field(description='IP address or hostname of the remote host')
become
class-attribute
instance-attribute
¶
become = Field(default=True, description='Use Ansible become (sudo) for escalated privileges')
become_method
class-attribute
instance-attribute
¶
become_method = Field(default='sudo', description='Ansible become method')
name
class-attribute
instance-attribute
¶
name = Field(description='Unique name for the remote host')
port
class-attribute
instance-attribute
¶
port = Field(default=22, gt=0, description='SSH port for connection')
user
class-attribute
instance-attribute
¶
user = Field(default='root', description='SSH user for connection')
vars
class-attribute
instance-attribute
¶
vars = Field(default_factory=dict, description='Additional Ansible variables for this host')
Functions¶
ansible_host_line ¶
ansible_host_line()
Render an INI-style inventory line for this host (compat helper).
Source code in lb_runner/models/config.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
validate_name_not_empty ¶
validate_name_not_empty()
Source code in lb_runner/models/config.py
137 138 139 140 141 | |