prefect.server.models.work_queues
Functions for interacting with work queue ORM objects. Intended for internal use by the Prefect REST API.
create_work_queue(session, work_queue)
async
Inserts a WorkQueue.
If a WorkQueue with the same name exists, an error will be thrown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
a database session |
required |
work_queue
|
WorkQueue
|
a WorkQueue model |
required |
Returns:
Type | Description |
---|---|
WorkQueue
|
orm_models.WorkQueue: the newly-created or updated WorkQueue |
Source code in src/prefect/server/models/work_queues.py
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 |
|
delete_work_queue(session, work_queue_id)
async
Delete a WorkQueue by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
work_queue_id
|
str
|
a WorkQueue id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the WorkQueue was deleted |
Source code in src/prefect/server/models/work_queues.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
ensure_work_queue_exists(session, name)
async
Checks if a work queue exists and creates it if it does not.
Useful when working with deployments, agents, and flow runs that automatically create work queues.
Will also create a work pool queue in the default agent pool to facilitate migration to work pools.
Source code in src/prefect/server/models/work_queues.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
|
get_runs_in_work_queue(db, session, work_queue_id, limit=None, scheduled_before=None)
async
Get runs from a work queue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session. work_queue_id: The work queue id. |
required |
scheduled_before
|
Optional[datetime]
|
Only return runs scheduled to start before this time. |
None
|
limit
|
Optional[int]
|
An optional limit for the number of runs to return from the
queue. This limit applies to the request only. It does not affect
the work queue's concurrency limit. If |
None
|
Source code in src/prefect/server/models/work_queues.py
297 298 299 300 301 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 333 334 335 336 337 338 |
|
read_work_queue(session, work_queue_id)
async
Reads a WorkQueue by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
work_queue_id
|
str
|
a WorkQueue id |
required |
Returns:
Type | Description |
---|---|
Optional[WorkQueue]
|
orm_models.WorkQueue: the WorkQueue |
Source code in src/prefect/server/models/work_queues.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
read_work_queue_by_name(session, name)
async
Reads a WorkQueue by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
work_queue_id
|
str
|
a WorkQueue id |
required |
Returns:
Type | Description |
---|---|
Optional[WorkQueue]
|
orm_models.WorkQueue: the WorkQueue |
Source code in src/prefect/server/models/work_queues.py
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 |
|
read_work_queue_status(session, work_queue_id)
async
Get work queue status by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
work_queue_id
|
str
|
a WorkQueue id |
required |
Returns:
Type | Description |
---|---|
WorkQueueStatusDetail
|
Information about the status of the work queue. |
Source code in src/prefect/server/models/work_queues.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
read_work_queues(session, offset=None, limit=None, work_queue_filter=None)
async
Read WorkQueues.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
offset
|
Optional[int]
|
Query offset |
None
|
limit
|
Optional[int]
|
Query limit |
None
|
work_queue_filter
|
Optional[WorkQueueFilter]
|
only select work queues matching these filters |
None
|
Source code in src/prefect/server/models/work_queues.py
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 |
|
record_work_queue_polls(session, polled_work_queue_ids, ready_work_queue_ids)
async
Record that the given work queues were polled, and also update the given ready_work_queue_ids to READY.
Source code in src/prefect/server/models/work_queues.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
|
update_work_queue(session, work_queue_id, work_queue, emit_status_change=None)
async
Update a WorkQueue by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
work_queue
|
WorkQueueUpdate
|
the work queue data |
required |
work_queue_id
|
str
|
a WorkQueue id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the WorkQueue was updated |
Source code in src/prefect/server/models/work_queues.py
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 |
|