From adb683bdfc72270f66594aa1a4e5e055de4bec07 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 3 Nov 2022 10:46:20 +0100 Subject: [PATCH] OP-3909 - use caching function from creator In between cache function was extracted into creator_plugins, use this to standardize betwen different hosts. --- openpype/hosts/aftereffects/api/pipeline.py | 19 ------------------- .../plugins/create/create_render.py | 8 ++++++-- .../plugins/create/workfile_creator.py | 7 +++++-- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/openpype/hosts/aftereffects/api/pipeline.py b/openpype/hosts/aftereffects/api/pipeline.py index cf5bcf242e..585c101d2c 100644 --- a/openpype/hosts/aftereffects/api/pipeline.py +++ b/openpype/hosts/aftereffects/api/pipeline.py @@ -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] diff --git a/openpype/hosts/aftereffects/plugins/create/create_render.py b/openpype/hosts/aftereffects/plugins/create/create_render.py index 01d59abb37..7a81c7754b 100644 --- a/openpype/hosts/aftereffects/plugins/create/create_render.py +++ b/openpype/hosts/aftereffects/plugins/create/create_render.py @@ -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", '')) diff --git a/openpype/hosts/aftereffects/plugins/create/workfile_creator.py b/openpype/hosts/aftereffects/plugins/create/workfile_creator.py index c698af896b..10d3685869 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.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"]