OP-3908 - revert back to PS cache

Standard approach doesn't handle legacy instances, eg. instance without creator_identifier.
This commit is contained in:
Petr Kalis 2022-11-03 13:17:37 +01:00
parent 0e9c0a5eb3
commit cb5c8c2b13
3 changed files with 20 additions and 11 deletions

View file

@ -1,6 +1,6 @@
import os
from Qt import QtWidgets
import collections
import pyblish.api
from openpype.lib import register_event_callback, Logger
@ -290,3 +290,18 @@ def containerise(
stub.imprint(layer.id, data)
return layer
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]

View file

@ -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.pipeline.create.creator_plugins import cache_and_get_instances
from openpype.hosts.photoshop.api.pipeline import cache_and_get_instances
class ImageCreator(Creator):
@ -20,10 +20,7 @@ class ImageCreator(Creator):
description = "Image creator"
def collect_instances(self):
instances = cache_and_get_instances(self,
"openpype.photoshop.instances",
self.host.list_instances)
for instance_data in instances.values():
for instance_data in cache_and_get_instances(self):
# legacy instances have family=='image'
creator_id = (instance_data.get("creator_identifier") or
instance_data.get("family"))

View file

@ -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.photoshop.api.pipeline import cache_and_get_instances
class PSWorkfileCreator(AutoCreator):
@ -18,10 +18,7 @@ class PSWorkfileCreator(AutoCreator):
return []
def collect_instances(self):
instances = cache_and_get_instances(self,
"openpype.photoshop.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"]