Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Publisher: Prepare publisher controller for remote publishing #3972

Merged
merged 90 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
ff2453c
PublisherController can be imported without import of Qt
iLLiCiTiT Oct 5, 2022
a00dafb
change few attributes to private
iLLiCiTiT Oct 5, 2022
92cd6b6
added abstract controller for UI
iLLiCiTiT Oct 6, 2022
6397db6
removed 'plugins_with_defs' attribute
iLLiCiTiT Oct 6, 2022
80103e6
changed 'creators' attribute to '_creators'
iLLiCiTiT Oct 6, 2022
71cca8e
changed 'publish_plugins' attribute to '_publish_plugins'
iLLiCiTiT Oct 6, 2022
c232e81
removed doubled event system
iLLiCiTiT Oct 6, 2022
5b75511
traypublisher has it's controller
iLLiCiTiT Oct 6, 2022
054b87b
fix event system access in qt controller
iLLiCiTiT Oct 7, 2022
f13d2bc
implemented helper publish plugins proxy to handle actions for plugins
iLLiCiTiT Oct 7, 2022
a3d16de
created objects for controller <-> ui communiction related to plugin …
iLLiCiTiT Oct 7, 2022
a63854f
Created object to gather validation errors during publish processing
iLLiCiTiT Oct 7, 2022
d90838b
removed unused 'get_manual_creators_base_info'
iLLiCiTiT Oct 7, 2022
e53efc7
create plugins proxy in controller
iLLiCiTiT Oct 7, 2022
8996e27
changed how validation errors are collected and worked with in UI
iLLiCiTiT Oct 7, 2022
2a34a5f
renamed 'get_icon_for_family' to 'get_creator_icon'
iLLiCiTiT Oct 7, 2022
5628528
fix action trigger
iLLiCiTiT Oct 7, 2022
35562e4
remove unused variable reset
iLLiCiTiT Oct 7, 2022
e6042d9
fix event system access
iLLiCiTiT Oct 7, 2022
a06f629
added some docstrings
iLLiCiTiT Oct 7, 2022
2001072
controller is private for all widgets
iLLiCiTiT Oct 7, 2022
d6de369
Merge branch 'feature/OP-4158_Creation-UI-is-part-of-main-window' int…
iLLiCiTiT Oct 7, 2022
5cfd5db
added missing abstract property 'host_is_valid'
iLLiCiTiT Oct 7, 2022
5644921
store asset documents by name
iLLiCiTiT Oct 7, 2022
2ab0ad9
added ability to get and query full asset document
iLLiCiTiT Oct 7, 2022
626cb38
added ability to get existing subsets for passet asset name via contr…
iLLiCiTiT Oct 7, 2022
ac61407
controller can handle get subset name based on creator identifier
iLLiCiTiT Oct 7, 2022
72dccf2
create widget does not call 'get_subset_name' on creator but via cont…
iLLiCiTiT Oct 7, 2022
9ce236a
Added creator item for warpping creator plugins
iLLiCiTiT Oct 7, 2022
447d156
use creator items instead of creators directly
iLLiCiTiT Oct 7, 2022
06e1cf0
attribute definitions now have types
iLLiCiTiT Oct 7, 2022
bc39b99
attribute definitions can be serialized and deserialized
iLLiCiTiT Oct 7, 2022
ac40610
added helper functions to serialize and deserialize attribute definit…
iLLiCiTiT Oct 7, 2022
409ec10
added serialization and deserialization of CreatorItem
iLLiCiTiT Oct 7, 2022
12fee4e
create context provides instances by id
iLLiCiTiT Oct 7, 2022
8f83ff8
prepared some methods for instance remote processing
iLLiCiTiT Oct 7, 2022
b5a4420
instances returns instances by id
iLLiCiTiT Oct 7, 2022
56cea03
don't call same property more then once
iLLiCiTiT Oct 7, 2022
d71f201
removed 'reset_project_data_cache' used in traypublisher
iLLiCiTiT Oct 7, 2022
0534451
reset assets cache on controller reset
iLLiCiTiT Oct 7, 2022
92f2827
mimic creator methods
iLLiCiTiT Oct 7, 2022
ae717d4
use creator item to get attribute definitions instead of instance
iLLiCiTiT Oct 7, 2022
098bcce
added some helper functions for easy overriding to avoid duplicity
iLLiCiTiT Oct 7, 2022
7e53b03
prepared base class of remote qt controller
iLLiCiTiT Oct 7, 2022
811e785
added ability to serailize and deserialize event to data
iLLiCiTiT Oct 10, 2022
d1f3c8e
added properties with getters and setters
iLLiCiTiT Oct 10, 2022
c907383
use events to handle controller changes
iLLiCiTiT Oct 10, 2022
0f514aa
mark methods that should be abstract in remote controller
iLLiCiTiT Oct 10, 2022
ebb6a17
trigger event on finished attribute change
iLLiCiTiT Oct 10, 2022
8ffdbf0
instances are removed by ids
iLLiCiTiT Oct 10, 2022
91b6681
added some basic implementation of client event handling
iLLiCiTiT Oct 10, 2022
ac3326d
fix import
iLLiCiTiT Oct 10, 2022
187411e
added BaseController to handle base attributes
iLLiCiTiT Oct 10, 2022
16aff52
fix attribute changes
iLLiCiTiT Oct 10, 2022
f9155bd
implemented base controller
iLLiCiTiT Oct 10, 2022
2baa3a5
fix typo
iLLiCiTiT Oct 10, 2022
3f46529
Merge branch 'feature/OP-4158_Creation-UI-is-part-of-main-window' int…
iLLiCiTiT Oct 10, 2022
4d40024
added double click for asset dialog
iLLiCiTiT Oct 10, 2022
d46ca7e
cache assets hierarchy and stringify object ids
iLLiCiTiT Oct 10, 2022
5f1bfe2
use 'get_subset_name' on controller instead of calling directly creator
iLLiCiTiT Oct 10, 2022
2e86d03
fix import of PublisherWindow and add ability to pass controller
iLLiCiTiT Oct 11, 2022
67f4112
removed duplicated topic from docstring
iLLiCiTiT Oct 11, 2022
e883f87
renamed 'BasePublishController' to 'BasePublisherController'
iLLiCiTiT Oct 11, 2022
7576980
use 'BasePublisherController' for 'QtRemotePublishController'
iLLiCiTiT Oct 11, 2022
18ebea7
handle 'host_is_valid' attribute change
iLLiCiTiT Oct 11, 2022
e0a222c
modified remote qt controller
iLLiCiTiT Oct 12, 2022
8c3ffcc
added a docstring to remote controller
iLLiCiTiT Oct 12, 2022
8e46890
Merge branch 'feature/OP-4158_Creation-UI-is-part-of-main-window' int…
iLLiCiTiT Oct 12, 2022
df4f3d4
fix instances access in 'get_subset_name'
iLLiCiTiT Oct 12, 2022
64f9d98
hound fix
iLLiCiTiT Oct 12, 2022
296ed1e
Merge branch 'develop' into feature/OP-4194_Remote-publisher-controller
iLLiCiTiT Oct 13, 2022
9955ffe
fix validation errors access
iLLiCiTiT Oct 14, 2022
1b8dff4
add process time to publish report
iLLiCiTiT Oct 15, 2022
2787dbd
add report version to report data
iLLiCiTiT Oct 15, 2022
d3e5041
fix not passed argument
iLLiCiTiT Oct 15, 2022
0df1597
fix unwanted zooming if control was released in different widget
iLLiCiTiT Oct 16, 2022
3afee73
define min/max of text sizes
iLLiCiTiT Oct 16, 2022
bb2432e
Merge branch 'develop' into feature/OP-4194_Remote-publisher-controller
iLLiCiTiT Oct 17, 2022
1ecc673
error message fix
iLLiCiTiT Oct 17, 2022
495b547
fix args order
iLLiCiTiT Oct 17, 2022
609f9f1
fix attribute access
iLLiCiTiT Oct 17, 2022
27d4f1f
reuse duration from pyblish result instead of calculating own
iLLiCiTiT Oct 17, 2022
b4d6fa3
removed unused import
iLLiCiTiT Oct 17, 2022
3fd2a88
fix wrong attribute name
iLLiCiTiT Oct 17, 2022
7190c07
go to report on publish stop if on publish tab
iLLiCiTiT Oct 17, 2022
c077fdf
Merge branch 'develop' into feature/OP-4194_Remote-publisher-controller
iLLiCiTiT Oct 17, 2022
c9e10f6
change progress bar on validation error
iLLiCiTiT Oct 17, 2022
9e37f34
change page to publish on reset
iLLiCiTiT Oct 17, 2022
7f53339
change progress bar colors on pause
iLLiCiTiT Oct 17, 2022
4641cb5
added backrwards compatibility for PyQt4
iLLiCiTiT Oct 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 173 additions & 2 deletions openpype/lib/attribute_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@
import collections
import uuid
import json
from abc import ABCMeta, abstractmethod
from abc import ABCMeta, abstractmethod, abstractproperty

