diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 61cf7eb7806..9b11f9fe80b 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -1,3 +1,4 @@ +import os import json import copy import pyblish.api @@ -109,7 +110,7 @@ def _create_review_instance_data(self, context): return { "family": "review", - "asset": context.data["workfile_context"]["asset"], + "asset": context.data["asset"], # Dummy subset name "subset": "reviewMain" } diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_workfile.py b/openpype/hosts/tvpaint/plugins/publish/collect_workfile.py new file mode 100644 index 00000000000..b059be90bf6 --- /dev/null +++ b/openpype/hosts/tvpaint/plugins/publish/collect_workfile.py @@ -0,0 +1,43 @@ +import os +import json +import pyblish.api +from avalon import io + + +class CollectWorkfile(pyblish.api.ContextPlugin): + label = "Collect Workfile" + order = pyblish.api.CollectorOrder - 1 + hosts = ["tvpaint"] + + def process(self, context): + current_file = context.data["currentFile"] + + self.log.info( + "Workfile path used for workfile family: {}".format(current_file) + ) + + dirpath, filename = os.path.split(current_file) + basename, ext = os.path.splitext(filename) + instance = context.create_instance(name=basename) + + task_name = io.Session["AVALON_TASK"] + subset_name = "workfile" + task_name.capitalize() + + # Create Workfile instance + instance.data.update({ + "subset": subset_name, + "asset": context.data["asset"], + "label": subset_name, + "publish": True, + "family": "workfile", + "families": ["workfile"], + "representations": [{ + "name": ext.lstrip("."), + "ext": ext.lstrip("."), + "files": filename, + "stagingDir": dirpath + }] + }) + self.log.info("Collected workfile instance: {}".format( + json.dumps(instance.data, indent=4) + )) diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_workfile_metadata.py b/openpype/hosts/tvpaint/plugins/publish/validate_workfile_metadata.py new file mode 100644 index 00000000000..757da3294a2 --- /dev/null +++ b/openpype/hosts/tvpaint/plugins/publish/validate_workfile_metadata.py @@ -0,0 +1,49 @@ +import pyblish.api +from avalon.tvpaint import save_file + + +class ValidateWorkfileMetadataRepair(pyblish.api.Action): + """Store current context into workfile metadata.""" + + label = "Use current context" + icon = "wrench" + on = "failed" + + def process(self, context, _plugin): + """Save current workfile which should trigger storing of metadata.""" + current_file = context.data["currentFile"] + # Save file should trigger + save_file(current_file) + + +class ValidateWorkfileMetadata(pyblish.api.ContextPlugin): + """Validate if wokrfile contain required metadata for publising.""" + + label = "Validate Workfile Metadata" + order = pyblish.api.ValidatorOrder + + families = ["workfile"] + + actions = [ValidateWorkfileMetadataRepair] + + required_keys = {"project", "asset", "task"} + + def process(self, context): + workfile_context = context.data["workfile_context"] + if not workfile_context: + raise AssertionError( + "Current workfile is missing whole metadata about context." + ) + + missing_keys = [] + for key in self.required_keys: + value = workfile_context.get(key) + if not value: + missing_keys.append(key) + + if missing_keys: + raise AssertionError( + "Current workfile is missing metadata about {}.".format( + ", ".join(missing_keys) + ) + ) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index 47abced4576..769a0d39192 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -1686,7 +1686,7 @@ def video_filters(self): def _convert_string_to_values(self, orig_string_value): string_value = orig_string_value.strip().lower() if not string_value: - return + return [PixValueRelative(0), PixValueRelative(0)] # Replace "px" (and spaces before) with single space string_value = re.sub(r"([ ]+)?px", " ", string_value)