Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Validate Content plugin settings #525

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
40 changes: 36 additions & 4 deletions client/ayon_core/plugins/publish/validate_containers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import pyblish.api

from ayon_core.lib import filter_profiles
from ayon_core.host import ILoadHost
from ayon_core.pipeline.load import any_outdated_containers
from ayon_core.pipeline import (
get_current_host_name,
registered_host,
PublishXmlValidationError,
OptionalPyblishPluginMixin
)
Expand All @@ -18,17 +23,44 @@ def process(self, context, plugin):
host_tools.show_scene_inventory()


class ValidateContainers(OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin):

class ValidateContainers(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Containers are must be updated to latest version on publish."""

label = "Validate Outdated Containers"
order = pyblish.api.ValidatorOrder
hosts = ["maya", "houdini", "nuke", "harmony", "photoshop", "aftereffects"]

optional = True
actions = [ShowInventory]

@classmethod
def apply_settings(cls, settings):
# Disable plugin if host does not inherit from 'ILoadHost'
# - not a host that can load containers
host = registered_host()
if not isinstance(host, ILoadHost):
cls.enabled = False
return

# Disable if no profile is found for the current host
profile = filter_profiles(
settings["core"]["publish"]["ValidateContainers"]["profiles"],
{"host_names": get_current_host_name()}
)
if not profile:
cls.enabled = False
return

# Apply settings from profile
for attr_name in {
"enabled",
"optional",
"active",
}:
setattr(cls, attr_name, profile[attr_name])

def process(self, context):
if not self.is_active(context.data):
return
Expand Down
49 changes: 49 additions & 0 deletions server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ class CollectFramesFixDefModel(BaseSettingsModel):
)


class ValidateContainersProfile(BaseSettingsModel):
_layout = "expanded"
# Filtering
host_names: list[str] = SettingsField(
default_factory=list,
title="Host names"
)
# Profile values
enabled: bool = SettingsField(True, title="Enabled")
optional: bool = SettingsField(True, title="Optional")
active: bool = SettingsField(True, title="Active")


class ValidateContainersModel(BaseSettingsModel):
"""Validate if Publishing intent was selected.

It is possible to disable validation for specific publishing context
with profiles.
"""

_isGroup = True
profiles: list[ValidateContainersProfile] = SettingsField(
default_factory=list
)


class ValidateIntentProfile(BaseSettingsModel):
_layout = "expanded"
hosts: list[str] = SettingsField(default_factory=list, title="Host names")
Expand Down Expand Up @@ -770,6 +796,10 @@ class PublishPuginsModel(BaseSettingsModel):
default_factory=ValidateBaseModel,
title="Validate Version"
)
ValidateContainers: ValidateContainersModel = SettingsField(
default_factory=ValidateContainersModel,
title="Validate Containers"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the title to Validate Outdated Containers so it matches the label on the plug-in itself?

With just Validate Containers it leaves me a bit guessing what it validates about the containers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, why you wrote it after merge, now I have to create new PR...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, day off today - saw it a bit too late.

)
ValidateIntent: ValidateIntentModel = SettingsField(
default_factory=ValidateIntentModel,
title="Validate Intent"
Expand Down Expand Up @@ -855,6 +885,25 @@ class PublishPuginsModel(BaseSettingsModel):
"optional": False,
"active": True
},
"ValidateContainers": {
"profiles": [
{
# Default host names are based on original
# filter of ValidateContainer pyblish plugin
"host_names": [
"maya",
"houdini",
"nuke",
"harmony",
"photoshop",
"aftereffects"
],
"enabled": True,
"optional": True,
"active": True
}
]
},
"ValidateIntent": {
"enabled": False,
"profiles": []
Expand Down
2 changes: 1 addition & 1 deletion server_addon/aftereffects/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "aftereffects"
title = "AfterEffects"
version = "0.1.3"
version = "0.1.4"
15 changes: 0 additions & 15 deletions server_addon/aftereffects/server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ class ValidateSceneSettingsModel(BaseSettingsModel):
)


class ValidateContainersModel(BaseSettingsModel):
enabled: bool = SettingsField(True, title="Enabled")
optional: bool = SettingsField(True, title="Optional")
active: bool = SettingsField(True, title="Active")


class AfterEffectsPublishPlugins(BaseSettingsModel):
CollectReview: CollectReviewPluginModel = SettingsField(
default_factory=CollectReviewPluginModel,
Expand All @@ -37,10 +31,6 @@ class AfterEffectsPublishPlugins(BaseSettingsModel):
default_factory=ValidateSceneSettingsModel,
title="Validate Scene Settings",
)
ValidateContainers: ValidateContainersModel = SettingsField(
default_factory=ValidateContainersModel,
title="Validate Containers",
)


AE_PUBLISH_PLUGINS_DEFAULTS = {
Expand All @@ -58,9 +48,4 @@ class AfterEffectsPublishPlugins(BaseSettingsModel):
".*"
]
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True,
}
}
2 changes: 1 addition & 1 deletion server_addon/harmony/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "harmony"
title = "Harmony"
version = "0.1.2"
version = "0.1.3"
5 changes: 0 additions & 5 deletions server_addon/harmony/server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ class HarmonySettings(BaseSettingsModel):
"optional": True,
"active": True
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True
},
"ValidateSceneSettings": {
"enabled": True,
"optional": True,
Expand Down
13 changes: 0 additions & 13 deletions server_addon/harmony/server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ class ValidateAudioPlugin(BaseSettingsModel):
active: bool = SettingsField(True, title="Active")


class ValidateContainersPlugin(BaseSettingsModel):
"""Check if loaded container is scene are latest versions."""
_isGroup = True
enabled: bool = True
optional: bool = SettingsField(False, title="Optional")
active: bool = SettingsField(True, title="Active")


class ValidateSceneSettingsPlugin(BaseSettingsModel):
"""Validate if FrameStart, FrameEnd and Resolution match shot data in DB.
Use regular expressions to limit validations only on particular asset
Expand Down Expand Up @@ -63,11 +55,6 @@ class HarmonyPublishPlugins(BaseSettingsModel):
default_factory=ValidateAudioPlugin,
)

