lib
AYON lib functions.
AYONSecureRegistry
Store information using keyring.
Registry should be used for private data that should be available only for user.
All passed registry names will have added prefix AYON/
to easier identify which data were created by AYON.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name(str) | Name of registry used as identifier for data. | required |
Source code in client/ayon_core/lib/local_settings.py
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 |
|
delete_item(name)
Delete value stored in system's keyring.
See also Keyring module
_
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the item to be deleted. | required |
.. _Keyring module: https://github.com/jaraco/keyring
Source code in client/ayon_core/lib/local_settings.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
get_item(name, default=_PLACEHOLDER)
cached
Get value of sensitive item from system's keyring.
See also Keyring module
_
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the item. | required |
default | Any | Default value if item is not available. | _PLACEHOLDER |
Returns:
Name | Type | Description |
---|---|---|
value | str | Value of the item. |
Raises:
Type | Description |
---|---|
ValueError | If item doesn't exist and default is not defined. |
.. _Keyring module: https://github.com/jaraco/keyring
Source code in client/ayon_core/lib/local_settings.py
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 |
|
set_item(name, value)
Set sensitive item into system's keyring.
This uses Keyring module
_ to save sensitive stuff into system's keyring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the item. | required |
value | str | Value of the item. | required |
.. _Keyring module: https://github.com/jaraco/keyring
Source code in client/ayon_core/lib/local_settings.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
AYONSettingsRegistry
Bases: JSONSettingRegistry
Class handling AYON general settings registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | Optional[str] | Name of the registry. | None |
Source code in client/ayon_core/lib/local_settings.py
550 551 552 553 554 555 556 557 558 559 560 561 |
|
AbstractAttrDef
Abstraction of attribute definition.
Each attribute definition must have implemented validation and conversion method.
Attribute definition should have ability to return "default" value. That can be based on passed data into __init__
so is not abstracted to attribute.
QUESTION: How to force to set key
attribute?
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | str | Under which key will be attribute value stored. | required |
default | Any | Default value of an attribute. | required |
label | Optional[str] | Attribute label. | None |
tooltip | Optional[str] | Attribute tooltip. | None |
is_label_horizontal | Optional[bool] | UI specific argument. Specify if label is next to value input or ahead. | None |
visible | Optional[bool] | Item is shown to user (for UI purposes). | None |
enabled | Optional[bool] | Item is enabled (for UI purposes). | None |
hidden | Optional[bool] | DEPRECATED: Use 'visible' instead. | None |
disabled | Optional[bool] | DEPRECATED: Use 'enabled' instead. | None |
Source code in client/ayon_core/lib/attribute_definitions.py
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 |
|
type
abstractmethod
property
Attribute definition type also used as identifier of class.
Returns:
Name | Type | Description |
---|---|---|
str | str | Type of attribute definition. |
convert_value(value)
abstractmethod
Convert value to a valid one.
Convert passed value to a valid type. Use default if value can't be converted.
Source code in client/ayon_core/lib/attribute_definitions.py
238 239 240 241 242 243 244 245 246 |
|
deserialize(data)
classmethod
Recreate object from data.
Data can be received using 'serialize' method.
Source code in client/ayon_core/lib/attribute_definitions.py
270 271 272 273 274 275 276 277 278 279 280 |
|
is_value_valid(value)
abstractmethod
Check if value is valid.
This should return False if value is not valid based on definition type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Any | Value to validate based on definition type. | required |
Returns:
Name | Type | Description |
---|---|---|
bool | bool | True if value is valid. |
Source code in client/ayon_core/lib/attribute_definitions.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
serialize()
Serialize object to data so it's possible to recreate it.
Returns:
Type | Description |
---|---|
Dict[str, Any] | Dict[str, Any]: Serialized object that can be passed to 'deserialize' method. |
Source code in client/ayon_core/lib/attribute_definitions.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
|
BoolDef
Bases: AbstractAttrDef
Boolean representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default(bool) | Default value. Set to | required |
Source code in client/ayon_core/lib/attribute_definitions.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
|
CacheItem
Simple cache item with lifetime and default factory for default value.
Default factory should return default value that is used on init and on reset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default_factory | Optional[callable] | Function that returns default value used on init and on reset. | None |
lifetime | Optional[int] | Lifetime of the cache data in seconds. Default lifetime is 120 seconds. | None |
Source code in client/ayon_core/lib/cache.py
14 15 16 17 18 19 20 21 22 23 24 25 26 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 |
|
is_valid
property
Is cache valid to use.
Return
bool: True if cache is valid, False otherwise.
get_data()
Receive cached data.
Returns:
Name | Type | Description |
---|---|---|
Any | Any data that are cached. |
Source code in client/ayon_core/lib/cache.py
70 71 72 73 74 75 76 77 |
|
reset()
Set cache as invalid and reset data.
Source code in client/ayon_core/lib/cache.py
64 65 66 67 68 |
|
set_invalid()
Set cache as invalid.
Source code in client/ayon_core/lib/cache.py
59 60 61 62 |
|
set_lifetime(lifetime)
Change lifetime of cache item.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lifetime | int | Lifetime of the cache data in seconds. | required |
Source code in client/ayon_core/lib/cache.py
50 51 52 53 54 55 56 57 |
|
update_data(data)
Update cache data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | Any | Any data that are cached. | required |
Source code in client/ayon_core/lib/cache.py
79 80 81 82 83 84 85 86 87 |
|
EnumDef
Bases: AbstractAttrDef
Enumeration of items.
Enumeration of single item from items. Or list of items if multiselection is enabled.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | str | Key under which value is stored. | required |
items | EnumItemsInputType | Items definition that can be converted using 'prepare_enum_items'. | required |
default | Optional[Any] | Default value. Must be one key(value) from passed items or list of values for multiselection. | None |
multiselection | Optional[bool] | If True, multiselection is allowed. Output is list of selected items. | False |
placeholder | Optional[str] | Placeholder for UI purposes, only for multiselection enumeration. | None |
Source code in client/ayon_core/lib/attribute_definitions.py
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 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
|
is_value_valid(value)
Check if item is available in possible values.
Source code in client/ayon_core/lib/attribute_definitions.py
611 612 613 614 615 616 617 618 619 620 |
|
prepare_enum_items(items)
staticmethod
Convert items to unified structure.
Output is a list where each item is dictionary with 'value' and 'label'.
# Example output
[
{"label": "Option 1", "value": 1},
{"label": "Option 2", "value": 2},
{"label": "Option 3", "value": 3}
]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items | EnumItemsInputType | The items to convert. | required |
Returns:
Type | Description |
---|---|
List[EnumItemDict] | List[EnumItemDict]: Unified structure of items. |
Source code in client/ayon_core/lib/attribute_definitions.py
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 680 681 682 683 684 685 686 687 688 |
|
FileDef
Bases: AbstractAttrDef
File definition. It is possible to define filters of allowed file extensions and if supports folders. Args: single_item(bool): Allow only single path item. folders(bool): Allow folder paths. extensions(List[str]): Allow files with extensions. Empty list will allow all extensions and None will disable files completely. extensions_label(str): Custom label shown instead of extensions in UI. default(str, List[str]): Default value.
Source code in client/ayon_core/lib/attribute_definitions.py
962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 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 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 |
|
FileDefItem
Source code in client/ayon_core/lib/attribute_definitions.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 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 |
|
from_value(value, allow_sequences)
classmethod
Convert passed value to FileDefItem objects.
Returns:
Name | Type | Description |
---|---|---|
list | List[Self] | Created FileDefItem objects. |
Source code in client/ayon_core/lib/attribute_definitions.py
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 |
|
FormatObject
Object that can be used for formatting.
This is base that is valid for to be used in 'StringTemplate' value.
Source code in client/ayon_core/lib/path_templates.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
IniSettingRegistry
Bases: ASettingRegistry
Class using :mod:configparser
.
This class is using :mod:configparser
(ini) files to store items.
Source code in client/ayon_core/lib/local_settings.py
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 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 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 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 |
|
delete_item_from_section(section, name)
Delete item from section in ini file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section | str | Section name. | required |
name | str | Name of the item. | required |
Raises:
Type | Description |
---|---|
ValueError | If item doesn't exist. |
Source code in client/ayon_core/lib/local_settings.py
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 |
|
get_item(name)
Gets item from settings ini file.
This gets settings from DEFAULT
section of ini file as each item there must reside in some section.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the item. | required |
Returns:
Name | Type | Description |
---|---|---|
str | Value of item. |
Raises:
Type | Description |
---|---|
ValueError | If value doesn't exist. |
Source code in client/ayon_core/lib/local_settings.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
|
get_item_from_section(section, name)
cached
Get item from section of ini file.
This will read ini file and try to get item value from specified section. If that section or item doesn't exist, :exc:ValueError
is risen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section | str | Name of ini section. | required |
name | str | Name of the item. | required |
Returns:
Name | Type | Description |
---|---|---|
str | Item value. |
Raises:
Type | Description |
---|---|
ValueError | If value doesn't exist. |
Source code in client/ayon_core/lib/local_settings.py
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 |
|
set_item(name, value)
Set item to settings ini file.
This saves item to DEFAULT
section of ini as each item there must reside in some section.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the item. | required |
value | str | Value of the item. | required |
Source code in client/ayon_core/lib/local_settings.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
set_item_section(section, name, value)
Set item to specific section of ini registry.
If section doesn't exists, it is created.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section | str | Name of section. | required |
name | str | Name of the item. | required |
value | str | Value of the item. | required |
Source code in client/ayon_core/lib/local_settings.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
JSONSettingRegistry
Bases: ASettingRegistry
Class using json file as storage.
Source code in client/ayon_core/lib/local_settings.py
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 |
|
get_item(name)
Get item value from registry json.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the item. | required |
Returns:
Type | Description |
---|---|
value of the item |
Raises:
Type | Description |
---|---|
ValueError | If item is not found in registry file. |
Source code in client/ayon_core/lib/local_settings.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
|
set_item(name, value)
Set item and its value into json registry file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | name of the item. | required |
value | Any | value of the item. | required |
Source code in client/ayon_core/lib/local_settings.py
528 529 530 531 532 533 534 535 536 537 |
|
Logger
Source code in client/ayon_core/lib/log.py
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 |
|
get_process_data()
classmethod
Data about current process which should be same for all records.
Process data are used for each record sent to mongo database.
Source code in client/ayon_core/lib/log.py
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 |
|
get_process_name()
classmethod
Process name that is like "label" of a process.
AYON logging can be used from OpenPyppe itself of from hosts. Even in AYON process it's good to know if logs are from tray or from other cli commands. This should help to identify that information.
Source code in client/ayon_core/lib/log.py
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 |
|
set_process_name(process_name)
classmethod
Set process name for mongo logs.
Source code in client/ayon_core/lib/log.py
214 215 216 217 218 219 220 221 |
|
NestedCacheItem
Helper for cached items stored in nested structure.
Example
cache = NestedCacheItem(levels=2, default_factory=lambda: 0) cache["a"]["b"].is_valid False cache["a"]["b"].get_data() 0 cache["a"]["b"] = 1 cache["a"]["b"].is_valid True cache["a"]["b"].get_data() 1 cache.reset() cache["a"]["b"].is_valid False
Parameters:
Name | Type | Description | Default |
---|---|---|---|
levels | int | Number of nested levels where read cache is stored. | 1 |
default_factory | Optional[callable] | Function that returns default value used on init and on reset. | None |
lifetime | Optional[int] | Lifetime of the cache data in seconds. Default value is based on default value of 'CacheItem'. | None |
_init_info | Optional[InitInfo] | Private argument. Init info for nested cache where created from parent item. | None |
Source code in client/ayon_core/lib/cache.py
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 |
|
is_valid
property
Raise reasonable error when called on wrong level.
Raises:
Type | Description |
---|---|
AttributeError | If called on nested cache item. |
__getitem__(key)
Get cached data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | str | Key of the cache item. | required |
Returns:
Type | Description |
---|---|
Union[NestedCacheItem, CacheItem]: Cache item. |
Source code in client/ayon_core/lib/cache.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
__setitem__(key, value)
Update cached data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | str | Key of the cache item. | required |
value | Any | Any data that are cached. | required |
Source code in client/ayon_core/lib/cache.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
cached_count()
Amount of cached items.
Returns:
Name | Type | Description |
---|---|---|
int | Amount of cached items. |
Source code in client/ayon_core/lib/cache.py
181 182 183 184 185 186 187 188 |
|
clear_invalid()
Clear all invalid cache items.
Note
To clear all cache items use 'reset'.
Source code in client/ayon_core/lib/cache.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
clear_key(key)
Clear cached item by key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | str | Key of the cache item. | required |
Source code in client/ayon_core/lib/cache.py
190 191 192 193 194 195 196 197 |
|
get(key)
Get cached data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | str | Key of the cache item. | required |
Returns:
Type | Description |
---|---|
Union[NestedCacheItem, CacheItem]: Cache item. |
Source code in client/ayon_core/lib/cache.py
169 170 171 172 173 174 175 176 177 178 179 |
|
reset()
Reset cache.
Note
To clear only invalid cache items use 'clear_invalid'.
Source code in client/ayon_core/lib/cache.py
220 221 222 223 224 225 226 227 |
|
set_lifetime(lifetime)
Change lifetime of all children cache items.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lifetime | int | Lifetime of the cache data in seconds. | required |
Source code in client/ayon_core/lib/cache.py
229 230 231 232 233 234 235 236 237 238 |
|
NumberDef
Bases: AbstractAttrDef
Number definition.
Number can have defined minimum/maximum value and decimal points. Value is integer if decimals are 0.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
minimum(int, | float | Minimum possible value. | required |
maximum(int, | float | Maximum possible value. | required |
decimals(int) | Maximum decimal points of value. | required | |
default(int, | float | Default value for conversion. | required |
Source code in client/ayon_core/lib/attribute_definitions.py
372 373 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 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 |
|
StringTemplate
String that can be formatted.
Source code in client/ayon_core/lib/path_templates.py
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 |
|
format(data)
Figure out with whole formatting.
Separate advanced keys (*Like '{project[name]}') from string which must be formatted separately in case of missing or incomplete keys in data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | dict | Containing keys to be filled into template. | required |
Returns:
Name | Type | Description |
---|---|---|
TemplateResult | TemplateResult | Filled or partially filled template containing all data needed or missing for filling template. |
Source code in client/ayon_core/lib/path_templates.py
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 |
|
TemplateUnsolved
Bases: Exception
Exception for unsolved template when strict is set to True.
Source code in client/ayon_core/lib/path_templates.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
TextDef
Bases: AbstractAttrDef
Text definition.
Text can have multiline option so end-line characters are allowed regex validation can be applied placeholder for UI purposes and default value.
Regex validation is not part of attribute implementation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
multiline(bool) | Text has single or multiline support. | required | |
regex(str, | Pattern | Regex validation. | required |
placeholder(str) | UI placeholder for attribute. | required | |
default(str, | None | Default value. Empty string used when not defined. | required |
Source code in client/ayon_core/lib/attribute_definitions.py
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 |
|
ToolNotFoundError
Bases: Exception
Raised when tool arguments are not found.
Source code in client/ayon_core/lib/vendor_bin_utils.py
9 10 |
|
UnknownDef
Bases: AbstractAttrDef
Definition is not known because definition is not available.
This attribute can be used to keep existing data unchanged but does not have known definition of type.
Source code in client/ayon_core/lib/attribute_definitions.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
classes_from_module(superclass, module)
Return plug-ins from module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
superclass | superclass | Superclass of subclasses to look for | required |
module | ModuleType | Imported module where to look for 'superclass' subclasses. | required |
Returns:
Type | Description |
---|---|
List of plug-ins, or empty list if none is found. |
Source code in client/ayon_core/lib/python_module_tools.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
collect_frames(files)
Returns dict of source path and its frame, if from sequence
Uses clique as most precise solution, used when anatomy template that created files is not known.
Assumption is that frames are separated by '.', negative frames are not allowed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
files(list) | or (set with single value | list of source paths | required |
Returns:
Name | Type | Description |
---|---|---|
dict | {'/folder/product_v001.0001.png': '0001', ....} |
Source code in client/ayon_core/lib/path_tools.py
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 |
|
compile_list_of_regexes(in_list)
Convert strings in entered list to compiled regex objects.
Source code in client/ayon_core/lib/profiles_filtering.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
convert_ffprobe_fps_to_float(value)
Convert string value of frame rate to float.
Copy of 'convert_ffprobe_fps_value' which raises exceptions on invalid value, does not convert value to string and does not return "Unknown" string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | str | Value to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
Float | Converted frame rate in float. If divisor in value is '0' then '0.0' is returned. |
Raises:
Type | Description |
---|---|
ValueError | Passed value is invalid for conversion. |
Source code in client/ayon_core/lib/transcoding.py
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 |
|
convert_ffprobe_fps_value(str_value)
Returns (str) value of fps from ffprobe frame format (120/1)
Source code in client/ayon_core/lib/transcoding.py
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
|
convert_for_ffmpeg(first_input_path, output_dir, input_frame_start=None, input_frame_end=None, logger=None)
Convert source file to format supported in ffmpeg.
Currently can convert only exrs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
first_input_path | str | Path to first file of a sequence or a single file path for non-sequential input. | required |
output_dir | str | Path to directory where output will be rendered. Must not be same as input's directory. | required |
input_frame_start | int | Frame start of input. | None |
input_frame_end | int | Frame end of input. | None |
logger | Logger | Logger used for logging. | None |
Raises:
Type | Description |
---|---|
ValueError | If input filepath has extension not supported by function. Currently is supported only ".exr" extension. |
Source code in client/ayon_core/lib/transcoding.py
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 |
|
convert_input_paths_for_ffmpeg(input_paths, output_dir, logger=None)
Convert source file to format supported in ffmpeg.
Currently can convert only exrs. The input filepaths should be files with same type. Information about input is loaded only from first found file.
Filenames of input files are kept so make sure that output directory is not the same directory as input files have. - This way it can handle gaps and can keep input filenames without handling frame template
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_paths | str | Paths that should be converted. It is expected that contains single file or image sequence of same type. | required |
output_dir | str | Path to directory where output will be rendered. Must not be same as input's directory. | required |
logger | Logger | Logger used for logging. | None |
Raises:
Type | Description |
---|---|
ValueError | If input filepath has extension not supported by function. Currently is supported only ".exr" extension. |
Source code in client/ayon_core/lib/transcoding.py
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 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 |
|
create_hard_link(src_path, dst_path)
Create hardlink of file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_path(str) | Full path to a file which is used as source for hardlink. | required | |
dst_path(str) | Full path to a file where a link of source will be added. | required |
Source code in client/ayon_core/lib/path_tools.py
31 32 33 34 35 36 37 38 39 40 |
|
emit_event(topic, data=None, source=None)
Emit event with topic and data.
Arg
topic(str): Event's topic. data(dict): Event's additional data. Optional. source(str): Who emitted the topic. Optional.
Returns:
Name | Type | Description |
---|---|---|
Event | Object of event that was emitted. |
Source code in client/ayon_core/lib/events.py
709 710 711 712 713 714 715 716 717 718 719 720 721 |
|
env_value_to_bool(env_key=None, value=None, default=False)
Convert environment variable value to boolean.
Function is based on value of the environemt variable. Value is lowered so function is not case sensitive.
Returns:
Name | Type | Description |
---|---|---|
bool | bool | If value match to one of ["true", "yes", "1"] result if True but if value match to ["false", "no", "0"] result is False else default value is returned. |
Source code in client/ayon_core/lib/env_tools.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 |
|
filter_profiles(profiles_data, key_values, keys_order=None, logger=None)
Filter profiles by entered key -> values.
Profile if marked with score for each key/value from key_values
with points -1, 0 or 1. - if profile contain the key and profile's value contain value from key_values
then profile gets 1 point - if profile does not contain the key or profile's value is empty or contain "" then got 0 point - if profile contain the key, profile's value is not empty and does not contain "" and value from key_values
is not available in the value then got -1 point
If profile gets -1 point at any time then is skipped and not used for output. Profile with higher score is returned. If there are multiple profiles with same score then first in order is used (order of profiles matter).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
profiles_data | list | Profile definitions as dictionaries. | required |
key_values | dict | Mapping of Key <-> Value. Key is checked if is available in profile and if Value is matching it's values. | required |
keys_order | (list, tuple) | Order of keys from | None |
logger | Logger | Optionally can be passed different logger. | None |
Returns:
Type | Description |
---|---|
dict/None: Return most matching profile or None if none of profiles match at least one criteria. |
Source code in client/ayon_core/lib/profiles_filtering.py
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 |
|
find_executable(executable)
Find full path to executable.
Also tries additional extensions if passed executable does not contain one.
Paths where it is looked for executable is defined by 'PATH' environment variable, 'os.confstr("CS_PATH")' or 'os.defpath'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
executable(str) | Name of executable with or without extension. Can be path to file. | required |
Returns:
Type | Description |
---|---|
Union[str, None]: Full path to executable with extension which was found otherwise None. |
Source code in client/ayon_core/lib/vendor_bin_utils.py
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 |
|
format_file_size(file_size, suffix=None)
Returns formatted string with size in appropriate unit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_size | int | Size of file in bytes. | required |
suffix | str | Suffix for formatted size. Default is 'B' (as bytes). | None |
Returns:
Name | Type | Description |
---|---|---|
str | Formatted size using proper unit and passed suffix (e.g. 7 MiB). |
Source code in client/ayon_core/lib/path_tools.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
get_addons_resources_dir(addon_name, *args)
Get directory for storing resources for addons.
Some addons might need to store ad-hoc resources that are not part of addon client package (e.g. because of size). Studio might define dedicated directory to store them with 'AYON_ADDONS_RESOURCES_DIR' environment variable. By default, is used 'addons_resources' in launcher storage (might be shared across platforms).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
addon_name | str | Addon name. | required |
*args | str | Subfolders in resources directory. | () |
Returns:
Name | Type | Description |
---|---|---|
str | str | Path to resources directory. |
Source code in client/ayon_core/lib/local_settings.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
get_ayon_launcher_args(*args)
Arguments to run AYON launcher process.
Arguments for subprocess when need to spawn new AYON launcher process.
Reasons
AYON launcher started from code has different executable set to virtual env python and must have path to script as first argument which is not needed for built application.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args | str | Any arguments that will be added after executables. | () |
Returns:
Type | Description |
---|---|
list[str]: List of arguments to run AYON launcher process. |
Source code in client/ayon_core/lib/execute.py
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 356 357 358 359 |
|
get_ayon_username()
AYON username used for templates and publishing.
Uses curet ayon api username.
Returns:
Name | Type | Description |
---|---|---|
str | Username. |
Source code in client/ayon_core/lib/local_settings.py
591 592 593 594 595 596 597 598 599 600 |
|
get_datetime_data(datetime_obj=None)
Returns current datetime data as dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datetime_obj | datetime | Specific datetime object | None |
Returns:
Name | Type | Description |
---|---|---|
dict | prepared date & time data |
Available keys
"d" - Mon
, ... "dddd" - Monday
, ... "m" - 1
if January "mm" - Jan
, ... "mmmm" - January
, ... "yy" - 19
, 20
, ... "yyyy" - 2019
, 2020
, ... "H" -
Source code in client/ayon_core/lib/dateutils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 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 |
|
get_ffmpeg_codec_args(ffprobe_data, source_ffmpeg_cmd=None, logger=None)
Copy codec from input metadata for output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ffprobe_data(dict) | Data received from ffprobe. | required | |
source_ffmpeg_cmd(str) | Command that created input if available. | required |
Source code in client/ayon_core/lib/transcoding.py
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 |
|
get_ffmpeg_format_args(ffprobe_data, source_ffmpeg_cmd=None)
Copy format from input metadata for output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ffprobe_data(dict) | Data received from ffprobe. | required | |
source_ffmpeg_cmd(str) | Command that created input if available. | required |
Source code in client/ayon_core/lib/transcoding.py
838 839 840 841 842 843 844 845 846 847 848 |
|
get_ffmpeg_tool_args(tool_name, *extra_args)
Arguments to launch FFmpeg tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name | str | Tool name 'ffmpeg', 'ffprobe', exc. | required |
*extra_args | str | Extra arguments to add to after tool arguments. | () |
Returns:
Type | Description |
---|---|
list[str]: List of arguments. |
Source code in client/ayon_core/lib/vendor_bin_utils.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
get_ffmpeg_tool_path(tool='ffmpeg')
Path to vendorized FFmpeg executable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool | str | Tool name 'ffmpeg', 'ffprobe', etc. Default is "ffmpeg". | 'ffmpeg' |
Returns:
Name | Type | Description |
---|---|---|
str | Full path to ffmpeg executable. |
Source code in client/ayon_core/lib/vendor_bin_utils.py
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 |
|
get_ffprobe_data(path_to_file, logger=None)
Load data about entered filepath via ffprobe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_to_file | str | absolute path | required |
logger | Logger | injected logger, if empty new is created | None |
Source code in client/ayon_core/lib/transcoding.py
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 |
|
get_ffprobe_streams(path_to_file, logger=None)
Load streams from entered filepath via ffprobe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_to_file | str | absolute path | required |
logger | Logger | injected logger, if empty new is created | None |
Source code in client/ayon_core/lib/transcoding.py
828 829 830 831 832 833 834 835 |
|
get_last_version_from_path(path_dir, filter)
Find last version of given directory content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_dir | str | directory path | required |
filter | list | list of strings used as file name filter | required |
Returns:
Name | Type | Description |
---|---|---|
str | file name with last version |
Example
last_version_file = get_last_version_from_path( "/project/shots/shot01/work", ["shot01", "compositing", "nk"])
Source code in client/ayon_core/lib/path_tools.py
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 |
|
get_launcher_local_dir(*subdirs)
Get local directory for launcher.
Local directory is used for storing machine or user specific data.
The location is user specific.
Note
This function should be called at least once on bootstrap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*subdirs | str | Subdirectories relative to local dir. | () |
Returns:
Name | Type | Description |
---|---|---|
str | str | Path to local directory. |
Source code in client/ayon_core/lib/local_settings.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
get_launcher_storage_dir(*subdirs)
Get storage directory for launcher.
Storage directory is used for storing shims, addons, dependencies, etc.
It is not recommended, but the location can be shared across multiple machines.
Note
This function should be called at least once on bootstrap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*subdirs | str | Subdirectories relative to storage dir. | () |
Returns:
Name | Type | Description |
---|---|---|
str | str | Path to storage directory. |
Source code in client/ayon_core/lib/local_settings.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_linux_launcher_args(*args)
Path to application mid process executable.
This function should be able as arguments are different when used from code and build.
It is possible that this function is used in AYON build which does not have yet the new executable. In that case 'None' is returned.
Todos
Replace by script in scripts for ayon-launcher.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args | iterable | List of additional arguments added after executable argument. | () |
Returns:
Name | Type | Description |
---|---|---|
list | Executables with possible positional argument to script when called from code. |
Source code in client/ayon_core/lib/execute.py
362 363 364 365 366 367 368 369 370 371 372 373 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 403 |
|
get_local_site_id()
Get local site identifier.
Identifier is created if does not exist yet.
Source code in client/ayon_core/lib/local_settings.py
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 |
|
get_media_mime_type(filepath)
Determine Mime-Type of a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath | str | Path to file. | required |
Returns:
Type | Description |
---|---|
Optional[str] | Optional[str]: Mime type or None if is unknown mime type. |
Source code in client/ayon_core/lib/transcoding.py
1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 |
|
get_oiio_tool_args(tool_name, *extra_args)
Arguments to launch OpenImageIO tool.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool_name | str | Tool name 'oiiotool', 'maketx', etc. | required |
*extra_args | str | Extra arguments to add to after tool arguments. | () |
Returns:
Type | Description |
---|---|
list[str]: List of arguments. |
Source code in client/ayon_core/lib/vendor_bin_utils.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
get_oiio_tools_path(tool='oiiotool')
Path to OpenImageIO tool executables.
On Windows it adds .exe extension if missing from tool argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tool | string | Tool name 'oiiotool', 'maketx', etc. Default is "oiiotool". | 'oiiotool' |
Source code in client/ayon_core/lib/vendor_bin_utils.py
286 287 288 289 290 291 292 293 294 295 296 297 298 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 |
|
get_paths_from_environ(env_key=None, env_value=None, return_first=False)
Return existing paths from specific environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env_key | Optional[str] | Environment key where should look for paths. | None |
env_value | Optional[str] | Value of environment variable. Argument | None |
return_first | bool | Return first found value or return list of found paths. | False |
Returns:
Type | Description |
---|---|
Optional[Union[str, list[str]]] | Optional[Union[str, list[str]]]: Result of found path/s. |
Source code in client/ayon_core/lib/env_tools.py
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 |
|
get_rescaled_command_arguments(application, input_path, target_width, target_height, target_par=None, bg_color=None, log=None)
Get command arguments for rescaling input to target size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
application | str | Application for which command should be created. Currently supported are "ffmpeg" and "oiiotool". | required |
input_path | str | Path to input file. | required |
target_width | int | Width of target. | required |
target_height | int | Height of target. | required |
target_par | Optional[float] | Pixel aspect ratio of target. | None |
bg_color | Optional[list[int]] | List of 8bit int values for background color. Should be in range 0 - 255. | None |
log | Optional[Logger] | Logger used for logging. | None |
Returns:
Type | Description |
---|---|
list[str]: List of command arguments. |
Source code in client/ayon_core/lib/transcoding.py
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
|
get_timestamp(datetime_obj=None)
Get standardized timestamp from datetime object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
datetime_obj | datetime | Object of datetime. Current time is used if not passed. | None |
Source code in client/ayon_core/lib/dateutils.py
79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
get_transcode_temp_directory()
Creates temporary folder for transcoding.
Its local, in case of farm it is 'local' to the farm machine.
Should be much faster, needs to be cleaned up later.
Source code in client/ayon_core/lib/transcoding.py
70 71 72 73 74 75 76 77 78 79 |
|
get_version_from_path(file)
Find version number in file path string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file | str | file path | required |
Returns:
Name | Type | Description |
---|---|---|
str | version number in string ('001') |
Source code in client/ayon_core/lib/path_tools.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
import_filepath(filepath, module_name=None, sys_module_name=None)
Import python file as python module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath | str | Path to python file. | required |
module_name | str | Name of loaded module. Only for Python 3. By default is filled with filename of filepath. | None |
sys_module_name | str | Name of module in | None |
Todo (antirotor): We should add the module to the sys.modules always but we need to be careful about it and test it properly.
Source code in client/ayon_core/lib/python_module_tools.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
import_module_from_dirpath(dirpath, folder_name, dst_module_name=None)
Import passed directory as a python module.
Imported module can be assigned as a child attribute of already loaded module from sys.modules
if has support of setattr
. That is not default behavior of python modules so parent module must be a custom module with that ability.
It is not possible to reimport already cached module. If you need to reimport module you have to remove it from caches manually.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dirpath | str | Parent directory path of loaded folder. | required |
folder_name | str | Folder name which should be imported inside passed directory. | required |
dst_module_name | str | Parent module name under which can be loaded module added. | None |
Source code in client/ayon_core/lib/python_module_tools.py
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 |
|
initialize_ayon_connection(force=False)
Initialize global AYON api connection.
Create global connection in ayon_api module and set site id and client version. Is silently skipped if already happened.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force | Optional[bool] | Force reinitialize connection. Defaults to False. | False |
Source code in client/ayon_core/lib/ayon_connection.py
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 |
|
is_dev_mode_enabled()
Dev mode is enabled in AYON.
Returns:
Name | Type | Description |
---|---|---|
bool | True if dev mode is enabled. |
Source code in client/ayon_core/lib/ayon_info.py
99 100 101 102 103 104 105 106 |
|
is_func_signature_supported(func, *args, **kwargs)
Check if a function signature supports passed args and kwargs.
This check does not actually call the function, just look if function can be called with the arguments.
Notes
This does NOT check if the function would work with passed arguments only if they can be passed in. If function have args, *kwargs in parameters, this will always return 'True'.
Example
def my_function(my_number): ... return my_number + 1 ... is_func_signature_supported(my_function, 1) True is_func_signature_supported(my_function, 1, 2) False is_func_signature_supported(my_function, my_number=1) True is_func_signature_supported(my_function, number=1) False is_func_signature_supported(my_function, "string") True def my_other_function(args, kwargs): ... my_function(args, **kwargs) ... is_func_signature_supported( ... my_other_function, ... "string", ... 1, ... other=None ... ) True
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func | Callable | A function where the signature should be tested. | required |
*args | Any | Positional arguments for function signature. | () |
**kwargs | Any | Keyword arguments for function signature. | {} |
Returns:
Name | Type | Description |
---|---|---|
bool | Function can pass in arguments. |
Source code in client/ayon_core/lib/python_module_tools.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 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
is_in_ayon_launcher_process()
Determine if current process is running from AYON launcher.
Returns:
Name | Type | Description |
---|---|---|
bool | True if running from AYON launcher. |
Source code in client/ayon_core/lib/ayon_info.py
29 30 31 32 33 34 35 36 37 38 |
|
is_in_tests()
Process is running in automatic tests mode.
Returns:
Name | Type | Description |
---|---|---|
bool | True if running in tests. |
Source code in client/ayon_core/lib/ayon_info.py
89 90 91 92 93 94 95 96 |
|
is_oiio_supported()
Checks if oiiotool is configured for this platform.
Returns:
Name | Type | Description |
---|---|---|
bool | OIIO tool executable is available. |
Source code in client/ayon_core/lib/vendor_bin_utils.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
|
is_running_from_build()
Determine if current process is running from build or code.
Returns:
Name | Type | Description |
---|---|---|
bool | True if running from build. |
Source code in client/ayon_core/lib/ayon_info.py
41 42 43 44 45 46 47 48 49 50 51 52 |
|
is_using_ayon_console()
AYON launcher console executable is used.
This function make sense only on Windows platform. For other platforms always returns True. True is also returned if process is running from code.
AYON launcher on windows has 2 executable files. First 'ayon_console.exe' works as 'python.exe' executable, the second 'ayon.exe' works as 'pythonw.exe' executable. The difference is way how stdout/stderr is handled (especially when calling subprocess).
Returns:
Name | Type | Description |
---|---|---|
bool | True if console executable is used. |
Source code in client/ayon_core/lib/ayon_info.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
modules_from_path(folder_path)
Get python scripts as modules from a path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | str | Path to folder containing python scripts. | required |
Returns:
Type | Description |
---|---|
tuple |
Source code in client/ayon_core/lib/python_module_tools.py
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 |
|
path_to_subprocess_arg(path)
Prepare path for subprocess arguments.
Returned path can be wrapped with quotes or kept as is.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path | str | Path to be converted. | required |
Returns:
Name | Type | Description |
---|---|---|
str | Converted path. |
Source code in client/ayon_core/lib/execute.py
317 318 319 320 321 322 323 324 325 326 327 328 |
|
prepare_template_data(fill_pairs)
Prepares formatted data for filling template.
It produces multiple variants of keys (key, Key, KEY) to control format of filled template.
Example
src_data = { ... "host": "maya", ... } output = prepare_template_data(src_data) sorted(list(output.items())) # sort & list conversion for tests [('HOST', 'MAYA'), ('Host', 'Maya'), ('host', 'maya')]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fill_pairs | Union[dict[str, Any], Iterable[Tuple[str, Any]]] | The value that are prepared for template. | required |
Returns:
Type | Description |
---|---|
dict[str, str]: Prepared values for template. |
Source code in client/ayon_core/lib/plugin_tools.py
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 |
|
recursive_bases_from_class(klass)
Extract all bases from entered class.
Source code in client/ayon_core/lib/python_module_tools.py
107 108 109 110 111 112 113 114 |
|
register_event_callback(topic, callback)
Add callback that will be executed on specific topic.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topic(str) | Topic on which will callback be triggered. | required | |
callback(function) | Callback that will be triggered when a topic is triggered. Callback should expect none or 1 argument where | required |
Returns:
Name | Type | Description |
---|---|---|
EventCallback | Object wrapping the callback. It can be used to enable/disable listening to a topic or remove the callback from the topic completely. |
Source code in client/ayon_core/lib/events.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
|
run_ayon_launcher_process(*args, add_sys_paths=False, **kwargs)
Execute AYON process with passed arguments and wait.
Wrapper for 'run_process' which prepends AYON executable arguments before passed arguments and define environments if are not passed.
Values from 'os.environ' are used for environments if are not passed. They are cleaned using 'clean_envs_for_ayon_process' function.
Example:
run_ayon_process("run", "<path to .py script>")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args | str | ayon-launcher cli arguments. | () |
**kwargs | Any | Keyword arguments for subprocess.Popen. | {} |
Returns:
Name | Type | Description |
---|---|---|
str | Full output of subprocess concatenated stdout and stderr. |
Source code in client/ayon_core/lib/execute.py
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 |
|
run_detached_process(args, **kwargs)
Execute process with passed arguments as separated process.
Example
run_detached_process("run", "./path_to.py")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args | Iterable[str] | AYON cli arguments. | required |
**kwargs | dict | Keyword arguments for subprocess.Popen. | {} |
Returns:
Type | Description |
---|---|
subprocess.Popen: Pointer to launched process but it is possible that launched process is already killed (on linux). |
Source code in client/ayon_core/lib/execute.py
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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
run_subprocess(*args, **kwargs)
Convenience method for getting output errors for subprocess.
Output logged when process finish.
Entered arguments and keyword arguments are passed to subprocess Popen.
On windows are 'creationflags' filled with flags that should cause ignore creation of new window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args | Variable length argument list passed to Popen. | () | |
**kwargs | Arbitrary keyword arguments passed to Popen. Is possible to pass | {} |
Returns:
Name | Type | Description |
---|---|---|
str | Full output of subprocess concatenated stdout and stderr. |
Raises:
Type | Description |
---|---|
RuntimeError | Exception is raised if process finished with nonzero return code. |
Source code in client/ayon_core/lib/execute.py
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 |
|
should_convert_for_ffmpeg(src_filepath)
Find out if input should be converted for ffmpeg.
Currently cares only about exr inputs and is based on OpenImageIO.
Returns:
Type | Description |
---|---|
bool/NoneType: True if should be converted, False if should not and None if can't determine. |
Source code in client/ayon_core/lib/transcoding.py
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 |
|
source_hash(filepath, *args)
Generate simple identifier for a source file. This is used to identify whether a source file has previously been processe into the pipeline, e.g. a texture. The hash is based on source filepath, modification time and file size. This is only used to identify whether a specific source file was already published before from the same location with the same modification date. We opt to do it this way as opposed to Avalanch C4 hash as this is much faster and predictable enough for all our production use cases. Args: filepath (str): The source file path. You can specify additional arguments in the function to allow for specific 'processing' values to be included.
Source code in client/ayon_core/lib/plugin_tools.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
version_up(filepath)
Version up filepath to a new non-existing version.
Parses for a version identifier like _v001
or .v001
When no version present _v001 is appended as suffix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath | str | full url | required |
Returns:
Type | Description |
---|---|
str | filepath with increased version number |
Source code in client/ayon_core/lib/path_tools.py
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 |
|