utils
IncompatibleLoaderError
Bases: ValueError
Error when Loader is incompatible with a representation.
Source code in client/ayon_core/pipeline/load/utils.py
58 59 60 | |
InvalidRepresentationContext
Bases: ValueError
Representation path can't be received using representation document.
Source code in client/ayon_core/pipeline/load/utils.py
63 64 65 | |
LoadError
Bases: Exception
Known error that happened during loading.
A message is shown to user (without traceback). Make sure an artist can understand the problem.
Source code in client/ayon_core/pipeline/load/utils.py
48 49 50 51 52 53 54 55 | |
LoaderNotFoundError
Bases: RuntimeError
Error when Loader plugin for a loader name is not found.
Source code in client/ayon_core/pipeline/load/utils.py
73 74 75 | |
LoaderSwitchNotImplementedError
Bases: NotImplementedError
Error when switch is used with Loader that has no implementation.
Source code in client/ayon_core/pipeline/load/utils.py
68 69 70 | |
any_outdated_containers(host=None, project_name=None)
Check if there are any outdated containers in scene.
Source code in client/ayon_core/pipeline/load/utils.py
937 938 939 940 941 942 | |
filter_containers(containers, project_name)
Filter containers and split them into 4 categories.
Categories are 'latest', 'outdated', 'invalid' and 'not_found'. The 'lastest' containers are from last version, 'outdated' are not, 'invalid' are invalid containers (invalid content) and 'not_found' has some missing entity in database.
Todos
Respect 'project_name' on containers if is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
containers | Iterable[dict] | List of containers referenced into scene. | required |
project_name | str | Name of project in which context shoud look for versions. | required |
Returns:
| Name | Type | Description |
|---|---|---|
ContainersFilterResult | Named tuple with 'latest', 'outdated', 'invalid' and 'not_found' containers. |
Source code in client/ayon_core/pipeline/load/utils.py
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 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 | |
filter_repre_contexts_by_loader(repre_contexts, loader)
Filter representation contexts for loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repre_contexts | list[dict[str, Ant]] | Representation context. | required |
loader | LoaderPlugin | Loader plugin to filter contexts for. | required |
Returns:
| Type | Description |
|---|---|
| list[dict[str, Any]]: Filtered representation contexts. |
Source code in client/ayon_core/pipeline/load/utils.py
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | |
get_loader_identifier(loader)
Loader identifier from loader plugin or object.
Identifier should be stored to container for future management.
Source code in client/ayon_core/pipeline/load/utils.py
423 424 425 426 427 428 429 430 | |
get_outdated_containers(host=None, project_name=None, ignore_locked_versions=False)
Collect outdated containers from host scene.
Currently registered host and project in global session are used if arguments are not passed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host | Optional[AbstractHost] | Host implementation. | None |
project_name | Optional[str] | Name of project in which context we are. | None |
ignore_locked_versions | bool | Locked versions are ignored. | False |
Source code in client/ayon_core/pipeline/load/utils.py
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 981 982 | |
get_product_contexts(product_ids, project_name=None)
Return parenthood context for product.
Provides context on product granularity - less detail than
'get_repre_contexts'.
Args: product_ids (list): The product ids. project_name (Optional[str]): Project name. Returns: dict: The full representation context by representation id.
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_repres_contexts(representation_ids, project_name=None)
Return parenthood context for representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
representation_ids | list | The representation ids. | required |
project_name | Optional[str] | Project name. | None |
Returns:
| Name | Type | Description |
|---|---|---|
dict | The full representation context by representation id. keys are repre_id, value is dictionary with entities of folder, product, version and representation. |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_by_names(project_name, folder_path, product_name, version_name, representation_name)
Get representation entity for asset and subset.
If version_name is "hero" then return the hero version If version_name is "latest" then return the latest version Otherwise use version_name as the exact integer version name.
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_context(project_name, representation)
Return parenthood context for representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name | str | Project name. | required |
representation | Union[dict[str, Any], str] | Representation entity or representation id. | required |
Returns:
| Type | Description |
|---|---|
| dict[str, dict[str, Any]]: The full representation context. |
Raises:
| Type | Description |
|---|---|
ValueError | When representation is invalid or parents were not found. |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_contexts(project_name, representation_entities)
Parenthood context for representations.
Function fills None if any entity was not found or could not be queried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name | str | Project name. | required |
representation_entities | Iterable[dict[str, Any]] | Representation entities. | required |
Returns:
| Type | Description |
|---|---|
| dict[str, dict[str, Any]]: The full representation context by representation id. |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_contexts_by_ids(project_name, representation_ids)
Parenthood context for representations found by ids.
Function fills None if any entity was not found or could not be queried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name | str | Project name. | required |
representation_ids | Iterable[str] | Representation ids. | required |
Returns:
| Type | Description |
|---|---|
| dict[str, dict[str, Any]]: The full representation context by representation id. |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_path(representation, root=None)
Get filename from representation document
There are three ways of getting the path from representation which are tried in following sequence until successful. 1. Get template from representation['data']['template'] and data from representation['context']. Then format template with the data. 2. Get template from project['config'] and format it with default data set 3. Get representation['data']['path'] and use it directly
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
representation | dict | representation document from the database | required |
Returns:
| Name | Type | Description |
|---|---|---|
str | fullpath of the representation |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_path_by_names(project_name, folder_path, product_name, version_name, representation_name, anatomy=None)
Get (latest) filepath for representation for folder and product.
See get_representation_by_names for more details.
Returns:
| Name | Type | Description |
|---|---|---|
str | Optional[str] | The representation path if the representation exists. |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
get_representation_path_from_context(context)
Preparation wrapper using only context as a argument
Source code in client/ayon_core/pipeline/load/utils.py
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
get_representation_path_with_anatomy(repre_entity, anatomy)
Receive representation path using representation document and anatomy.
Anatomy is used to replace 'root' key in representation file. Ideally should be used instead of 'get_representation_path' which is based on "current context".
Future notes
We want also be able store resources into representation and I can imagine the result should also contain paths to possible resources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repre_entity | Dict[str, Any] | Representation entity. | required |
anatomy | Anatomy | Project anatomy object. | required |
Returns:
| Type | Description |
|---|---|
| Union[None, TemplateResult]: None if path can't be received |
Raises:
| Type | Description |
|---|---|
InvalidRepresentationContext | When representation data are probably invalid or not available. |
Source code in client/ayon_core/pipeline/load/utils.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | |
is_compatible_loader(Loader, context)
Return whether a loader is compatible with a context.
This checks the product type and the representation for the given Loader.
Returns:
| Type | Description |
|---|---|
| bool |
Source code in client/ayon_core/pipeline/load/utils.py
885 886 887 888 889 890 891 892 893 894 895 | |
load_container(Loader, representation, namespace=None, name=None, options=None, **kwargs)
Use Loader to load a representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Loader | Loader | The loader class to trigger. | required |
representation | str or dict | The representation id or full representation as returned by the database. | required |
namespace | (str, Optional) | The namespace to assign. Defaults to None. | None |
name | (str, Optional) | The name to assign. Defaults to product name. | None |
options | (dict, Optional) | Additional options to pass on to the loader. | None |
Returns:
| Type | Description |
|---|---|
| The return of the |
Raises:
| Type | Description |
|---|---|
IncompatibleLoaderError | When the loader is not compatible with the representation. |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
loaders_from_repre_context(loaders, repre_context)
Return compatible loaders for by representaiton's context.
Source code in client/ayon_core/pipeline/load/utils.py
898 899 900 901 902 903 904 905 | |
loaders_from_representation(loaders, representation)
Return all compatible loaders for a representation.
Source code in client/ayon_core/pipeline/load/utils.py
926 927 928 929 930 931 932 933 934 | |
remove_container(container)
Remove a container
Source code in client/ayon_core/pipeline/load/utils.py
459 460 461 462 463 464 465 466 467 468 469 | |
switch_container(container, representation, loader_plugin=None)
Switch a container to representation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container | dict | container information | required |
representation | dict | representation entity | required |
Returns:
| Type | Description |
|---|---|
| return from function call |
Source code in client/ayon_core/pipeline/load/utils.py
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 | |
update_container(container, version=-1)
Update a container
Source code in client/ayon_core/pipeline/load/utils.py
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 | |