data_merger
Pure functions for merging model reference data with Horde runtime data.
This module provides utilities to combine static model reference data with dynamic runtime data from the AI Horde API (status, statistics, workers).
WorkerSummary
Bases: BaseModel
Summary of a worker serving a model.
Source code in src/horde_model_reference/integrations/data_merger.py
performance
class-attribute
instance-attribute
online
class-attribute
instance-attribute
trusted
class-attribute
instance-attribute
UsageStats
Bases: BaseModel
Usage statistics for a specific model.
Source code in src/horde_model_reference/integrations/data_merger.py
month
class-attribute
instance-attribute
CombinedModelStatistics
Bases: BaseModel
Horde usage statistics and data for a model, aggregated from multiple sources.
Source code in src/horde_model_reference/integrations/data_merger.py
worker_count
property
Number of workers serving this model.
Returns worker count from detailed worker_summaries if available (including empty dict = 0 workers). Falls back to worker_count_from_status if worker_summaries is None (detailed info not fetched). Returns 0 if neither is available.
queued_jobs
class-attribute
instance-attribute
performance
class-attribute
instance-attribute
eta
class-attribute
instance-attribute
queued
class-attribute
instance-attribute
usage_stats
class-attribute
instance-attribute
worker_summaries
class-attribute
instance-attribute
worker_summaries: dict[str, WorkerSummary] | None = Field(
default=None, description="Workers serving this model"
)
PopularModelResult
Bases: BaseModel
A model paired with its live Horde usage/popularity stats.
Source code in src/horde_model_reference/integrations/data_merger.py
record
class-attribute
instance-attribute
merge_model_with_horde_data
merge_model_with_horde_data(
model_name: str,
horde_status: list[HordeModelStatus]
| IndexedHordeModelStatus,
horde_stats: HordeModelStatsResponse
| IndexedHordeModelStats,
workers: list[HordeWorker]
| IndexedHordeWorkers
| None = None,
include_backend_variations: bool = False,
) -> CombinedModelStatistics
Merge a single model reference with Horde runtime data.
Optimization: Pass IndexedHordeModelStatus, IndexedHordeModelStats, and IndexedHordeWorkers instead of raw lists to skip the indexing overhead. This is especially beneficial when merging multiple models sequentially.
Parameters:
-
model_name(str) –The model name to look up in Horde data.
-
horde_status(list[HordeModelStatus] | IndexedHordeModelStatus) –Model status from Horde API (list or indexed).
-
horde_stats(HordeModelStatsResponse | IndexedHordeModelStats) –Model statistics from Horde API (response or indexed).
-
workers(list[HordeWorker] | IndexedHordeWorkers | None, default:None) –Optional workers from Horde API (list or indexed).
-
include_backend_variations(bool, default:False) –If True, include per-backend statistics for text models.
Returns:
-
CombinedModelStatistics–CombinedModelStatistics with runtime fields: - worker_count: Number of workers serving this model (computed field) - queued_jobs: Number of active jobs - performance: Performance metric - eta: Estimated time to completion in seconds - queued: Number of queued requests - usage_stats: UsageStats with {day, month, total} usage counts - worker_summaries: Dict of worker_id -> WorkerSummary (if workers provided) - backend_variations: Dict of backend_name -> BackendVariation (if include_backend_variations=True)
Source code in src/horde_model_reference/integrations/data_merger.py
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 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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
merge_category_with_horde_data
merge_category_with_horde_data(
model_names: Iterable[str],
horde_status: list[HordeModelStatus]
| IndexedHordeModelStatus,
horde_stats: HordeModelStatsResponse
| IndexedHordeModelStats,
workers: list[HordeWorker]
| IndexedHordeWorkers
| None = None,
include_backend_variations: bool = False,
) -> dict[str, CombinedModelStatistics]
Merge all models in a category with Horde runtime data.
Optimization: Pass IndexedHordeModelStatus, IndexedHordeModelStats, and IndexedHordeWorkers instead of raw lists to skip the O(s+t+w*p) indexing overhead. This is especially beneficial when merging multiple categories sequentially.
Parameters:
-
model_names(Iterable[str]) –Iterable of model names to merge.
-
horde_status(list[HordeModelStatus] | IndexedHordeModelStatus) –Model status from Horde API (list or indexed).
-
horde_stats(HordeModelStatsResponse | IndexedHordeModelStats) –Model statistics from Horde API (response or indexed).
-
workers(list[HordeWorker] | IndexedHordeWorkers | None, default:None) –Optional workers from Horde API (list or indexed).
-
include_backend_variations(bool, default:False) –If True, include per-backend statistics for text models.
Returns:
-
dict[str, CombinedModelStatistics]–Dict of model_name -> CombinedModelStatistics with added runtime fields.