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
116 117 118 119 |
|
get_pipeline_names()
¶
Return names of all pipelines.
Returns:
Type | Description |
---|---|
List[str]
|
List of all pipeline names. |
Source code in cmflib/cmfquery.py
356 357 358 359 360 361 362 |
|
get_pipeline_id(pipeline_name)
¶
Return pipeline identifier for the pipeline names pipeline_name
.
Args:
pipeline_name: Name of the pipeline.
Returns:
Pipeline identifier or -1 if one does not exist.
Source code in cmflib/cmfquery.py
364 365 366 367 368 369 370 371 372 |
|
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
374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
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
388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
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
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
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
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
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
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
|
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
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
|
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
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
|
get_all_artifacts()
¶
Return names of all artifacts.
Returns:
Type | Description |
---|---|
List[str]
|
List of all artifact names. |
Source code in cmflib/cmfquery.py
499 500 501 502 503 504 505 |
|
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
509 510 511 512 513 514 515 516 517 518 519 520 |
|
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
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
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
539 540 541 542 543 544 545 546 547 |
|
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
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 577 578 579 580 |
|
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
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
|
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
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 |
|
get_one_hop_parent_artifacts(artifact_name)
¶
Return input artifacts for the execution that produced the given artifact. Args: artifact_name: Artifact name. Returns: Data frame containing immediate parent artifactog of given artifact.
Source code in cmflib/cmfquery.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 |
|
get_all_parent_artifacts(artifact_name)
¶
Return all upstream artifacts. Args: artifact_name: Artifact name. Returns: Data frame containing all parent artifacts.
Source code in cmflib/cmfquery.py
712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
|
get_all_parent_executions(artifact_name)
¶
Return all executions that produced upstream artifacts for the given artifact. Args: artifact_name: Artifact name. Returns: Data frame containing all parent executions.
Source code in cmflib/cmfquery.py
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
|
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
816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
|
dumptojson(pipeline_name, exec_id=None)
¶
Return JSON-parsable string containing details about the given pipeline. Args: pipeline_name: Name of an AI pipelines. exec_id: Optional stage execution ID - filter stages by this execution ID. Returns: Pipeline in JSON format.
Source code in cmflib/cmfquery.py
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
|