prefect.server.models.artifacts
count_artifacts(session, artifact_filter=None, flow_run_filter=None, task_run_filter=None, deployment_filter=None, flow_filter=None)
async
Counts artifacts. Args: session: A database session artifact_filter: Only select artifacts matching this filter flow_run_filter: Only select artifacts whose flow runs matching this filter task_run_filter: Only select artifacts whose task runs matching this filter
Source code in src/prefect/server/models/artifacts.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
count_latest_artifacts(session, artifact_filter=None, flow_run_filter=None, task_run_filter=None, deployment_filter=None, flow_filter=None)
async
Counts artifacts. Args: session: A database session artifact_filter: Only select artifacts matching this filter flow_run_filter: Only select artifacts whose flow runs matching this filter task_run_filter: Only select artifacts whose task runs matching this filter
Source code in src/prefect/server/models/artifacts.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
delete_artifact(session, artifact_id)
async
Deletes an artifact by id.
The ArtifactCollection table is used to track the latest version of an artifact by key. If we are deleting the latest version of an artifact from the Artifact table, we need to first update the latest version referenced in ArtifactCollection so that it points to the next latest version of the artifact.
Example: If we have the following artifacts in Artifact: - key: "foo", id: 1, created: 2020-01-01 - key: "foo", id: 2, created: 2020-01-02 - key: "foo", id: 3, created: 2020-01-03
the ArtifactCollection table has the following entry: - key: "foo", latest_id: 3
If we delete the artifact with id 3, we need to update the latest version of the artifact with key "foo" to be the artifact with id 2.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
artifact_id
|
UUID
|
The artifact id to delete |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the delete was successful, False otherwise |
Source code in src/prefect/server/models/artifacts.py
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 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
|
read_artifact(session, artifact_id)
async
Reads an artifact by id.
Source code in src/prefect/server/models/artifacts.py
144 145 146 147 148 149 150 151 152 153 154 155 |
|
read_artifacts(session, offset=None, limit=None, artifact_filter=None, flow_run_filter=None, task_run_filter=None, deployment_filter=None, flow_filter=None, sort=sorting.ArtifactSort.ID_DESC)
async
Reads artifacts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
offset
|
Optional[int]
|
Query offset |
None
|
limit
|
Optional[int]
|
Query limit |
None
|
artifact_filter
|
Optional[ArtifactFilter]
|
Only select artifacts matching this filter |
None
|
flow_run_filter
|
Optional[FlowRunFilter]
|
Only select artifacts whose flow runs matching this filter |
None
|
task_run_filter
|
Optional[TaskRunFilter]
|
Only select artifacts whose task runs matching this filter |
None
|
deployment_filter
|
Optional[DeploymentFilter]
|
Only select artifacts whose flow runs belong to deployments matching this filter |
None
|
flow_filter
|
Optional[FlowFilter]
|
Only select artifacts whose flow runs belong to flows matching this filter |
None
|
work_pool_filter
|
Only select artifacts whose flow runs belong to work pools matching this filter |
required |
Source code in src/prefect/server/models/artifacts.py
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 294 295 296 |
|
read_latest_artifact(session, key)
async
Reads the latest artifact by key. Args: session: A database session key: The artifact key Returns: Artifact: The latest artifact
Source code in src/prefect/server/models/artifacts.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
read_latest_artifacts(session, offset=None, limit=None, artifact_filter=None, flow_run_filter=None, task_run_filter=None, deployment_filter=None, flow_filter=None, sort=sorting.ArtifactCollectionSort.ID_DESC)
async
Reads artifacts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
offset
|
Optional[int]
|
Query offset |
None
|
limit
|
Optional[int]
|
Query limit |
None
|
artifact_filter
|
Optional[ArtifactCollectionFilter]
|
Only select artifacts matching this filter |
None
|
flow_run_filter
|
Optional[FlowRunFilter]
|
Only select artifacts whose flow runs matching this filter |
None
|
task_run_filter
|
Optional[TaskRunFilter]
|
Only select artifacts whose task runs matching this filter |
None
|
deployment_filter
|
Optional[DeploymentFilter]
|
Only select artifacts whose flow runs belong to deployments matching this filter |
None
|
flow_filter
|
Optional[FlowFilter]
|
Only select artifacts whose flow runs belong to flows matching this filter |
None
|
work_pool_filter
|
Only select artifacts whose flow runs belong to work pools matching this filter |
required |
Source code in src/prefect/server/models/artifacts.py
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 339 340 |
|
update_artifact(session, artifact_id, artifact)
async
Updates an artifact by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
AsyncSession
|
A database session |
required |
artifact_id
|
UUID
|
The artifact id to update |
required |
artifact
|
ArtifactUpdate
|
An artifact model |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the update was successful, False otherwise |
Source code in src/prefect/server/models/artifacts.py
405 406 407 408 409 410 411 412 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 |
|