cmflib.cmfquery.CmfQuery¶
Bases: object
CMF Query communicates with the MLMD database and implements basic search and retrieval functionality.
This class has been designed to work with the CMF framework. CMF alters names of pipelines, stages and artifacts
in various ways. This means that actual names in the MLMD database will be different from those originally provided
by users via CMF API. When methods in this class accept name
parameters, it is expected that values of these
parameters are fully-qualified names of respective entities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath
|
str
|
Path to the MLMD database file. |
'mlmd'
|
Source code in cmflib/cmfquery.py
121 122 123 124 125 126 127 128 129 |
|
get_pipeline_names()
¶
Return names of all pipelines.
Returns:
Type | Description |
---|---|
List[str]
|
List of all pipeline names. |
Source code in cmflib/cmfquery.py
368 369 370 371 372 373 374 |
|
get_pipeline_id(pipeline_name)
¶
Return pipeline identifier for the pipeline names pipeline_name
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_name
|
str
|
Name of the pipeline. |
required |
Returns: Pipeline identifier or -1 if one does not exist.
Source code in cmflib/cmfquery.py
376 377 378 379 380 381 382 383 384 385 |
|
get_pipeline_stages(pipeline_name)
¶
Return list of pipeline stages for the pipeline with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_name
|
str
|
Name of the pipeline for which stages need to be returned. In CMF, there are no different pipelines with the same name. |
required |
Returns: List of stage names associated with the given pipeline.
Source code in cmflib/cmfquery.py
387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
get_all_exe_in_stage(stage_name)
¶
Return list of all executions for the stage with the given name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage_name
|
str
|
Name of the stage. Before stages are recorded in MLMD, they are modified (e.g., pipeline name will become part of the stage name). So stage names from different pipelines will not collide. |
required |
Returns: List of executions for the given stage.
Source code in cmflib/cmfquery.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
get_all_executions_by_ids_list(exe_ids)
¶
Return executions for given execution ids list as a pandas data frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exe_ids
|
List[int]
|
List of execution identifiers. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
Data frame with all executions for the list of given execution identifiers. |
Source code in cmflib/cmfquery.py
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
get_all_artifacts_by_context(pipeline_name)
¶
Return artifacts for given pipeline name as a pandas data frame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_name
|
str
|
Name of the pipeline. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
Data frame with all artifacts associated with given pipeline name. |
Source code in cmflib/cmfquery.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
get_all_artifacts_by_ids_list(artifact_ids)
¶
Return all artifacts for the given artifact ids list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_ids
|
List[int]
|
List of artifact identifiers |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
Data frame with all artifacts for the given artifact ids list. |
Source code in cmflib/cmfquery.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
get_all_executions_in_stage(stage_name)
¶
Return executions of the given stage as pandas data frame. Args: stage_name: Stage name. See doc strings for the prev method. Returns: Data frame with all executions associated with the given stage.
Source code in cmflib/cmfquery.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
|
get_artifact_df(artifact, d=None)
¶
Return artifact's data frame representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact
|
Artifact
|
MLMD entity representing artifact. |
required |
d
|
Optional[Dict]
|
Optional initial content for data frame. |
None
|
Returns: A data frame with the single row containing attributes of this artifact.
Source code in cmflib/cmfquery.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
get_all_artifacts()
¶
Return names of all artifacts.
Returns:
Type | Description |
---|---|
List[str]
|
List of all artifact names. |
Source code in cmflib/cmfquery.py
512 513 514 515 516 517 518 |
|
get_artifact(name)
¶
Return artifact's data frame representation using artifact name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Artifact name. |
required |
Returns: Pandas data frame with one row containing attributes of this artifact.
Source code in cmflib/cmfquery.py
522 523 524 525 526 527 528 529 530 531 532 533 |
|
get_all_artifacts_for_execution(execution_id)
¶
Return input and output artifacts for the given execution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
execution_id
|
int
|
Execution identifier. |
required |
Return: Data frame containing input and output artifacts for the given execution, one artifact per row.
Source code in cmflib/cmfquery.py
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
|
get_all_artifact_types()
¶
Return names of all artifact types.
Returns:
Type | Description |
---|---|
List[str]
|
List of all artifact types. |
Source code in cmflib/cmfquery.py
552 553 554 555 556 557 558 559 560 |
|
get_all_executions_for_artifact(artifact_name)
¶
Return executions that consumed and produced given artifact.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_name
|
str
|
Artifact name. |
required |
Returns: Pandas data frame containing stage executions, one execution per row.
Source code in cmflib/cmfquery.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
|
get_one_hop_child_artifacts(artifact_name, pipeline_id=None)
¶
Get artifacts produced by executions that consume given artifact.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact
|
name
|
Name of an artifact. |
required |
Return: Output artifacts of all executions that consumed given artifact.
Source code in cmflib/cmfquery.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
|
get_all_child_artifacts(artifact_name)
¶
Return all downstream artifacts starting from the given artifact.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_name
|
str
|
Artifact name. |
required |
Returns: Data frame containing all child artifacts.
Source code in cmflib/cmfquery.py
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
|
get_one_hop_parent_artifacts(artifact_name)
¶
Return input artifacts for the execution that produced the given artifact.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_name
|
str
|
Artifact name. |
required |
Returns: Data frame containing immediate parent artifact of given artifact.
Source code in cmflib/cmfquery.py
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 |
|
get_all_parent_artifacts(artifact_name)
¶
Return all upstream artifacts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_name
|
str
|
Artifact name. |
required |
Returns: Data frame containing all parent artifacts.
Source code in cmflib/cmfquery.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
|
get_all_parent_executions(artifact_name)
¶
Return all executions that produced upstream artifacts for the given artifact.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_name
|
str
|
Artifact name. |
required |
Returns: Data frame containing all parent executions.
Source code in cmflib/cmfquery.py
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 |
|
get_metrics(metrics_name)
¶
Return metric data frame. Args: metrics_name: Metrics name. Returns: Data frame containing all metrics.
Source code in cmflib/cmfquery.py
832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
|
dumptojson(pipeline_name, exec_uuid=None)
¶
Return JSON-parsable string containing details about the given pipeline. Args: pipeline_name: Name of an AI pipelines. exec_uuid: Optional stage execution_uuid - filter stages by this execution_uuid. Returns: Pipeline in JSON format.
Source code in cmflib/cmfquery.py
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
|