validate intent has settings and can work on more hosts

This commit is contained in:
iLLiCiTiT 2021-09-27 15:47:17 +02:00
parent 5d70ab2a0e
commit f58cacb716
3 changed files with 99 additions and 11 deletions

View file

@ -1,5 +1,7 @@
import pyblish.api
import os
import pyblish.api
from openpype.lib import filter_profiles
class ValidateIntent(pyblish.api.ContextPlugin):
@ -12,20 +14,49 @@ class ValidateIntent(pyblish.api.ContextPlugin):
order = pyblish.api.ValidatorOrder
label = "Validate Intent"
# TODO: this should be off by default and only activated viac config
tasks = ["animation"]
hosts = ["harmony"]
if os.environ.get("AVALON_TASK") not in tasks:
active = False
enabled = False
# Can be modified by settings
profiles = [{
"hosts": [],
"task_types": [],
"tasks": [],
"validate": False
}]
def process(self, context):
# Skip if there are no profiles
validate = True
if self.profiles:
# Collect data from context
task_name = context.data.get("task")
task_type = context.data.get("taskType")
host_name = context.data.get("hostName")
filter_data = {
"hosts": host_name,
"task_types": task_type,
"tasks": task_name
}
matching_profile = filter_profiles(
self.profiles, filter_data, logger=self.log
)
if matching_profile:
validate = matching_profile["validate"]
if not validate:
self.log.debug((
"Validation of intent was skipped."
" Matching profile for current context disabled validation."
))
return
msg = (
"Please make sure that you select the intent of this publish."
)
intent = context.data.get("intent")
self.log.debug(intent)
assert intent, msg
intent = context.data.get("intent") or {}
self.log.debug(str(intent))
intent_value = intent.get("value")
assert intent is not "", msg
if not intent_value:
raise AssertionError(msg)

View file

@ -8,6 +8,10 @@
"enabled": true,
"optional": false
},
"ValidateIntent": {
"enabled": false,
"profiles": []
},
"IntegrateHeroVersion": {
"enabled": true,
"optional": true,

View file

@ -44,6 +44,59 @@
}
]
},
{
"type": "dict",
"label": "Validate Intent",
"key": "ValidateIntent",
"is_group": true,
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "label",
"label": "Validate if Publishing intent was selected. It is possible to disable validation for specific publishing context with profiles."
},
{
"type": "list",
"collapsible": true,
"key": "profiles",
"object_type": {
"type": "dict",
"children": [
{
"key": "hosts",
"label": "Host names",
"type": "hosts-enum",
"multiselection": true
},
{
"key": "task_types",
"label": "Task types",
"type": "task-types-enum"
},
{
"key": "tasks",
"label": "Task names",
"type": "list",
"object_type": "text"
},
{
"type": "separator"
},
{
"key": "validate",
"label": "Validate",
"type": "boolean"
}
]
}
}
]
},
{
"type": "dict",
"collapsible": true,