Item¶
Data containers that flow through the pipeline with timing and sequence tracking.
PipelineItem
¶
Bases: BaseModel
, Generic[DataT]
Data container for pipeline processing.
A wrapper class that carries data through the pipeline along with metadata for tracking timing and performance analysis. Each item maintains detailed timing information as it flows through different pipeline stages.
PARAMETER | DESCRIPTION |
---|---|
data
|
The actual data payload being processed through the pipeline.
TYPE:
|
enable_timing
|
Whether to collect detailed timing information for performance analysis.
TYPE:
|
start_timestamp
|
Timestamp when the item entered the pipeline. Auto-generated if not provided.
TYPE:
|
start_timestamp
class-attribute
instance-attribute
¶
start_timestamp = Field(default_factory=perf_counter)
record_entry_time
¶
record_entry_time(stage_name)
Record when item enters a stage's input queue.
PARAMETER | DESCRIPTION |
---|---|
stage_name
|
Name of the stage whose queue the item is entering.
TYPE:
|
Source code in src/async_task_pipeline/base/item.py
57 58 59 60 61 62 63 64 65 66 |
|
record_completion_time
¶
record_completion_time(stage_name)
Record when a stage completes processing this item.
PARAMETER | DESCRIPTION |
---|---|
stage_name
|
Name of the stage that completed processing.
TYPE:
|
Source code in src/async_task_pipeline/base/item.py
68 69 70 71 72 73 74 75 76 77 |
|
record_detailed_timing
¶
record_detailed_timing(stage_name, detailed_timing)
Record detailed timing for a stage
Source code in src/async_task_pipeline/base/item.py
79 80 81 82 |
|
get_entry_time
¶
get_entry_time(stage_name)
Get the time the item entered the queue for a stage
Source code in src/async_task_pipeline/base/item.py
84 85 86 87 88 89 |
|
get_completion_time
¶
get_completion_time(stage_name)
Get the time the item completed processing for a stage
Source code in src/async_task_pipeline/base/item.py
91 92 93 94 95 96 |
|
get_detailed_timing
¶
get_detailed_timing(stage_name)
Get the detailed timing for a stage
Source code in src/async_task_pipeline/base/item.py
98 99 100 101 102 103 |
|
get_total_latency
¶
get_total_latency()
Calculate total end-to-end latency.
Computes the time from when the item entered the pipeline until the last stage completed processing it.
RETURNS | DESCRIPTION |
---|---|
float | None
|
Total latency in seconds, or None if timing is disabled or no stages have completed processing. |
Source code in src/async_task_pipeline/base/item.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
get_stage_latencies
¶
get_stage_latencies()
Calculate latency for each stage
Source code in src/async_task_pipeline/base/item.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
get_timing_breakdown
¶
get_timing_breakdown()
Get detailed timing breakdown for each stage.
Provides comprehensive timing analysis including queue wait times, computation times, transmission times, and overall efficiency metrics.
RETURNS | DESCRIPTION |
---|---|
dict[str, dict[str, float]] | None
|
Dictionary with per-stage timing breakdowns and totals, including: - Per-stage: queue_wait_time, computation_time, transmission_time - Totals: total_computation_time, total_overhead_time, computation_ratio Returns None if timing is disabled or no detailed timings available. |
Source code in src/async_task_pipeline/base/item.py
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 |
|