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

Context Validation Repair Action enhancements #6207

Closed
Show file tree
Hide file tree
Changes from all 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
28 changes: 23 additions & 5 deletions openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from maya import cmds, mel
from maya.api import OpenMaya

from ayon_api import get_task_by_name
from openpype.client import (
get_project,
get_asset_by_name,
Expand Down Expand Up @@ -2614,17 +2615,34 @@ def reset_scene_resolution():
project_name = get_current_project_name()
project_doc = get_project(project_name)
project_data = project_doc["data"]
asset_data = get_current_project_asset()["data"]
asset_data_root = get_current_project_asset()
asset_data = asset_data_root["data"]

task_name = get_current_task_name()
task_entity = get_task_by_name(
project_name, asset_data_root["_id"], task_name)


# Set project resolution
width_key = "resolutionWidth"
height_key = "resolutionHeight"
pixelAspect_key = "pixelAspect"

width = asset_data.get(width_key, project_data.get(width_key, 1920))
height = asset_data.get(height_key, project_data.get(height_key, 1080))
pixelAspect = asset_data.get(pixelAspect_key,
project_data.get(pixelAspect_key, 1))
# Get frame information from task entity
# NOTE: If there is no task override then the asset
# value is automatically returned instead
width = task_entity["attrib"].get(
width_key,
asset_data.get(
width_key, project_data.get(width_key, 1920)))
height = task_entity["attrib"].get(
height_key,
asset_data.get(
height_key, project_data.get(height_key, 1080)))
pixelAspect = task_entity["attrib"].get(
pixelAspect_key,
asset_data.get(
pixelAspect_key, project_data.get(pixelAspect_key, 1080)))

set_scene_resolution(width, height, pixelAspect)

Expand Down
54 changes: 41 additions & 13 deletions openpype/hosts/maya/plugins/publish/validate_frame_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,26 @@ def process(self, instance):
)
return

frame_start_handle = int(context.data.get("frameStartHandle"))
frame_end_handle = int(context.data.get("frameEndHandle"))
handle_start = int(context.data.get("handleStart"))
handle_end = int(context.data.get("handleEnd"))
frame_start = int(context.data.get("frameStart"))
frame_end = int(context.data.get("frameEnd"))
# Get frame information from task entity
# NOTE: If there is no task override then the asset
# value is automatically returned instead
task_entity = instance.context.data["taskEntity"]
frame_start_handle = task_entity["attrib"]["frameStart"] - \
task_entity["attrib"]["handleStart"]
frame_end_handle = task_entity["attrib"]["frameEnd"] + \
task_entity["attrib"]["handleEnd"]
handle_start = task_entity["attrib"]["handleStart"]
handle_end = task_entity["attrib"]["handleEnd"]
frame_start = task_entity["attrib"]["frameStart"]
frame_end = task_entity["attrib"]["frameEnd"]

# Get frame information from asset context
# frame_start_handle = int(context.data.get("frameStartHandle"))
# frame_end_handle = int(context.data.get("frameEndHandle"))
# handle_start = int(context.data.get("handleStart"))
# handle_end = int(context.data.get("handleEnd"))
# frame_start = int(context.data.get("frameStart"))
# frame_end = int(context.data.get("frameEnd"))

inst_start = int(instance.data.get("frameStartHandle"))
inst_end = int(instance.data.get("frameEndHandle"))
Expand Down Expand Up @@ -117,7 +131,7 @@ def process(self, instance):
@classmethod
def repair(cls, instance):
"""
Repair instance container to match asset data.
Repair instance container to match task / asset data.
"""

if "renderlayer" in instance.data.get("families"):
Expand All @@ -128,12 +142,26 @@ def repair(cls, instance):
node = instance.data["name"]
context = instance.context

frame_start_handle = int(context.data.get("frameStartHandle"))
frame_end_handle = int(context.data.get("frameEndHandle"))
handle_start = int(context.data.get("handleStart"))
handle_end = int(context.data.get("handleEnd"))
frame_start = int(context.data.get("frameStart"))
frame_end = int(context.data.get("frameEnd"))
# Get frame information from task entity
# NOTE: If there is no task override then the asset
# value is automatically returned instead
task_entity = instance.context.data["taskEntity"]
frame_start_handle = task_entity["attrib"]["frameStart"] - \
task_entity["attrib"]["handleStart"]
frame_end_handle = task_entity["attrib"]["frameEnd"] + \
task_entity["attrib"]["handleEnd"]
handle_start = task_entity["attrib"]["handleStart"]
handle_end = task_entity["attrib"]["handleEnd"]
frame_start = task_entity["attrib"]["frameStart"]
frame_end = task_entity["attrib"]["frameEnd"]

# Get frame information from asset context
# frame_start_handle = int(context.data.get("frameStartHandle"))
# frame_end_handle = int(context.data.get("frameEndHandle"))
# handle_start = int(context.data.get("handleStart"))
# handle_end = int(context.data.get("handleEnd"))
# frame_start = int(context.data.get("frameStart"))
# frame_end = int(context.data.get("frameEnd"))

# Start
if cmds.attributeQuery("handleStart", node=node, exists=True):
Expand Down
6 changes: 5 additions & 1 deletion openpype/hosts/maya/plugins/publish/validate_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ def get_invalid_resolution(cls, instance):

@classmethod
def get_db_resolution(cls, instance):
task_doc = instance.context.data["taskEntity"]
asset_doc = instance.data["assetEntity"]
project_doc = instance.context.data["projectEntity"]
for data in [asset_doc["data"], project_doc["data"]]:
for data in [
task_doc["attrib"],
asset_doc["data"],
project_doc["data"]]:
if (
"resolutionWidth" in data and
"resolutionHeight" in data and
Expand Down
6 changes: 6 additions & 0 deletions openpype/plugins/publish/collect_context_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import pyblish.api

from ayon_api import get_task_by_name

from openpype.client import get_project, get_asset_by_name
from openpype.pipeline import KnownPublishError

Expand Down Expand Up @@ -51,6 +53,10 @@ def process(self, context):

context.data["assetEntity"] = asset_entity

task_entity = get_task_by_name(
project_name, asset_entity["_id"], task_name)
context.data["taskEntity"] = task_entity

data = asset_entity['data']

# Task type
Expand Down
Loading