Merge pull request #2103 from pypeclub/bugfix/ftrack_custom_attributes_on_save

Ftrack: Project settings save custom attributes skip unknown attributes
This commit is contained in:
Jakub Trllo 2021-10-05 13:28:05 +02:00 committed by GitHub
commit 6c8bbdb40c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

View file

@ -10,6 +10,7 @@ from openpype_modules.ftrack.lib import (
CUST_ATTR_GROUP,
CUST_ATTR_TOOLS,
CUST_ATTR_APPLICATIONS,
CUST_ATTR_INTENT,
default_custom_attributes_definition,
app_definitions_from_app_manager,
@ -431,7 +432,7 @@ class CustomAttributes(BaseAction):
intent_custom_attr_data = {
"label": "Intent",
"key": "intent",
"key": CUST_ATTR_INTENT,
"type": "enumerator",
"entity_type": "assetversion",
"group": CUST_ATTR_GROUP,

View file

@ -230,7 +230,13 @@ class FtrackModule(
return
import ftrack_api
from openpype_modules.ftrack.lib import get_openpype_attr
from openpype_modules.ftrack.lib import (
get_openpype_attr,
default_custom_attributes_definition,
CUST_ATTR_TOOLS,
CUST_ATTR_APPLICATIONS,
CUST_ATTR_INTENT
)
try:
session = self.create_ftrack_session()
@ -255,6 +261,15 @@ class FtrackModule(
project_id = project_entity["id"]
ca_defs = default_custom_attributes_definition()
hierarchical_attrs = ca_defs.get("is_hierarchical") or {}
project_attrs = ca_defs.get("show") or {}
ca_keys = (
set(hierarchical_attrs.keys())
| set(project_attrs.keys())
| {CUST_ATTR_TOOLS, CUST_ATTR_APPLICATIONS, CUST_ATTR_INTENT}
)
cust_attr, hier_attr = get_openpype_attr(session)
cust_attr_by_key = {attr["key"]: attr for attr in cust_attr}
hier_attrs_by_key = {attr["key"]: attr for attr in hier_attr}
@ -262,6 +277,9 @@ class FtrackModule(
failed = {}
missing = {}
for key, value in attributes_changes.items():
if key not in ca_keys:
continue
configuration = hier_attrs_by_key.get(key)
if not configuration:
configuration = cust_attr_by_key.get(key)

View file

@ -3,7 +3,8 @@ from .constants import (
CUST_ATTR_AUTO_SYNC,
CUST_ATTR_GROUP,
CUST_ATTR_TOOLS,
CUST_ATTR_APPLICATIONS
CUST_ATTR_APPLICATIONS,
CUST_ATTR_INTENT
)
from .settings import (
get_ftrack_event_mongo_info

View file

@ -10,3 +10,5 @@ CUST_ATTR_AUTO_SYNC = "avalon_auto_sync"
CUST_ATTR_APPLICATIONS = "applications"
# Environment tools custom attribute
CUST_ATTR_TOOLS = "tools_env"
# Intent custom attribute name
CUST_ATTR_INTENT = "intent"