From d6ffdc93e5d8f06558af43b39fd7dcf516d3f4db Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Thu, 3 Nov 2022 10:50:03 +0100 Subject: [PATCH] OP-3908 - use caching function from creator In between cache function was extracted into creator_plugins, use this to standardize betwen different hosts. --- openpype/hosts/photoshop/api/pipeline.py | 19 ------------------- .../photoshop/plugins/create/create_image.py | 7 +++++-- .../plugins/create/workfile_creator.py | 7 +++++-- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/openpype/hosts/photoshop/api/pipeline.py b/openpype/hosts/photoshop/api/pipeline.py index f762ca0062..1913a94d19 100644 --- a/openpype/hosts/photoshop/api/pipeline.py +++ b/openpype/hosts/photoshop/api/pipeline.py @@ -1,6 +1,5 @@ import os from Qt import QtWidgets -import collections import pyblish.api @@ -291,21 +290,3 @@ def containerise( stub.imprint(layer.id, data) return layer - - -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.photoshop.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/photoshop/plugins/create/create_image.py b/openpype/hosts/photoshop/plugins/create/create_image.py index 53e68ef384..4f8b227852 100644 --- a/openpype/hosts/photoshop/plugins/create/create_image.py +++ b/openpype/hosts/photoshop/plugins/create/create_image.py @@ -9,7 +9,7 @@ from openpype.pipeline import ( ) from openpype.lib import prepare_template_data from openpype.pipeline.create import SUBSET_NAME_ALLOWED_SYMBOLS -from openpype.hosts.photoshop.api.pipeline import cache_and_get_instances +from openpype.pipeline.create.creator_plugins import cache_and_get_instances class ImageCreator(Creator): @@ -20,7 +20,10 @@ class ImageCreator(Creator): description = "Image creator" def collect_instances(self): - for instance_data in cache_and_get_instances(self): + instances = cache_and_get_instances(self, + "openpype.photoshop.instances", + self.host.list_instances) + for instance_data in instances: # legacy instances have family=='image' creator_id = (instance_data.get("creator_identifier") or instance_data.get("family")) diff --git a/openpype/hosts/photoshop/plugins/create/workfile_creator.py b/openpype/hosts/photoshop/plugins/create/workfile_creator.py index 8ee9a0d832..af84b5ab9e 100644 --- a/openpype/hosts/photoshop/plugins/create/workfile_creator.py +++ b/openpype/hosts/photoshop/plugins/create/workfile_creator.py @@ -5,7 +5,7 @@ from openpype.pipeline import ( CreatedInstance, legacy_io ) -from openpype.hosts.photoshop.api.pipeline import cache_and_get_instances +from openpype.pipeline.create.creator_plugins import cache_and_get_instances class PSWorkfileCreator(AutoCreator): @@ -18,7 +18,10 @@ class PSWorkfileCreator(AutoCreator): return [] def collect_instances(self): - for instance_data in cache_and_get_instances(self): + instances = cache_and_get_instances(self, + "openpype.photoshop.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"]