mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
use fps conversion function during synchronization
This commit is contained in:
parent
6a6ce4d5c5
commit
f88bf7b5be
2 changed files with 92 additions and 1 deletions
|
|
@ -25,6 +25,11 @@ from openpype_modules.ftrack.lib import (
|
|||
|
||||
BaseEvent
|
||||
)
|
||||
from openpype_modules.ftrack.lib.avalon_sync import (
|
||||
convert_to_fps,
|
||||
InvalidFpsValue,
|
||||
FPS_KEYS
|
||||
)
|
||||
from openpype.lib import CURRENT_DOC_SCHEMAS
|
||||
|
||||
|
||||
|
|
@ -1149,12 +1154,31 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
"description": ftrack_ent["description"]
|
||||
}
|
||||
}
|
||||
invalid_fps_items = []
|
||||
cust_attrs = self.get_cust_attr_values(ftrack_ent)
|
||||
for key, val in cust_attrs.items():
|
||||
if key.startswith("avalon_"):
|
||||
continue
|
||||
|
||||
if key in FPS_KEYS:
|
||||
try:
|
||||
val = convert_to_fps(val)
|
||||
except InvalidFpsValue:
|
||||
invalid_fps_items.append((ftrack_ent["id"], val))
|
||||
continue
|
||||
|
||||
final_entity["data"][key] = val
|
||||
|
||||
if invalid_fps_items:
|
||||
fps_msg = (
|
||||
"These entities have invalid fps value in custom attributes"
|
||||
)
|
||||
items = []
|
||||
for entity_id, value in invalid_fps_items:
|
||||
ent_path = self.get_ent_path(entity_id)
|
||||
items.append("{} - \"{}\"".format(ent_path, value))
|
||||
self.report_items["error"][fps_msg] = items
|
||||
|
||||
_mongo_id_str = cust_attrs.get(CUST_ATTR_ID_KEY)
|
||||
if _mongo_id_str:
|
||||
try:
|
||||
|
|
@ -2155,11 +2179,19 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
)
|
||||
|
||||
convert_types_by_id[attr_id] = convert_type
|
||||
default_value = attr["default"]
|
||||
if key in FPS_KEYS:
|
||||
try:
|
||||
default_value = convert_to_fps(default_value)
|
||||
except InvalidFpsValue:
|
||||
pass
|
||||
|
||||
entities_dict[ftrack_project_id]["hier_attrs"][key] = (
|
||||
attr["default"]
|
||||
)
|
||||
|
||||
# PREPARE DATA BEFORE THIS
|
||||
invalid_fps_items = []
|
||||
avalon_hier = []
|
||||
for item in values:
|
||||
value = item["value"]
|
||||
|
|
@ -2173,8 +2205,25 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
|
||||
if convert_type:
|
||||
value = convert_type(value)
|
||||
|
||||
if key in FPS_KEYS:
|
||||
try:
|
||||
value = convert_to_fps(value)
|
||||
except InvalidFpsValue:
|
||||
invalid_fps_items.append((entity_id, value))
|
||||
continue
|
||||
entities_dict[entity_id]["hier_attrs"][key] = value
|
||||
|
||||
if invalid_fps_items:
|
||||
fps_msg = (
|
||||
"These entities have invalid fps value in custom attributes"
|
||||
)
|
||||
items = []
|
||||
for entity_id, value in invalid_fps_items:
|
||||
ent_path = self.get_ent_path(entity_id)
|
||||
items.append("{} - \"{}\"".format(ent_path, value))
|
||||
self.report_items["error"][fps_msg] = items
|
||||
|
||||
# Get dictionary with not None hierarchical values to pull to childs
|
||||
project_values = {}
|
||||
for key, value in (
|
||||
|
|
|
|||
|
|
@ -1086,6 +1086,7 @@ class SyncEntitiesFactory:
|
|||
sync_ids
|
||||
)
|
||||
|
||||
invalid_fps_items = []
|
||||
for item in items:
|
||||
entity_id = item["entity_id"]
|
||||
attr_id = item["configuration_id"]
|
||||
|
|
@ -1098,8 +1099,24 @@ class SyncEntitiesFactory:
|
|||
value = item["value"]
|
||||
if convert_type:
|
||||
value = convert_type(value)
|
||||
|
||||
if key in FPS_KEYS:
|
||||
try:
|
||||
value = convert_to_fps(value)
|
||||
except InvalidFpsValue:
|
||||
invalid_fps_items.append((entity_id, value))
|
||||
self.entities_dict[entity_id][store_key][key] = value
|
||||
|
||||
if invalid_fps_items:
|
||||
fps_msg = (
|
||||
"These entities have invalid fps value in custom attributes"
|
||||
)
|
||||
items = []
|
||||
for entity_id, value in invalid_fps_items:
|
||||
ent_path = self.get_ent_path(entity_id)
|
||||
items.append("{} - \"{}\"".format(ent_path, value))
|
||||
self.report_items["error"][fps_msg] = items
|
||||
|
||||
# process hierarchical attributes
|
||||
self.set_hierarchical_attribute(
|
||||
hier_attrs, sync_ids, cust_attr_type_name_by_id
|
||||
|
|
@ -1132,8 +1149,15 @@ class SyncEntitiesFactory:
|
|||
if key.startswith("avalon_"):
|
||||
store_key = "avalon_attrs"
|
||||
|
||||
default_value = attr["default"]
|
||||
if key in FPS_KEYS:
|
||||
try:
|
||||
default_value = convert_to_fps(default_value)
|
||||
except InvalidFpsValue:
|
||||
pass
|
||||
|
||||
self.entities_dict[self.ft_project_id][store_key][key] = (
|
||||
attr["default"]
|
||||
default_value
|
||||
)
|
||||
|
||||
# Add attribute ids to entities dictionary
|
||||
|
|
@ -1175,6 +1199,7 @@ class SyncEntitiesFactory:
|
|||
True
|
||||
)
|
||||
|
||||
invalid_fps_items = []
|
||||
avalon_hier = []
|
||||
for item in items:
|
||||
value = item["value"]
|
||||
|
|
@ -1194,6 +1219,13 @@ class SyncEntitiesFactory:
|
|||
|
||||
entity_id = item["entity_id"]
|
||||
key = attribute_key_by_id[attr_id]
|
||||
if key in FPS_KEYS:
|
||||
try:
|
||||
value = convert_to_fps(value)
|
||||
except InvalidFpsValue:
|
||||
invalid_fps_items.append((entity_id, value))
|
||||
continue
|
||||
|
||||
if key.startswith("avalon_"):
|
||||
store_key = "avalon_attrs"
|
||||
avalon_hier.append(key)
|
||||
|
|
@ -1201,6 +1233,16 @@ class SyncEntitiesFactory:
|
|||
store_key = "hier_attrs"
|
||||
self.entities_dict[entity_id][store_key][key] = value
|
||||
|
||||
if invalid_fps_items:
|
||||
fps_msg = (
|
||||
"These entities have invalid fps value in custom attributes"
|
||||
)
|
||||
items = []
|
||||
for entity_id, value in invalid_fps_items:
|
||||
ent_path = self.get_ent_path(entity_id)
|
||||
items.append("{} - \"{}\"".format(ent_path, value))
|
||||
self.report_items["error"][fps_msg] = items
|
||||
|
||||
# Get dictionary with not None hierarchical values to pull to childs
|
||||
top_id = self.ft_project_id
|
||||
project_values = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue