Merge branch 'develop' into bugfix/OP-4183_Crashed-save-cause-crash-of-UI

This commit is contained in:
Jakub Trllo 2022-10-21 15:23:31 +02:00
commit a5c161c39c
16 changed files with 107 additions and 35 deletions

View file

@ -251,7 +251,6 @@ def reload_config():
import importlib
for module in (
"openpype.api",
"openpype.hosts.hiero.lib",
"openpype.hosts.hiero.menu",
"openpype.hosts.hiero.tags"

View file

@ -1,5 +1,6 @@
from pyblish import api
import openpype.api as pype
from openpype.lib import version_up
class IntegrateVersionUpWorkfile(api.ContextPlugin):
@ -15,7 +16,7 @@ class IntegrateVersionUpWorkfile(api.ContextPlugin):
def process(self, context):
project = context.data["activeProject"]
path = context.data.get("currentFile")
new_path = pype.version_up(path)
new_path = version_up(path)
if project:
project.saveAs(new_path)

View file

@ -66,7 +66,6 @@ def reload_config():
"""
for module in (
"openpype.api",
"openpype.hosts.nuke.api.actions",
"openpype.hosts.nuke.api.menu",
"openpype.hosts.nuke.api.plugin",

View file

@ -3,7 +3,8 @@ import os
import nuke
import pyblish.api
import openpype.api as pype
from openpype.lib import get_version_from_path
from openpype.hosts.nuke.api.lib import (
add_publish_knob,
get_avalon_knob_data
@ -74,7 +75,7 @@ class CollectWorkfile(pyblish.api.ContextPlugin):
"fps": root['fps'].value(),
"currentFile": current_file,
"version": int(pype.get_version_from_path(current_file)),
"version": int(get_version_from_path(current_file)),
"host": pyblish.api.current_host(),
"hostVersion": nuke.NUKE_VERSION_STRING

View file

@ -17,11 +17,27 @@ from openpype.lib.transcoding import IMAGE_EXTENSIONS, VIDEO_EXTENSIONS
REVIEW_EXTENSIONS = IMAGE_EXTENSIONS + VIDEO_EXTENSIONS
def _cache_and_get_instances(creator):
"""Cache instances in shared data.
Args:
creator (Creator): Plugin which would like to get instances from host.
Returns:
List[Dict[str, Any]]: Cached instances list from host implementation.
"""
shared_key = "openpype.traypublisher.instances"
if shared_key not in creator.collection_shared_data:
creator.collection_shared_data[shared_key] = list_instances()
return creator.collection_shared_data[shared_key]
class HiddenTrayPublishCreator(HiddenCreator):
host_name = "traypublisher"
def collect_instances(self):
for instance_data in list_instances():
for instance_data in _cache_and_get_instances():
creator_id = instance_data.get("creator_identifier")
if creator_id == self.identifier:
instance = CreatedInstance.from_existing(
@ -58,7 +74,7 @@ class TrayPublishCreator(Creator):
host_name = "traypublisher"
def collect_instances(self):
for instance_data in list_instances():
for instance_data in _cache_and_get_instances():
creator_id = instance_data.get("creator_identifier")
if creator_id == self.identifier:
instance = CreatedInstance.from_existing(

View file

@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
"""Unreal Editor OpenPype host API."""
from .plugin import (
Loader,
Creator
)
from .plugin import Loader
from .pipeline import (
install,
uninstall,
@ -25,7 +23,6 @@ from .pipeline import (
__all__ = [
"install",
"uninstall",
"Creator",
"Loader",
"ls",
"publish",

View file

@ -1,16 +1,7 @@
# -*- coding: utf-8 -*-
from abc import ABC
from openpype.pipeline import (
LegacyCreator,
LoaderPlugin,
)
class Creator(LegacyCreator):
"""This serves as skeleton for future OpenPype specific functionality"""
defaults = ['Main']
maintain_selection = False
from openpype.pipeline import LoaderPlugin
class Loader(LoaderPlugin, ABC):

View file

@ -2,11 +2,11 @@ import unreal
from unreal import EditorAssetLibrary as eal
from unreal import EditorLevelLibrary as ell
from openpype.hosts.unreal.api import plugin
from openpype.hosts.unreal.api.pipeline import instantiate
from openpype.pipeline import LegacyCreator
class CreateCamera(plugin.Creator):
class CreateCamera(LegacyCreator):
"""Layout output for character rigs"""
name = "layoutMain"

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from unreal import EditorLevelLibrary
from openpype.hosts.unreal.api import plugin
from openpype.pipeline import LegacyCreator
from openpype.hosts.unreal.api.pipeline import instantiate
class CreateLayout(plugin.Creator):
class CreateLayout(LegacyCreator):
"""Layout output for character rigs."""
name = "layoutMain"

View file

@ -2,9 +2,10 @@
"""Create look in Unreal."""
import unreal # noqa
from openpype.hosts.unreal.api import pipeline, plugin
from openpype.pipeline import LegacyCreator
class CreateLook(plugin.Creator):
class CreateLook(LegacyCreator):
"""Shader connections defining shape look."""
name = "unrealLook"

View file

@ -1,10 +1,10 @@
import unreal
from openpype.hosts.unreal.api import pipeline
from openpype.hosts.unreal.api.plugin import Creator
from openpype.pipeline import LegacyCreator
class CreateRender(Creator):
class CreateRender(LegacyCreator):
"""Create instance for sequence for rendering"""
name = "unrealRender"

View file

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
"""Create Static Meshes as FBX geometry."""
import unreal # noqa
from openpype.hosts.unreal.api import plugin
from openpype.hosts.unreal.api.pipeline import (
instantiate,
)
from openpype.pipeline import LegacyCreator
class CreateStaticMeshFBX(plugin.Creator):
class CreateStaticMeshFBX(LegacyCreator):
"""Static FBX geometry."""
name = "unrealStaticMeshMain"

View file

@ -30,6 +30,11 @@ from .creator_plugins import (
UpdateData = collections.namedtuple("UpdateData", ["instance", "changes"])
class UnavailableSharedData(Exception):
"""Shared data are not available at the moment when are accessed."""
pass
class ImmutableKeyError(TypeError):
"""Accessed key is immutable so does not allow changes or removements."""
@ -999,6 +1004,9 @@ class CreateContext:
self._bulk_counter = 0
self._bulk_instances_to_process = []
# Shared data across creators during collection phase
self._collection_shared_data = None
# Trigger reset if was enabled
if reset:
self.reset(discover_publish_plugins)
@ -1054,6 +1062,9 @@ class CreateContext:
All changes will be lost if were not saved explicitely.
"""
self.reset_preparation()
self.reset_avalon_context()
self.reset_plugins(discover_publish_plugins)
self.reset_context_data()
@ -1062,6 +1073,20 @@ class CreateContext:
self.reset_instances()
self.execute_autocreators()
self.reset_finalization()
def reset_preparation(self):
"""Prepare attributes that must be prepared/cleaned before reset."""
# Give ability to store shared data for collection phase
self._collection_shared_data = {}
def reset_finalization(self):
"""Cleanup of attributes after reset."""
# Stop access to collection shared data
self._collection_shared_data = None
def reset_avalon_context(self):
"""Give ability to reset avalon context.
@ -1626,3 +1651,20 @@ class CreateContext:
if not plugin.__instanceEnabled__:
plugins.append(plugin)
return plugins
@property
def collection_shared_data(self):
"""Access to shared data that can be used during creator's collection.
Retruns:
Dict[str, Any]: Shared data.
Raises:
UnavailableSharedData: When called out of collection phase.
"""
if self._collection_shared_data is None:
raise UnavailableSharedData(
"Accessed Collection shared data out of collection phase"
)
return self._collection_shared_data

View file

@ -6,6 +6,7 @@ from abc import (
abstractmethod,
abstractproperty
)
import six
from openpype.settings import get_system_settings, get_project_settings
@ -323,6 +324,19 @@ class BaseCreator:
return self.instance_attr_defs
@property
def collection_shared_data(self):
"""Access to shared data that can be used during creator's collection.
Retruns:
Dict[str, Any]: Shared data.
Raises:
UnavailableSharedData: When called out of collection phase.
"""
return self.create_context.collection_shared_data
class Creator(BaseCreator):
"""Creator that has more information for artist to show in UI.

View file

@ -1674,6 +1674,8 @@ class PublisherController(BasePublisherController):
self.host_is_valid = self._create_context.host_is_valid
self._create_context.reset_preparation()
# Reset avalon context
self._create_context.reset_avalon_context()
@ -1684,6 +1686,8 @@ class PublisherController(BasePublisherController):
self._reset_publish()
self._reset_instances()
self._create_context.reset_finalization()
self._emit_event("controller.reset.finished")
self.emit_card_message("Refreshed..")