OP-3909 - use caching function from creator

In between cache function was extracted into creator_plugins, use this to standardize betwen different hosts.
This commit is contained in:
Petr Kalis 2022-11-03 10:46:20 +01:00
parent 313180d617
commit adb683bdfc
3 changed files with 11 additions and 23 deletions

View file

@ -1,5 +1,4 @@
import os
import collections
from Qt import QtWidgets
import pyblish.api
@ -291,21 +290,3 @@ def containerise(name,
stub.imprint(comp.id, data)
return comp
def cache_and_get_instances(creator):
"""Cache instances in shared data.
Args:
creator (Creator): Plugin which would like to get instances from host.
Returns:
Dict[str, Dict[str, Any]]: Cached instances list from host
implementation.
"""
shared_key = "openpype.aftereffects.instances"
if shared_key not in creator.collection_shared_data:
value = collections.defaultdict(list)
for instance in creator.list_instances():
identifier = instance["creator_identifier"]
value[identifier].append(instance)
creator.collection_shared_data[shared_key] = value
return creator.collection_shared_data[shared_key]

View file

@ -7,7 +7,8 @@ from openpype.pipeline import (
CreatorError,
legacy_io,
)
from openpype.hosts.aftereffects.api.pipeline import cache_and_get_instances
from openpype.pipeline.create.creator_plugins import cache_and_get_instances
class RenderCreator(Creator):
identifier = "render"
@ -28,7 +29,10 @@ class RenderCreator(Creator):
return resources.get_openpype_splash_filepath()
def collect_instances(self):
for instance_data in cache_and_get_instances(self):
instances = cache_and_get_instances(self,
"openpype.aftereffects.instances",
self.host.list_instances)
for instance_data in instances:
# legacy instances have family=='render' or 'renderLocal', use them
creator_id = (instance_data.get("creator_identifier") or
instance_data.get("family", '').replace("Local", ''))

View file

@ -5,7 +5,7 @@ from openpype.pipeline import (
CreatedInstance,
legacy_io,
)
from openpype.hosts.aftereffects.api.pipeline import cache_and_get_instances
from openpype.pipeline.create.creator_plugins import cache_and_get_instances
class AEWorkfileCreator(AutoCreator):
@ -18,7 +18,10 @@ class AEWorkfileCreator(AutoCreator):
return []
def collect_instances(self):
for instance_data in cache_and_get_instances(self):
instances = cache_and_get_instances(self,
"openpype.aftereffects.instances",
self.host.list_instances)
for instance_data in instances:
creator_id = instance_data.get("creator_identifier")
if creator_id == self.identifier:
subset_name = instance_data["subset"]