Step Wrapper¶
_StepWrapper
¶
Wrapper to run the Step
.
Attributes:
Name | Type | Description |
---|---|---|
step |
The step to run. |
|
replica |
The replica ID assigned. |
|
input_queue |
The queue to receive the input data. |
|
output_queue |
The queue to send the output data. |
|
load_queue |
The queue used to notify the main process that the step has been loaded, has been unloaded or has failed to load. |
Source code in src/distilabel/pipeline/step_wrapper.py
28 29 30 31 32 33 34 35 36 37 38 39 40 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 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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
__init__(step, replica, input_queue, output_queue, load_queue, dry_run=False, ray_pipeline=False)
¶
Initializes the _ProcessWrapper
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step
|
Union[Step, GeneratorStep]
|
The step to run. |
required |
input_queue
|
Queue[_Batch]
|
The queue to receive the input data. |
required |
output_queue
|
Queue[_Batch]
|
The queue to send the output data. |
required |
load_queue
|
Queue[Union[StepLoadStatus, None]]
|
The queue used to notify the main process that the step has been loaded, has been unloaded or has failed to load. |
required |
dry_run
|
bool
|
Flag to ensure we are forcing to run the last batch. |
False
|
ray_pipeline
|
bool
|
Whether the step is running a |
False
|
Source code in src/distilabel/pipeline/step_wrapper.py
_init_cuda_device_placement()
¶
Sets the LLM identifier and the number of desired GPUs of the CudaDevicePlacementMixin
Source code in src/distilabel/pipeline/step_wrapper.py
run()
¶
The target function executed by the process. This function will also handle
the step lifecycle, executing first the load
function of the Step
and then
waiting to receive a batch from the input_queue
that will be handled by the
process
method of the Step
.
Returns:
Type | Description |
---|---|
str
|
The name of the step that was executed. |
Source code in src/distilabel/pipeline/step_wrapper.py
_notify_load()
¶
Notifies that the step has finished executing its load
function successfully.
Source code in src/distilabel/pipeline/step_wrapper.py
_notify_unload()
¶
Notifies that the step has been unloaded.
Source code in src/distilabel/pipeline/step_wrapper.py
_notify_load_failed()
¶
Notifies that the step failed to load.
Source code in src/distilabel/pipeline/step_wrapper.py
_generator_step_process_loop()
¶
Runs the process loop for a generator step. It will call the process
method
of the step and send the output data to the output_queue
and block until the next
batch request is received (i.e. receiving an empty batch from the input_queue
).
If the last_batch
attribute of the batch is True
, the loop will stop and the
process will finish.
Raises:
Type | Description |
---|---|
_StepWrapperException
|
If an error occurs during the execution of the
|
Source code in src/distilabel/pipeline/step_wrapper.py
_non_generator_process_loop()
¶
Runs the process loop for a non-generator step. It will call the process
method of the step and send the output data to the output_queue
and block until
the next batch is received from the input_queue
. If the last_batch
attribute
of the batch is True
, the loop will stop and the process will finish.
If an error occurs during the execution of the process
method and the step is
global, the process will raise a _StepWrapperException
. If the step is not
global, the process will log the error and send an empty batch to the output_queue
.
Raises:
Type | Description |
---|---|
_StepWrapperException
|
If an error occurs during the execution of the
|
Source code in src/distilabel/pipeline/step_wrapper.py
_impute_step_outputs(batch)
¶
Imputes the step outputs columns with None
in the batch data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch
|
_Batch
|
The batch to impute. |
required |
Source code in src/distilabel/pipeline/step_wrapper.py
_send_batch(batch)
¶
Sends a batch to the output_queue
.
Source code in src/distilabel/pipeline/step_wrapper.py
_StepWrapperException
¶
Bases: Exception
Exception to be raised when an error occurs in the _StepWrapper
class.
Attributes:
Name | Type | Description |
---|---|---|
message |
The error message. |
|
step |
The |
|
code |
The error code. |
|
subprocess_exception |
The exception raised by the subprocess. |
|
data |
The data that caused the error. Defaults to |
Source code in src/distilabel/pipeline/step_wrapper.py
is_load_error
property
¶
Whether the error is a load error.
Returns:
Type | Description |
---|---|
bool
|
|
create_load_error(message, step, subprocess_exception=None)
classmethod
¶
Creates a _StepWrapperException
for a load error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message
|
str
|
The error message. |
required |
step
|
_Step
|
The |
required |
subprocess_exception
|
Optional[Exception]
|
The exception raised by the subprocess. Defaults to |
None
|
Returns:
Type | Description |
---|---|
_StepWrapperException
|
The |