From de5decbcbbacc427eea17642872bd123c890a63e Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 3 Nov 2022 13:20:24 +0100 Subject: [PATCH] OP-3908 - revert back to AE specific cache method Standard approach doesn't handle legacy instances, eg. instance without creator_identifier. --- openpype/hosts/aftereffects/api/pipeline.py | 16 ++++++++++++++++ .../aftereffects/plugins/create/create_render.py | 7 ++----- .../plugins/create/workfile_creator.py | 7 ++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/openpype/hosts/aftereffects/api/pipeline.py b/openpype/hosts/aftereffects/api/pipeline.py index dbdc534f29..af4c3338d8 100644 --- a/openpype/hosts/aftereffects/api/pipeline.py +++ b/openpype/hosts/aftereffects/api/pipeline.py @@ -1,5 +1,6 @@ import os from Qt import QtWidgets +import collections import pyblish.api @@ -294,3 +295,18 @@ def containerise(name, stub.imprint(comp.id, data) return comp + + +def cache_and_get_instances(creator): + """Cache instances in shared data. + + Storing all instances as a list as legacy instances might be still present. + Args: + creator (Creator): Plugin which would like to get instances from host. + Returns: + List[]: list of all instances stored in metadata + """ + shared_key = "openpype.photoshop.instances" + if shared_key not in creator.collection_shared_data: + creator.collection_shared_data[shared_key] = creator.list_instances() + return creator.collection_shared_data[shared_key] diff --git a/openpype/hosts/aftereffects/plugins/create/create_render.py b/openpype/hosts/aftereffects/plugins/create/create_render.py index 2bd6ecd9b5..1f38056c9b 100644 --- a/openpype/hosts/aftereffects/plugins/create/create_render.py +++ b/openpype/hosts/aftereffects/plugins/create/create_render.py @@ -7,7 +7,7 @@ from openpype.pipeline import ( CreatorError, legacy_io, ) -from openpype.pipeline.create.creator_plugins import cache_and_get_instances +from openpype.hosts.aftereffects.api.pipeline import cache_and_get_instances class RenderCreator(Creator): @@ -29,10 +29,7 @@ class RenderCreator(Creator): return resources.get_openpype_splash_filepath() def collect_instances(self): - instances = cache_and_get_instances(self, - "openpype.aftereffects.instances", - self.host.list_instances) - for instance_data in instances.values(): + for instance_data in cache_and_get_instances(self): # legacy instances have family=='render' or 'renderLocal', use them creator_id = (instance_data.get("creator_identifier") or instance_data.get("family", '').replace("Local", '')) diff --git a/openpype/hosts/aftereffects/plugins/create/workfile_creator.py b/openpype/hosts/aftereffects/plugins/create/workfile_creator.py index e6f4348526..c698af896b 100644 --- a/openpype/hosts/aftereffects/plugins/create/workfile_creator.py +++ b/openpype/hosts/aftereffects/plugins/create/workfile_creator.py @@ -5,7 +5,7 @@ from openpype.pipeline import ( CreatedInstance, legacy_io, ) -from openpype.pipeline.create.creator_plugins import cache_and_get_instances +from openpype.hosts.aftereffects.api.pipeline import cache_and_get_instances class AEWorkfileCreator(AutoCreator): @@ -18,10 +18,7 @@ class AEWorkfileCreator(AutoCreator): return [] def collect_instances(self): - instances = cache_and_get_instances(self, - "openpype.aftereffects.instances", - self.host.list_instances) - for instance_data in instances.values(): + for instance_data in cache_and_get_instances(self): creator_id = instance_data.get("creator_identifier") if creator_id == self.identifier: subset_name = instance_data["subset"]