ValidateContainers: ValidateContainersPlugin = SettingsField(
title="Validate Containers",
default_factory=ValidateContainersPlugin,
)

ValidateSceneSettings: ValidateSceneSettingsPlugin = SettingsField(
title="Validate Scene Settings",
default_factory=ValidateSceneSettingsPlugin,
Expand Down
2 changes: 1 addition & 1 deletion server_addon/houdini/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "houdini"
title = "Houdini"
version = "0.2.14"
version = "0.2.15"
9 changes: 0 additions & 9 deletions server_addon/houdini/server/settings/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class PublishPluginsModel(BaseSettingsModel):
default_factory=CollectLocalRenderInstancesModel,
title="Collect Local Render Instances."
)
ValidateContainers: BasicValidateModel = SettingsField(
default_factory=BasicValidateModel,
title="Validate Latest Containers.",
section="Validators")
ValidateInstanceInContextHoudini: BasicValidateModel = SettingsField(
default_factory=BasicValidateModel,
title="Validate Instance is in same Context.")
Expand Down Expand Up @@ -119,11 +115,6 @@ class PublishPluginsModel(BaseSettingsModel):
]
}
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True
},
"ValidateInstanceInContextHoudini": {
"enabled": True,
"optional": True,
Expand Down
2 changes: 1 addition & 1 deletion server_addon/maya/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "maya"
title = "Maya"
version = "0.1.19"
version = "0.1.20"
9 changes: 0 additions & 9 deletions server_addon/maya/server/settings/publishers.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,6 @@ class PublishersModel(BaseSettingsModel):
title="Validate Instance In Context",
section="Validators"
)
ValidateContainers: BasicValidateModel = SettingsField(
default_factory=BasicValidateModel,
title="Validate Containers"
)
ValidateFrameRange: ValidateFrameRangeModel = SettingsField(
default_factory=ValidateFrameRangeModel,
title="Validate Frame Range"
Expand Down Expand Up @@ -1059,11 +1055,6 @@ class PublishersModel(BaseSettingsModel):
"optional": True,
"active": True
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True
},
"ValidateFrameRange": {
"enabled": True,
"optional": True,
Expand Down
2 changes: 1 addition & 1 deletion server_addon/nuke/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "nuke"
title = "Nuke"
version = "0.1.12"
version = "0.1.13"
9 changes: 0 additions & 9 deletions server_addon/nuke/server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ class PublishPluginsModel(BaseSettingsModel):
default_factory=OptionalPluginModel,
section="Validators"
)
ValidateContainers: OptionalPluginModel = SettingsField(
title="Validate Containers",
default_factory=OptionalPluginModel
)
ValidateKnobs: ValidateKnobsModel = SettingsField(
title="Validate Knobs",
default_factory=ValidateKnobsModel
Expand Down Expand Up @@ -300,11 +296,6 @@ class PublishPluginsModel(BaseSettingsModel):
"optional": True,
"active": True
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True
},
"ValidateKnobs": {
"enabled": False,
"knobs": "\n".join([
Expand Down
2 changes: 1 addition & 1 deletion server_addon/photoshop/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "photoshop"
title = "Photoshop"
version = "0.1.2"
version = "0.1.3"
18 changes: 0 additions & 18 deletions server_addon/photoshop/server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ class CollectVersionPlugin(BaseSettingsModel):
enabled: bool = SettingsField(True, title="Enabled")


class ValidateContainersPlugin(BaseSettingsModel):
"""Check that workfile contains latest version of loaded items""" # noqa
_isGroup = True
enabled: bool = True
optional: bool = SettingsField(False, title="Optional")
active: bool = SettingsField(True, title="Active")


class ValidateNamingPlugin(BaseSettingsModel):
"""Validate naming of products and layers""" # noqa
invalid_chars: str = SettingsField(
Expand Down Expand Up @@ -154,11 +146,6 @@ class PhotoshopPublishPlugins(BaseSettingsModel):
default_factory=CollectVersionPlugin,
)

ValidateContainers: ValidateContainersPlugin = SettingsField(
title="Validate Containers",
default_factory=ValidateContainersPlugin,
)

ValidateNaming: ValidateNamingPlugin = SettingsField(
title="Validate naming of products and layers",
default_factory=ValidateNamingPlugin,
Expand Down Expand Up @@ -187,11 +174,6 @@ class PhotoshopPublishPlugins(BaseSettingsModel):
"CollectVersion": {
"enabled": False
},
"ValidateContainers": {
"enabled": True,
"optional": True,
"active": True
},
"ValidateNaming": {
"invalid_chars": "[ \\\\/+\\*\\?\\(\\)\\[\\]\\{\\}:,;]",
"replace_char": "_"
Expand Down