Dag utils
Base
Source code in blue/utils/dag_utils.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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 170 171 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 201 202 203 204 205 206 207 208 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
__init__(id=None, label=None, type=None, properties=None, path=None, synchronizer=None, auto_sync=False, sync=None)
Initialize the Base object, which serves as a foundational class for other entities, including Nodes and DAGs.
Each Base object is characterized by a unique identifier (id), an optional label, a type, and a set of properties. The class also supports synchronization features to keep the object's state consistent with an external source
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the object. If None, a unique ID will be generated. Defaults to None. |
None
|
|
label
|
Label of the object. Defaults to None. |
None
|
|
type
|
Type of the object. Defaults to None. |
None
|
|
properties
|
Properties of the object as a dictionary. Defaults to None. |
None
|
|
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
If True, force synchronization of instatiation regardless of auto_sync setting. Defaults to None. |
None
|
Source code in blue/utils/dag_utils.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
append_data(key, value, unique=False, sync=None)
Append a value to a list at the specified key, assumes key is a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key of the list to append to. |
required | |
value
|
Value to append. |
required | |
unique
|
If True, only append if the value is not already in the list. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If the data at the specified key is not a list. |
Source code in blue/utils/dag_utils.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
from_dict(d, path=None, synchronizer=None, auto_sync=False, sync=None)
classmethod
Create an instance of the class from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
Dictionary to create the instance from. |
required | |
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
If validation fails. |
Returns:
| Type | Description |
|---|---|
|
Instance of the class |
Source code in blue/utils/dag_utils.py
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 | |
get_data(key=None)
Get data by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key to get. If None, return all data. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Value associated with the key, or the entire data dictionary if key is None. |
Source code in blue/utils/dag_utils.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_id()
Get the ID of the object.
Returns:
| Type | Description |
|---|---|
|
ID of the object. |
Source code in blue/utils/dag_utils.py
134 135 136 137 138 139 140 | |
get_label()
Get the label of the object.
Returns:
| Type | Description |
|---|---|
|
Label of the object. |
Source code in blue/utils/dag_utils.py
142 143 144 145 146 147 148 | |
get_properties()
Get all properties.
Returns:
| Type | Description |
|---|---|
|
Dictionary with all properties. |
Source code in blue/utils/dag_utils.py
197 198 199 200 201 202 203 | |
get_property(key)
Get a property by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key of the property. |
required |
Returns:
| Type | Description |
|---|---|
|
Value of the property, or None if the key does not exist. |
Source code in blue/utils/dag_utils.py
183 184 185 186 187 188 189 190 191 192 193 194 195 | |
get_type()
Get the type of the object.
Returns:
| Type | Description |
|---|---|
|
Type of the object. |
Source code in blue/utils/dag_utils.py
150 151 152 153 154 155 156 | |
set_data(key, value, sync=None)
Set a data key-value pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key to set. |
required | |
value
|
Value to set. |
required | |
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None. |
None
|
Source code in blue/utils/dag_utils.py
75 76 77 78 79 80 81 82 83 84 85 86 | |
set_property(key, value, sync=None)
Set a property key-value pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key of the property. |
required | |
value
|
Value of the property. |
required | |
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
170 171 172 173 174 175 176 177 178 179 180 181 | |
synchronize(key=None, value=None, single=True, sync=None)
Synchronize the object or a specific key-value pair using the provided synchronizer function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key to synchronize. If None, synchronize the entire object. Defaults to None. |
None
|
|
value
|
Value to synchronize. If None, the current value of the key will be retrieved. Defaults to None. |
None
|
|
single
|
If True, expect a single value; if False, expect a list from JSON query. Defaults to True. |
True
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
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 277 278 279 280 281 282 283 284 285 286 | |
synchronizer(path, key, value)
Default synchronizer function that prints the synchronization action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path for synchronization context. |
required | |
key
|
Key to synchronize. |
required | |
value
|
Value to synchronize. |
required |
Source code in blue/utils/dag_utils.py
288 289 290 291 292 293 294 295 296 | |
DAG
Bases: Base
Source code in blue/utils/dag_utils.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 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 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 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 527 528 529 530 531 532 533 534 535 536 537 538 539 540 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 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 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 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
__init__(id=None, label=None, type='DAG', properties=None, path=None, synchronizer=None, auto_sync=False, sync=None)
A Directed Acyclic Graph (DAG) structure to manage nodes and their connections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the DAG. Defaults to None. |
None
|
|
label
|
Label of the DAG. Defaults to None. |
None
|
|
type
|
Type of the DAG. Defaults to "DAG". |
'DAG'
|
|
properties
|
Properties of the DAG as a dictionary. Defaults to None. |
None
|
|
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 | |
connect_nodes(f, t, sync=None)
Connect two nodes in the DAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
From node |
required | |
t
|
To node |
required | |
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
Undefined from node |
Exception
|
Undefined to node |
Source code in blue/utils/dag_utils.py
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 | |
count_nodes(filter_node_type=None, filter_hasPrev=None, filter_hasNext=None)
Count nodes based on criteria, such as node type, having previous nodes, or having next nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_node_type
|
List of node types to filter by. Defaults to None. |
None
|
|
filter_hasPrev
|
Whether to filter nodes that have previous nodes. Defaults to None. |
None
|
|
filter_hasNext
|
Whether to filter nodes that have next nodes. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Count of filtered nodes. |
Source code in blue/utils/dag_utils.py
608 609 610 611 612 613 614 615 616 617 618 619 620 | |
create_node(id=None, label=None, type=None, properties=None, sync=None)
Create a new node in the DAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the node. Defaults to None. |
None
|
|
label
|
Label of the node. Defaults to None. |
None
|
|
type
|
Type of the node. Defaults to None. |
None
|
|
properties
|
Properties of the node as a dictionary. Defaults to None. |
None
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Returns:
| Type | Description |
|---|---|
|
The created Node object. |
Source code in blue/utils/dag_utils.py
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 | |
filter_nodes(filter_node_type=None, filter_hasPrev=None, filter_hasNext=None)
Filter nodes based on criteria, such as node type, having previous nodes, or having next nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_node_type
|
List of node types to filter by. Defaults to None. |
None
|
|
filter_hasPrev
|
Whether to filter nodes that have previous nodes. Defaults to None. |
None
|
|
filter_hasNext
|
Whether to filter nodes that have next nodes. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Dictionary of filtered nodes. |
Source code in blue/utils/dag_utils.py
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
get_next_nodes(n)
Get next nodes connected to the given node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Node ID or label |
required |
Returns:
| Type | Description |
|---|---|
|
List of next Node objects. |
Source code in blue/utils/dag_utils.py
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | |
get_node(n, cls=None)
Get a node by ID or label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Node ID or label |
required | |
cls
|
Class type to return. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Node object or None if not found. |
Source code in blue/utils/dag_utils.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
get_node_by_id(node_id, cls=None)
Get a node by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
Node ID |
required | |
cls
|
Class type to return. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Node object or None if not found. |
Source code in blue/utils/dag_utils.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | |
get_node_by_label(node_label, cls=None)
Get a node by its label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_label
|
Node label |
required | |
cls
|
Class type to return. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Node object or None if not found. |
Source code in blue/utils/dag_utils.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
get_nodes()
Get all nodes in the DAG.
Returns:
Source code in blue/utils/dag_utils.py
469 470 471 472 473 474 475 | |
get_prev_nodes(n)
Get previous nodes connected to the given node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Node ID or label |
required |
Returns:
| Type | Description |
|---|---|
|
List of previous Node objects. |
Source code in blue/utils/dag_utils.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
is_mapped(i)
Check if a label is mapped to a node ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
i
|
Label to check. |
required |
Returns:
| Type | Description |
|---|---|
|
True if the label is mapped, False otherwise. |
Source code in blue/utils/dag_utils.py
653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
is_node_leaf(n)
Check if a node is a leaf node (has previous nodes but no next nodes).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Node ID or label |
required |
Returns:
| Type | Description |
|---|---|
|
True if the node is a leaf node, False otherwise. |
Source code in blue/utils/dag_utils.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
map(f, t, sync=None)
Map a label to a node ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
Label to map from. |
required | |
t
|
Node ID to map to. |
required | |
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
640 641 642 643 644 645 646 647 648 649 650 651 | |
Entity
Bases: Base
Source code in blue/utils/dag_utils.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
__init__(id=None, label=None, type='Entity', properties=None, path=None, synchronizer=None, auto_sync=False, sync=None)
Entity in an EntityDAG. Entities can be linked to nodes in the DAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the entity. Defaults to None. |
None
|
|
label
|
Label of the entity. Defaults to None. |
None
|
|
type
|
Type of the entity. Defaults to "Entity". |
'Entity'
|
|
properties
|
Properties of the entity as a dictionary. Defaults to None. |
None
|
|
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
EntityDAG
Bases: DAG
Source code in blue/utils/dag_utils.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 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 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 | |
__init__(id=None, label=None, type='DAG', properties=None, path=None, synchronizer=None, auto_sync=False, sync=None)
Entity DAG to manage entities
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the DAG. Defaults to None. |
None
|
|
label
|
Label of the DAG. Defaults to None. |
None
|
|
type
|
Type of the DAG. Defaults to "DAG". |
'DAG'
|
|
properties
|
Properties of the DAG as a dictionary. Defaults to None. |
None
|
|
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
add_entity_type(type, sync=None)
Add a new entity type to the DAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Entity type to add. |
required | |
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
782 783 784 785 786 787 788 789 790 791 792 793 794 | |
create_entity(id=None, label=None, type=None, properties=None, sync=None)
Create a new entity in the EntityDAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the entity. Defaults to None. |
None
|
|
label
|
Label of the entity. Defaults to None. |
None
|
|
type
|
Type of the entity. Defaults to None. |
None
|
|
properties
|
Properties of the entity as a dictionary. Defaults to None. |
None
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
Cannot create entity due to failed varification |
Returns:
| Type | Description |
|---|---|
|
The created Entity object. |
Source code in blue/utils/dag_utils.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
get_entities(type=None)
Get entities in the DAG, optionally filtered by type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Entity type to filter by. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Dictionary of entities, either all or filtered by type. |
Source code in blue/utils/dag_utils.py
796 797 798 799 800 801 802 803 804 805 806 807 808 | |
get_entity(e, type=None, cls=None)
Get an entity by ID or label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
Entity ID or label |
required | |
type
|
Type of the entity. Defaults to None. |
None
|
|
cls
|
Class type to return. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Entity object or None if not found. |
Source code in blue/utils/dag_utils.py
810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
get_entity_by_id(entity_id, type=None, cls=None)
Get an entity by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_id
|
ID of the entity. |
required | |
type
|
Type of the entity. Defaults to None. |
None
|
|
cls
|
Class type to return. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Entity object or None if not found. |
Source code in blue/utils/dag_utils.py
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | |
get_entity_by_label(entity_label, type=None, cls=None)
Get an entity by its label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entity_label
|
Label of the entity. |
required | |
type
|
Type of the entity. Defaults to None. |
None
|
|
cls
|
Class type to return. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
Entity object or None if not found. |
Source code in blue/utils/dag_utils.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 | |
get_node_entity(n, type=None, cls=None, field=None)
Get the entity associated with a specific node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Node ID or label |
required | |
type
|
Type of the entity. Defaults to None. |
None
|
|
cls
|
Class type to return. Defaults to None. |
None
|
|
field
|
Field to get the entity from the node. Defaults to None, which uses the entity type or "Entity". |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
Entity for non-existing node cannot be get |
Returns:
| Type | Description |
|---|---|
|
Entity object or None if not found. |
Source code in blue/utils/dag_utils.py
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | |
get_nodes_by_entity(e, type=None, cls=None, node_type=None)
Get nodes associated with a specific entity, optionally filtered by node type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
e
|
Entity ID or label |
required | |
type
|
Type of the entity. Defaults to None. |
None
|
|
cls
|
Class type to return. Defaults to None. |
None
|
|
node_type
|
Node type or list of node types to filter by. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
List of Node objects associated with the entity, optionally filtered by node type. |
Source code in blue/utils/dag_utils.py
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |
has_entity_type(type)
Check if an entity type exists, in the DAG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
Entity type to check. |
required |
Returns:
| Type | Description |
|---|---|
|
True if the entity type exists, False otherwise. |
Source code in blue/utils/dag_utils.py
770 771 772 773 774 775 776 777 778 779 780 | |
set_node_entity(n, e, field=None, sync=None)
Set an entity for a specific node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Node ID or label |
required | |
e
|
Entity ID or label |
required | |
field
|
Field to set the entity in the node. Defaults to None, which uses the entity type or "Entity". |
None
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Raises:
| Type | Description |
|---|---|
Exception
|
Entity for non-existing node cannot be set |
Source code in blue/utils/dag_utils.py
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 | |
verify_entity(label=None, type=None, properties=None)
Verify if an entity can be created, checks if label is unique.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
Label of the entity. Defaults to None. |
None
|
|
type
|
Type of the entity. Defaults to None. |
None
|
|
properties
|
Properties of the entity as a dictionary. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
|
True if the entity can be created, False otherwise. |
Source code in blue/utils/dag_utils.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | |
Node
Bases: Base
Source code in blue/utils/dag_utils.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 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
__init__(id=None, label=None, type=None, properties=None, path=None, synchronizer=None, auto_sync=False, sync=None)
Initializer a Node in a DAG
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the node. Defaults to None. |
None
|
|
label
|
Label of the node. Defaults to None. |
None
|
|
type
|
Type of the node. Defaults to None. |
None
|
|
properties
|
Properties of the node as a dictionary. Defaults to None. |
None
|
|
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
connect_to(t, sync=None)
Connect this node to another node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
Target node to connect to. |
required | |
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
331 332 333 334 335 336 337 338 339 340 341 342 | |
Plan
Bases: EntityDAG
Source code in blue/utils/dag_utils.py
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | |
__init__(id=None, label=None, type='PLAN', properties=None, path=None, synchronizer=None, auto_sync=False, sync=None)
Instance of a Plan, which is an EntityDAG with additional merge functionality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
ID of the plan. Defaults to None. |
None
|
|
label
|
Label of the plan. Defaults to None. |
None
|
|
type
|
Type of the plan. Defaults to "PLAN". |
'PLAN'
|
|
properties
|
Properties of the plan as a dictionary. Defaults to None. |
None
|
|
path
|
Path for synchronization context. Defaults to None. |
None
|
|
synchronizer
|
Function to handle synchronization. Defaults to None. |
None
|
|
auto_sync
|
If True, automatically synchronize changes. Defaults to False. |
False
|
|
sync
|
Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None |
None
|
Source code in blue/utils/dag_utils.py
984 985 986 987 988 989 990 991 992 993 994 995 996 997 | |
merge(merge_plan, sync=None)
Merge another plan into this plan. Parameters: merge_plan: Plan to merge into this plan. sync: Synchronization flag. If True, force synchronization regardless of auto_sync setting. Defaults to None
Source code in blue/utils/dag_utils.py
999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 | |