flight
Arrow Flight utilities.
ChainedFlightReader ¶
ChainedFlightReader(endpoints, initial_url, metadata=None, middleware=None)
Bases: StreamReader
Sequential reader for time-ordered endpoint slices.
Groups endpoints by time slice (based on the start time in their tickets), orders slices chronologically, and reads each slice to completion before starting the next. Concurrent endpoints within the same slice are handled by a MultiFlightReader.
Source code in arrakis/flight.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |
MultiFlightReader ¶
MultiFlightReader(endpoints, initial_url, metadata=None, middleware=None)
Bases: StreamReader
Multi-threaded Arrow Flight endpoint stream iterator context manager
Given a list of endpoints, connect to all of them in parallel and stream data from them all interleaved.
Source code in arrakis/flight.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
close ¶
close()
Close all streams, cancelling in-flight reads.
A DoGet blocked on a quiet stream holds its worker thread until data arrives; without the cancel, close() waited on that forever (and interrupting it left the interpreter's atexit hook waiting on the same thread). Cancelling unblocks the read immediately and signals the server, whose stream generator observes the cancellation at its next heartbeat.
Source code in arrakis/flight.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
done ¶
done()
returns True when all threads are done and the queue is empty
A failed endpoint must surface even here: consumers check done() before read(), so with the queue drained a stream whose endpoint(s) died with an error would otherwise be reported as a clean end of stream and the error never raised.
Source code in arrakis/flight.py
528 529 530 531 532 533 534 535 536 537 538 539 | |
read ¶
read(*, convert_blocks=False)
read all available data from all streams
Yields:
| Type | Description |
|---|---|
tuple of (stream_id, data)
|
|
Source code in arrakis/flight.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | |
ParsedRequest
dataclass
¶
ParsedRequest(request, args, version)
A parsed and validated request envelope.
RequestValidator ¶
RequestValidator()
A validator for JSON-encoded requests.
Source code in arrakis/flight.py
99 100 101 102 103 104 105 | |
known_args ¶
known_args(request)
Return the argument names the loaded schema defines for a request.
Servers use this to distinguish arguments introduced by newer schema versions from typos, and reject both with an actionable error instead of an incidental dispatch failure.
Source code in arrakis/flight.py
115 116 117 118 119 120 121 122 | |
validate ¶
validate(payload)
Validate a JSON-encoded request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Request
|
A dictionary with a 'request' and an 'args' key encoding the given Flight request. |
required |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
connect ¶
connect(location, **kwargs)
Connect to a Flight server with arrakis default channel options.
A drop-in wrapper for :func:pyarrow.flight.connect that applies
KEEPALIVE_OPTIONS unless the caller passes its own
generic_options.
Source code in arrakis/flight.py
76 77 78 79 80 81 82 83 84 | |
create_command ¶
create_command(request_type, *, validator, **kwargs)
Create a Flight command containing a JSON-encoded request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_type
|
RequestType
|
The type of request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
**kwargs
|
dict
|
Extra arguments corresponding to the specific request. |
{}
|
Returns:
| Type | Description |
|---|---|
bytes
|
The JSON-encoded request. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |
create_descriptor ¶
create_descriptor(request_type, *, validator, **kwargs)
Create a Flight descriptor given a request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_type
|
RequestType
|
The type of request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
**kwargs
|
dict
|
Extra arguments corresponding to the specific request. |
{}
|
Returns:
| Type | Description |
|---|---|
FlightDescriptor
|
A Flight Descriptor containing the request. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |
parse_command ¶
parse_command(cmd, *, validator)
Parse a Flight command into a request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
bytes
|
The JSON-encoded request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
request_type |
RequestType
|
The type of request. |
kwargs |
dict
|
Arguments corresponding to the specific request. |
Raises:
| Type | Description |
|---|---|
JSONDecodeError
|
If the command does not decode to valid JSON. |
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |
parse_request ¶
parse_request(cmd, *, validator)
Parse a Flight command into a request envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
bytes
|
The JSON-encoded request. |
required |
validator
|
RequestValidator
|
A validator to validate that the command matches the expected schema. |
required |
Returns:
| Type | Description |
|---|---|
ParsedRequest
|
The parsed request envelope. |
Raises:
| Type | Description |
|---|---|
JSONDecodeError
|
If the command does not decode to valid JSON. |
ValidationError
|
If the request does not match the expected schema. |
Source code in arrakis/flight.py
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 | |