From a7a72d4f6fa8b06217308f8c54ed9817e9ee20c1 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Fri, 9 Apr 2021 11:14:20 +0100 Subject: [PATCH 1/8] Validate mark in and out. # Conflicts: # openpype/hosts/tvpaint/plugins/publish/validate_marks.py --- .../tvpaint/plugins/publish/validate_marks.py | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 openpype/hosts/tvpaint/plugins/publish/validate_marks.py diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py new file mode 100644 index 0000000000..e6fd3c05af --- /dev/null +++ b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py @@ -0,0 +1,66 @@ +import json + +import pyblish.api +from avalon.tvpaint import lib + + +class ValidateMarksRepair(pyblish.api.Action): + """Repair the marks.""" + + label = "Repair" + icon = "wrench" + on = "failed" + + def process(self, context, plugin): + expected_data = ValidateMarks().get_expected_data(context) + lib.execute_george("tv_markin {} set".format(expected_data["markIn"])) + lib.execute_george( + "tv_markout {} set".format(expected_data["markOut"]) + ) + + +class ValidateMarks(pyblish.api.ContextPlugin): + """Validate mark in and out are enabled.""" + + label = "Validate Marks" + order = pyblish.api.ValidatorOrder + optional = True + actions = [ValidateMarksRepair] + + def get_expected_data(self, context): + return { + "markIn": context.data["assetEntity"]["data"]["frameStart"] - 1, + "markInState": True, + "markOut": context.data["assetEntity"]["data"]["frameEnd"] - 1, + "markOutState": True + } + + def process(self, context): + # Marks return as "{frame - 1} {state} ", example "0 set". + result = lib.execute_george("tv_markin") + mark_in_frame, mark_in_state, _ = result.split(" ") + + result = lib.execute_george("tv_markout") + mark_out_frame, mark_out_state, _ = result.split(" ") + + current_data = { + "markIn": int(mark_in_frame), + "markInState": mark_in_state == "set", + "markOut": int(mark_out_frame), + "markOutState": mark_out_state == "set" + } + expected_data = self.get_expected_data(context) + invalid = {} + for k in current_data.keys(): + if current_data[k] != expected_data[k]: + invalid[k] = { + "current": current_data[k], + "expected_data": expected_data[k] + } + + if invalid: + raise AssertionError( + "Marks does not match database:\n{}".format( + json.dumps(invalid, sort_keys=True, indent=4) + ) + ) From 05454f3cf221ca484084c2ced9450ffc826d83de Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Fri, 9 Apr 2021 11:32:31 +0100 Subject: [PATCH 2/8] Use static method instead of initializing class. --- openpype/hosts/tvpaint/plugins/publish/validate_marks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py index e6fd3c05af..e34b24d825 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py @@ -12,7 +12,7 @@ class ValidateMarksRepair(pyblish.api.Action): on = "failed" def process(self, context, plugin): - expected_data = ValidateMarks().get_expected_data(context) + expected_data = ValidateMarks.get_expected_data(context) lib.execute_george("tv_markin {} set".format(expected_data["markIn"])) lib.execute_george( "tv_markout {} set".format(expected_data["markOut"]) @@ -27,7 +27,8 @@ class ValidateMarks(pyblish.api.ContextPlugin): optional = True actions = [ValidateMarksRepair] - def get_expected_data(self, context): + @staticmethod + def get_expected_data(context): return { "markIn": context.data["assetEntity"]["data"]["frameStart"] - 1, "markInState": True, @@ -55,7 +56,7 @@ class ValidateMarks(pyblish.api.ContextPlugin): if current_data[k] != expected_data[k]: invalid[k] = { "current": current_data[k], - "expected_data": expected_data[k] + "expected": expected_data[k] } if invalid: From 0c08dcae73b1bf1f3b09d1a1eec55ffa4119ca47 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 14 Apr 2021 09:39:49 +0100 Subject: [PATCH 3/8] Accurate frame information to user. --- .../hosts/tvpaint/plugins/publish/validate_marks.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py index e34b24d825..e491d87835 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py @@ -13,6 +13,10 @@ class ValidateMarksRepair(pyblish.api.Action): def process(self, context, plugin): expected_data = ValidateMarks.get_expected_data(context) + + expected_data["markIn"] -= 1 + expected_data["markOut"] -= 1 + lib.execute_george("tv_markin {} set".format(expected_data["markIn"])) lib.execute_george( "tv_markout {} set".format(expected_data["markOut"]) @@ -30,9 +34,9 @@ class ValidateMarks(pyblish.api.ContextPlugin): @staticmethod def get_expected_data(context): return { - "markIn": context.data["assetEntity"]["data"]["frameStart"] - 1, + "markIn": int(context.data["frameStart"]), "markInState": True, - "markOut": context.data["assetEntity"]["data"]["frameEnd"] - 1, + "markOut": int(context.data["frameEnd"]), "markOutState": True } @@ -45,9 +49,9 @@ class ValidateMarks(pyblish.api.ContextPlugin): mark_out_frame, mark_out_state, _ = result.split(" ") current_data = { - "markIn": int(mark_in_frame), + "markIn": int(mark_in_frame) + 1, "markInState": mark_in_state == "set", - "markOut": int(mark_out_frame), + "markOut": int(mark_out_frame) + 1, "markOutState": mark_out_state == "set" } expected_data = self.get_expected_data(context) From 493e5cfa1dd077d2281ebf38b085a7b9dee4e064 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 14 Apr 2021 09:43:14 +0100 Subject: [PATCH 4/8] Remove frame range validation from project settings validator. --- .../hosts/tvpaint/plugins/publish/validate_project_settings.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py b/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py index fead3393ae..84c03a9857 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py @@ -13,8 +13,6 @@ class ValidateProjectSettings(pyblish.api.ContextPlugin): def process(self, context): scene_data = { - "frameStart": context.data.get("sceneFrameStart"), - "frameEnd": context.data.get("sceneFrameEnd"), "fps": context.data.get("sceneFps"), "resolutionWidth": context.data.get("sceneWidth"), "resolutionHeight": context.data.get("sceneHeight"), From bc401969ba568eb6bcd51e80366c588659931632 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 14 Apr 2021 10:33:02 +0100 Subject: [PATCH 5/8] Collect and use mark in/out frame and state. # Conflicts: # pype/plugins/tvpaint/publish/collect_instances.py --- .../plugins/publish/collect_workfile_data.py | 34 +++++++------------ .../tvpaint/plugins/publish/validate_marks.py | 15 +++----- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py b/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py index e683c66ea9..4409413ff6 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py @@ -122,36 +122,26 @@ class CollectWorkfileData(pyblish.api.ContextPlugin): width = int(workfile_info_parts.pop(-1)) workfile_path = " ".join(workfile_info_parts).replace("\"", "") - frame_start, frame_end = self.collect_clip_frames() + # Marks return as "{frame - 1} {state} ", example "0 set". + result = lib.execute_george("tv_markin") + mark_in_frame, mark_in_state, _ = result.split(" ") + + result = lib.execute_george("tv_markout") + mark_out_frame, mark_out_state, _ = result.split(" ") + scene_data = { "currentFile": workfile_path, "sceneWidth": width, "sceneHeight": height, "scenePixelAspect": pixel_apsect, - "sceneFrameStart": frame_start, - "sceneFrameEnd": frame_end, "sceneFps": frame_rate, - "sceneFieldOrder": field_order + "sceneFieldOrder": field_order, + "sceneMarkIn": int(mark_in_frame), + "sceneMarkInState": mark_in_state == "set", + "sceneMarkOut": int(mark_out_frame), + "sceneMarkOutState": mark_out_state == "set" } self.log.debug( "Scene data: {}".format(json.dumps(scene_data, indent=4)) ) context.data.update(scene_data) - - def collect_clip_frames(self): - clip_info_str = lib.execute_george("tv_clipinfo") - self.log.debug("Clip info: {}".format(clip_info_str)) - clip_info_items = clip_info_str.split(" ") - # Color index - not used - clip_info_items.pop(-1) - clip_info_items.pop(-1) - - mark_out = int(clip_info_items.pop(-1)) - frame_end = mark_out + 1 - clip_info_items.pop(-1) - - mark_in = int(clip_info_items.pop(-1)) - frame_start = mark_in + 1 - clip_info_items.pop(-1) - - return frame_start, frame_end diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py index e491d87835..73486d1005 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py @@ -41,18 +41,11 @@ class ValidateMarks(pyblish.api.ContextPlugin): } def process(self, context): - # Marks return as "{frame - 1} {state} ", example "0 set". - result = lib.execute_george("tv_markin") - mark_in_frame, mark_in_state, _ = result.split(" ") - - result = lib.execute_george("tv_markout") - mark_out_frame, mark_out_state, _ = result.split(" ") - current_data = { - "markIn": int(mark_in_frame) + 1, - "markInState": mark_in_state == "set", - "markOut": int(mark_out_frame) + 1, - "markOutState": mark_out_state == "set" + "markIn": context.data["sceneMarkIn"] + 1, + "markInState": context.data["sceneMarkInState"], + "markOut": context.data["sceneMarkOut"] + 1, + "markOutState": context.data["sceneMarkOutState"] } expected_data = self.get_expected_data(context) invalid = {} From 722340e33e84f425b6f6cec4108645f1129ea778 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 14 Apr 2021 12:54:00 +0200 Subject: [PATCH 6/8] fix resolve of conflict --- .../hosts/tvpaint/plugins/publish/collect_instances.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 68c142c005..0808dc06b1 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -34,8 +34,8 @@ class CollectInstances(pyblish.api.ContextPlugin): instance_data["name"] = name instance_data["label"] = "{} [{}-{}]".format( name, - context.data["sceneFrameStart"], - context.data["sceneFrameEnd"] + context.data["sceneMarkIn"] + 1, + context.data["sceneMarkOut"] + 1 ) active = instance_data.get("active", True) @@ -78,8 +78,8 @@ class CollectInstances(pyblish.api.ContextPlugin): if instance is None: continue - instance.data["frameStart"] = context.data["sceneFrameStart"] - instance.data["frameEnd"] = context.data["sceneFrameEnd"] + instance.data["frameStart"] = context.data["sceneMarkIn"] + 1 + instance.data["frameEnd"] = context.data["sceneMarkOut"] + 1 self.log.debug("Created instance: {}\n{}".format( instance, json.dumps(instance.data, indent=4) From 42b772c5fb12463324c46134e6b4112caa9b44b3 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 14 Apr 2021 13:01:33 +0200 Subject: [PATCH 7/8] fixed validator name --- openpype/settings/defaults/project_settings/tvpaint.json | 2 +- .../schemas/projects_schema/schema_project_tvpaint.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index d4130c88be..c5b3f3d5b6 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -1,6 +1,6 @@ { "publish": { - "ValidateMissingLayers": { + "ValidateProjectSettings": { "enabled": true, "optional": true, "active": true diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json index b9fe26a57c..375c4262de 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -17,8 +17,9 @@ "name": "template_publish_plugin", "template_data": [ { - "key": "ValidateMissingLayers", - "label": "ValidateMissingLayers" + "key": "ValidateProjectSettings", + "label": "ValidateProjectSettings", + "docstring": "Validate if FPS and Resolution match shot data" } ] } From c2fd9b0148aa08c3e8cff288793dbd12acb66fbb Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 14 Apr 2021 13:01:47 +0200 Subject: [PATCH 8/8] added validate mark in/out to settings --- .../settings/defaults/project_settings/tvpaint.json | 5 +++++ .../projects_schema/schema_project_tvpaint.json | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index c5b3f3d5b6..a6c10b3809 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -4,6 +4,11 @@ "enabled": true, "optional": true, "active": true + }, + "ValidateMarks": { + "enabled": true, + "optional": true, + "active": true } }, "filters": {} diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json index 375c4262de..0a9e7139dd 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -22,6 +22,17 @@ "docstring": "Validate if FPS and Resolution match shot data" } ] + }, + { + "type": "schema_template", + "name": "template_publish_plugin", + "template_data": [ + { + "key": "ValidateMarks", + "label": "Validate MarkIn/Out", + "docstring": "Validate MarkIn/Out match Frame start/end on shot data" + } + ] } ] },