Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Ftrack: Check existence of object type on recreation #2404

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions openpype/modules/default_modules/ftrack/lib/avalon_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ def launch_setup(self, project_full_name):
self._subsets_by_parent_id = None
self._changeability_by_mongo_id = None

self._object_types_by_name = None

self.all_filtered_entities = {}
self.filtered_ids = []
self.not_selected_ids = []
Expand Down Expand Up @@ -651,6 +653,18 @@ def changeability_by_mongo_id(self):
self._bubble_changeability(list(self.subsets_by_parent_id.keys()))
return self._changeability_by_mongo_id

@property
def object_types_by_name(self):
if self._object_types_by_name is None:
object_types_by_name = self.session.query(
"select id, name from ObjectType"
).all()
self._object_types_by_name = {
object_type["name"]: object_type
for object_type in object_types_by_name
}
return self._object_types_by_name

@property
def all_ftrack_names(self):
"""
Expand Down Expand Up @@ -880,10 +894,7 @@ def set_cutom_attributes(self):
custom_attrs, hier_attrs = get_openpype_attr(
self.session, query_keys=self.cust_attr_query_keys
)
ent_types = self.session.query("select id, name from ObjectType").all()
ent_types_by_name = {
ent_type["name"]: ent_type["id"] for ent_type in ent_types
}
ent_types_by_name = self.object_types_by_name
# Custom attribute types
cust_attr_types = self.session.query(
"select id, name from CustomAttributeType"
Expand Down Expand Up @@ -2491,7 +2502,13 @@ def create_ftrack_ent_from_avalon_ent(self, av_entity, parent_id):
parent_entity = self.entities_dict[parent_id]["entity"]

_name = av_entity["name"]
_type = av_entity["data"].get("entityType", "folder")
_type = av_entity["data"].get("entityType")
# Check existence of object type
if _type and _type not in self.object_types_by_name:
_type = None

if not _type:
_type = "Folder"

self.log.debug((
"Re-ceating deleted entity {} <{}>"
Expand Down