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

Commit

Permalink
Merge pull request #5853 from ynput/enhancement/OP-7277_Ftrack-Concur…
Browse files Browse the repository at this point in the history
…rent-event-server-for-OP-and-Ayon

Ftrack: Events are not processed if project is not available in OpenPype
  • Loading branch information
iLLiCiTiT authored Nov 7, 2023
2 parents 3999be0 + bd8638c commit ecc65d1
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import collections

from openpype.client import get_project
from openpype_modules.ftrack.lib import BaseEvent


Expand Down Expand Up @@ -73,8 +76,21 @@ def launch(self, session, event):
if not self.task_status_map:
return

entities_info = self.filter_event_ents(event)
if not entities_info:
filtered_entities_info = self.filter_entities_info(event)
if not filtered_entities_info:
return

for project_id, entities_info in filtered_entities_info.items():
self.process_by_project(session, event, project_id, entities_info)

def process_by_project(self, session, event, project_id, entities_info):
project_name = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug(
f"Project '{project_name}' not found in OpenPype. Skipping"
)
return

entity_ids = []
Expand Down Expand Up @@ -154,18 +170,18 @@ def launch(self, session, event):
exc_info=True
)

def filter_event_ents(self, event):
filtered_ents = []
for entity in event["data"].get("entities", []):
def filter_entities_info(self, event):
filtered_entities_info = collections.defaultdict(list)
for entity_info in event["data"].get("entities", []):
# Care only about add actions
if entity.get("action") != "add":
if entity_info.get("action") != "add":
continue

# Filter AssetVersions
if entity["entityType"] != "assetversion":
if entity_info["entityType"] != "assetversion":
continue

entity_changes = entity.get("changes") or {}
entity_changes = entity_info.get("changes") or {}

# Check if version of Asset Version is `1`
version_num = entity_changes.get("version", {}).get("new")
Expand All @@ -177,9 +193,18 @@ def filter_event_ents(self, event):
if not task_id:
continue

filtered_ents.append(entity)
project_id = None
for parent_item in reversed(entity_info["parents"]):
if parent_item["entityType"] == "show":
project_id = parent_item["entityId"]
break

if project_id is None:
continue

filtered_entities_info[project_id].append(entity_info)

return filtered_ents
return filtered_entities_info


def register(session):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import collections

from openpype.client import get_project
from openpype_modules.ftrack.lib import BaseEvent


Expand Down Expand Up @@ -99,6 +101,10 @@ def process_by_project(self, session, event, project_id, _entities_info):
project_name = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug("Project not found in OpenPype. Skipping")
return

# Load settings
project_settings = self.get_project_settings_from_event(
event, project_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from typing import Any

import ftrack_api

from openpype.client import get_project
from openpype_modules.ftrack.lib import (
BaseEvent,
query_custom_attributes,
Expand Down Expand Up @@ -139,6 +141,10 @@ def _get_handler_project_settings(
project_name: str = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug("Project not found in OpenPype. Skipping")
return set(), set()

# Load settings
project_settings: dict[str, Any] = (
self.get_project_settings_from_event(event, project_name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import collections

from openpype.client import get_project
from openpype_modules.ftrack.lib import BaseEvent


Expand Down Expand Up @@ -60,6 +62,10 @@ def process_by_project(self, session, event, project_id, entities_info):
project_name = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug("Project not found in OpenPype. Skipping")
return

# Load settings
project_settings = self.get_project_settings_from_event(
event, project_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import collections

from openpype.client import get_project
from openpype_modules.ftrack.lib import BaseEvent


Expand Down Expand Up @@ -102,6 +104,10 @@ def process_by_project(self, session, event, project_id, entities_info):
project_name = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug("Project not found in OpenPype. Skipping")
return

# Load settings
project_settings = self.get_project_settings_from_event(
event, project_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import collections

from openpype.client import get_project
from openpype_modules.ftrack.lib import BaseEvent


Expand All @@ -22,6 +24,10 @@ def process_project_entities(
project_name = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug("Project not found in OpenPype. Skipping")
return

# Load settings
project_settings = self.get_project_settings_from_event(
event, project_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from openpype.client import get_project
from openpype_modules.ftrack.lib import BaseEvent


Expand Down Expand Up @@ -50,6 +51,10 @@ def process_by_project(self, session, event, project_id, entities_info):
project_name = self.get_project_name_from_event(
session, event, project_id
)
if get_project(project_name) is None:
self.log.debug("Project not found in OpenPype. Skipping")
return

# Load settings
project_settings = self.get_project_settings_from_event(
event, project_name
Expand Down

0 comments on commit ecc65d1

Please sign in to comment.