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
Changes from 1 commit
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
32 changes: 26 additions & 6 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,32 @@ 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 to the task doc of the project, folder path and task
project_name = instance.context.data["projectEntity"]["name"]
folder_path = instance.context.data["asset"]
task_name = instance.context.data["task"]
from ayon_api import get_task_by_name, get_folder_by_path
folder = get_folder_by_path(project_name, folder_path)
asset_id = folder["id"]
task = get_task_by_name(project_name, asset_id, task_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The validator should not be querying this data - right? This should've been readily collected in the Collectors.

Doing this per instance like this I'm pretty sure will be very slow. This is much better batch collected in a Collector.


Side note: wasn't aware Ayon had frame data per task instead of per folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BigRoy so would you recommended adding a "CollectTaskEntity" to the Maya host collectors.
I want to store the task doc attributes for later query in validators.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, task entity collecting would make sense. It's happening already for projectEntity and assetEntity or alike on both context and instance (note that Instance MAY target a different asset than current context and thus might need a validation against that instead of the context).

I'd look up which collector is currently storing projectEntity and assetEntity which I think it does in a bulk query from a ContextPlugin and add the data collection for taskEntity there as well (if task is set on the instance/context, etc.)

@iLLiCiTiT thoughts?

Copy link
Contributor Author

@bradenjennings bradenjennings Feb 8, 2024

Choose a reason for hiding this comment

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

I found where project and asset entity are added to context, this is in

collect_context_entities.py

I now prepare and cache the "taskEntity"here.
https://github.com/ynput/OpenPype/pull/6207/files#diff-65495e9f1aba1baa5c1f7517ad5f56e80c42990db087260f8ee4a5eee6edb1c1R17

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BigRoy it seems get_task_by_name is only in ayon_api.

I guess I need to make OpenPype legacy work without ayon in the mix?

In which case I should test if AYON_SERVER_ENABLED, and then only do the query in ayon.

I assume there was no API for this in legacy OpenPype

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would be easier if I don't have to back support OpenPype without AYON.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, there's no equivalent "task" data in OpenPype as far as I know.

Since this is in the OpenPype repo I'm pretty sure you'll still need to maintain backwards compatibility. But might be a better question forwarded to @mkolar or @iLLiCiTiT


# Get frame information from task context
# NOTE: there is no "frameStartHandle" and "frameEndHandle" on task.
# NOTE: So im making the frame start handle equal to the handleStart.
frame_start_handle = task["attrib"]["handleStart"]
frame_end_handle = task["attrib"]["handleStart"]
handle_start = task["attrib"]["handleStart"]
handle_end = task["attrib"]["handleEnd"]
frame_start = task["attrib"]["frameStart"]
frame_end = task["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
Loading