import six
import clique

# Global variable which store attribude definitions by type
# - default types are registered on import
_attr_defs_by_type = {}


def register_attr_def_class(cls):
"""Register attribute definition.

Currently are registered definitions used to deserialize data to objects.

Attrs:
cls (AbtractAttrDef): Non-abstract class to be registered with unique
'type' attribute.

Raises:
KeyError: When type was already registered.
"""

if cls.type in _attr_defs_by_type:
raise KeyError("Type \"{}\" was already registered".format(cls.type))
_attr_defs_by_type[cls.type] = cls


def get_attributes_keys(attribute_definitions):
"""Collect keys from list of attribute definitions.
Expand Down Expand Up @@ -90,6 +112,8 @@ class AbtractAttrDef:
next to value input or ahead.
"""

type_attributes = []

is_value_def = True

def __init__(
Expand All @@ -115,6 +139,16 @@ def __eq__(self, other):
return False
return self.key == other.key

@abstractproperty
def type(self):
"""Attribute definition type also used as identifier of class.

Returns:
str: Type of attribute definition.
"""

pass

@abstractmethod
def convert_value(self, value):
"""Convert value to a valid one.
Expand All @@ -125,6 +159,35 @@ def convert_value(self, value):

pass

def serialize(self):
"""Serialize object to data so it's possible to recreate it.

Returns:
Dict[str, Any]: Serialized object that can be passed to
'deserialize' method.
"""

data = {
"type": self.type,
"key": self.key,
"label": self.label,
"tooltip": self.tooltip,
"default": self.default,
"is_label_horizontal": self.is_label_horizontal
}
for attr in self.type_attributes:
data[attr] = getattr(self, attr)
return data

@classmethod
def deserialize(cls, data):
"""Recreate object from data.

Data can be received using 'serialize' method.
"""

return cls(**data)


# -----------------------------------------
# UI attribute definitoins won't hold value
Expand All @@ -141,10 +204,12 @@ def convert_value(self, value):


class UISeparatorDef(UIDef):
pass
type = "separator"


class UILabelDef(UIDef):
type = "label"

def __init__(self, label):
super(UILabelDef, self).__init__(label=label)

Expand All @@ -160,6 +225,8 @@ class UnknownDef(AbtractAttrDef):
have known definition of type.
"""

type = "unknown"

def __init__(self, key, default=None, **kwargs):
kwargs["default"] = default
super(UnknownDef, self).__init__(key, **kwargs)
Expand All @@ -181,6 +248,13 @@ class NumberDef(AbtractAttrDef):
default(int, float): Default value for conversion.
"""

type = "number"
type_attributes = [
"minimum",
"maximum",
"decimals"
]

def __init__(
self, key, minimum=None, maximum=None, decimals=None, default=None,
**kwargs
Expand Down Expand Up @@ -252,6 +326,12 @@ class TextDef(AbtractAttrDef):
default(str, None): Default value. Empty string used when not defined.
"""

type = "text"
type_attributes = [
"multiline",
"placeholder",
]

def __init__(
self, key, multiline=None, regex=None, placeholder=None, default=None,
**kwargs
Expand Down Expand Up @@ -290,6 +370,11 @@ def convert_value(self, value):
return value
return self.default

def serialize(self):
data = super(TextDef, self).serialize()
data["regex"] = self.regex.pattern
return data


class EnumDef(AbtractAttrDef):
"""Enumeration of single item from items.
Expand All @@ -301,6 +386,8 @@ class EnumDef(AbtractAttrDef):
default: Default value. Must be one key(value) from passed items.
"""

type = "enum"

def __init__(self, key, items, default=None, **kwargs):
if not items:
raise ValueError((
Expand Down Expand Up @@ -335,6 +422,11 @@ def convert_value(self, value):
return value
return self.default

def serialize(self):
data = super(TextDef, self).serialize()
data["items"] = list(self.items)
return data


class BoolDef(AbtractAttrDef):
"""Boolean representation.
Expand All @@ -343,6 +435,8 @@ class BoolDef(AbtractAttrDef):
default(bool): Default value. Set to `False` if not defined.
"""

type = "bool"

def __init__(self, key, default=None, **kwargs):
if default is None:
default = False
Expand Down Expand Up @@ -585,6 +679,15 @@ class FileDef(AbtractAttrDef):
default(str, List[str]): Default value.
"""

type = "path"
type_attributes = [
"single_item",
"folders",
"extensions",
"allow_sequences",
"extensions_label",
]

def __init__(
self, key, single_item=True, folders=None, extensions=None,
allow_sequences=True, extensions_label=None, default=None, **kwargs
Expand Down Expand Up @@ -675,3 +778,71 @@ def convert_value(self, value):
if self.single_item:
return FileDefItem.create_empty_item().to_dict()
return []


def serialize_attr_def(attr_def):
"""Serialize attribute definition to data.

Args:
attr_def (AbtractAttrDef): Attribute definition to serialize.

Returns:
Dict[str, Any]: Serialized data.
"""

return attr_def.serialize()


def serialize_attr_defs(attr_defs):
"""Serialize attribute definitions to data.

Args:
attr_defs (List[AbtractAttrDef]): Attribute definitions to serialize.

Returns:
List[Dict[str, Any]]: Serialized data.
"""

return [
serialize_attr_def(attr_def)
for attr_def in attr_defs
]


def deserialize_attr_def(attr_def_data):
"""Deserialize attribute definition from data.

Args:
attr_def (Dict[str, Any]): Attribute definition data to deserialize.
"""

attr_type = attr_def_data.pop("type")
cls = _attr_defs_by_type[attr_type]
return cls.deserialize(attr_def_data)


def deserialize_attr_defs(attr_defs_data):
"""Deserialize attribute definitions.

Args:
List[Dict[str, Any]]: List of attribute definitions.
"""

return [
deserialize_attr_def(attr_def_data)
for attr_def_data in attr_defs_data
]


# Register attribute definitions
for _attr_class in (
UISeparatorDef,
UILabelDef,
UnknownDef,
NumberDef,
TextDef,
EnumDef,
BoolDef,
FileDef
):
register_attr_def_class(_attr_class)
49 changes: 49 additions & 0 deletions openpype/lib/events.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Events holding data about specific event."""
import os
import re
import copy
import inspect
import logging
import weakref
Expand Down Expand Up @@ -207,6 +208,12 @@ def id(self):

@property
def source(self):
"""Event's source used for triggering callbacks.

Returns:
Union[str, None]: Source string or None. Source is optional.
"""

return self._source

@property
Expand All @@ -215,6 +222,12 @@ def data(self):

@property
def topic(self):
"""Event's topic used for triggering callbacks.

Returns:
str: Topic string.
"""

return self._topic

def emit(self):
Expand All @@ -227,6 +240,42 @@ def emit(self):
)
self._event_system.emit_event(self)

def to_data(self):
"""Convert Event object to data.

Returns:
Dict[str, Any]: Event data.
"""

return {
"id": self.id,
"topic": self.topic,
"source": self.source,
"data": copy.deepcopy(self.data)
}

@classmethod
def from_data(cls, event_data, event_system=None):
"""Create event from data.

Args:
event_data (Dict[str, Any]): Event data with defined keys. Can be
created using 'to_data' method.
event_system (EventSystem): System to which the event belongs.

Returns:
Event: Event with attributes from passed data.
"""

obj = cls(
event_data["topic"],
event_data["data"],
event_data["source"],
event_system
)
obj._id = event_data["id"]
return obj


class EventSystem(object):
"""Encapsulate event handling into an object.
Expand Down
Loading