From 12557526c32e9d38d77d8ba73d3ff8a45975890b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 19:47:29 +0100 Subject: [PATCH 1/8] integrate ftrack note use label from ftrack's custom attribute configuration --- .../ftrack/publish/integrate_ftrack_note.py | 71 +++++++++++++++++-- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/pype/plugins/ftrack/publish/integrate_ftrack_note.py b/pype/plugins/ftrack/publish/integrate_ftrack_note.py index 2621ca96aba..9d040585d5f 100644 --- a/pype/plugins/ftrack/publish/integrate_ftrack_note.py +++ b/pype/plugins/ftrack/publish/integrate_ftrack_note.py @@ -1,4 +1,5 @@ import sys +import json import pyblish.api import six @@ -18,6 +19,47 @@ class IntegrateFtrackNote(pyblish.api.InstancePlugin): # - note label must exist in Ftrack note_labels = [] + def get_intent_label(self, session, intent_value): + if not intent_value: + return + + intent_configurations = session.query( + "CustomAttributeConfiguration where key is intent" + ).all() + if not intent_configurations: + return + + intent_configuration = intent_configurations[0] + if len(intent_configuration) > 1: + self.log.warning(( + "Found more than one `intent` custom attribute." + " Using first found." + )) + + config = intent_configuration.get("config") + if not config: + return + + items = config.get("data") + if not items: + return + + if sys.version_info[0] < 3: + string_type = basestring + else: + string_type = str + + if isinstance(items, string_type): + items = json.loads(items) + + intent_label = None + for item in items: + if item["value"] == intent_value: + intent_label = item["menu"] + break + + return intent_label + def process(self, instance): comment = (instance.context.data.get("comment") or "").strip() if not comment: @@ -26,17 +68,33 @@ def process(self, instance): self.log.debug("Comment is set to `{}`".format(comment)) - intent = instance.context.data.get("intent") - if intent: - msg = "Intent is set to `{}` and was added to comment.".format( - intent - ) + session = instance.context.data["ftrackSession"] + + intent_val = instance.context.data.get("intent", {}).get("value") + intent_label = None + if intent_val: + intent_label = self.get_intent_label(session, intent_val) + if intent_label is None: + intent_label = intent_val + + # if intent label is set then format comment + # - it is possible that intent_label is equal to "" (empty string) + if intent_label: + msg = "Intent label is to `{}`.".format(intent_label) comment = self.note_with_intent_template.format(**{ - "intent": intent, + "intent": intent_val, "comment": comment }) + + elif intent_val: + msg = ( + "Intent is set to `{}` and was not added" + " to comment because label is set to `{}`." + ).format(intent_val, intent_label) + else: msg = "Intent is not set." + self.log.debug(msg) asset_versions_key = "ftrackIntegratedAssetVersions" @@ -45,7 +103,6 @@ def process(self, instance): self.log.info("There are any integrated AssetVersions") return - session = instance.context.data["ftrackSession"] user = session.query( "User where username is \"{}\"".format(session.api_user) ).first() From d2f9336b4541ce1ace974b6e162da525b2dad8c3 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 19:51:20 +0100 Subject: [PATCH 2/8] updated intent getting --- pype/plugins/ftrack/publish/integrate_ftrack_instances.py | 2 +- pype/plugins/global/publish/extract_burnin.py | 2 +- pype/plugins/nuke/publish/extract_slate_frame.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pype/plugins/ftrack/publish/integrate_ftrack_instances.py b/pype/plugins/ftrack/publish/integrate_ftrack_instances.py index ec57f46d618..591dcf0dc28 100644 --- a/pype/plugins/ftrack/publish/integrate_ftrack_instances.py +++ b/pype/plugins/ftrack/publish/integrate_ftrack_instances.py @@ -127,7 +127,7 @@ def process(self, instance): # Add custom attributes for AssetVersion assetversion_cust_attrs = {} - intent_val = instance.context.data.get("intent") + intent_val = instance.context.data.get("intent", {}).get("value") if intent_val: assetversion_cust_attrs["intent"] = intent_val diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index 1251e5c02fa..be287fbb144 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -52,7 +52,7 @@ def process(self, instance): "duration": duration, "version": int(version), "comment": instance.context.data.get("comment", ""), - "intent": instance.context.data.get("intent", "") + "intent": instance.context.data.get("intent", {}).get("label", "") }) # get anatomy project diff --git a/pype/plugins/nuke/publish/extract_slate_frame.py b/pype/plugins/nuke/publish/extract_slate_frame.py index 0d8bfe9dc52..eff51d95d47 100644 --- a/pype/plugins/nuke/publish/extract_slate_frame.py +++ b/pype/plugins/nuke/publish/extract_slate_frame.py @@ -157,7 +157,7 @@ def add_comment_slate_node(self, instance): return comment = instance.context.data.get("comment") - intent = instance.context.data.get("intent") + intent = instance.context.data.get("intent", {}).get("value") try: node["f_submission_note"].setValue(comment) From 354c8d7a50092e7f998552abc5c6433e2e2b54ff Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 19:51:52 +0100 Subject: [PATCH 3/8] set intent only if set in extract burnin --- pype/plugins/global/publish/extract_burnin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index be287fbb144..086a1fdfb2b 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -51,10 +51,13 @@ def process(self, instance): "frame_end": frame_end_handle, "duration": duration, "version": int(version), - "comment": instance.context.data.get("comment", ""), - "intent": instance.context.data.get("intent", {}).get("label", "") + "comment": instance.context.data.get("comment", "") }) + intent = instance.context.data.get("intent", {}).get("label") + if intent: + prep_data["intent"] = intent + # get anatomy project anatomy = instance.context.data['anatomy'] From 349beaccfc5ca213771325c84e4ef8dec4ecdc0b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 19:52:04 +0100 Subject: [PATCH 4/8] collect anatomy docs cleanup --- pype/plugins/global/publish/collect_anatomy.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pype/plugins/global/publish/collect_anatomy.py b/pype/plugins/global/publish/collect_anatomy.py index ae83e395139..73ae3bb024b 100644 --- a/pype/plugins/global/publish/collect_anatomy.py +++ b/pype/plugins/global/publish/collect_anatomy.py @@ -6,10 +6,6 @@ username -> collect_pype_user *(pyblish.api.CollectorOrder + 0.001) datetimeData -> collect_datetime_data *(pyblish.api.CollectorOrder) -Optional: - comment -> collect_comment *(pyblish.api.CollectorOrder) - intent -> collected in pyblish-lite - Provides: context -> anatomy (pypeapp.Anatomy) context -> anatomyData From 8072f1dcc9736eeacd3387fb8ddc276725c39d7a Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 19:52:59 +0100 Subject: [PATCH 5/8] removed intent from required keys in collect rendered files --- pype/plugins/global/publish/collect_rendered_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/plugins/global/publish/collect_rendered_files.py b/pype/plugins/global/publish/collect_rendered_files.py index 010cf44c151..552fd49f6d0 100644 --- a/pype/plugins/global/publish/collect_rendered_files.py +++ b/pype/plugins/global/publish/collect_rendered_files.py @@ -35,7 +35,7 @@ def _load_json(self, path): def _process_path(self, data): # validate basic necessary data data_err = "invalid json file - missing data" - required = ["asset", "user", "intent", "comment", + required = ["asset", "user", "comment", "job", "instances", "session", "version"] assert all(elem in data.keys() for elem in required), data_err From f37ea5d82ae82b9c8c04ba06d86f982a120035ad Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 20:09:14 +0100 Subject: [PATCH 6/8] intent is not required in extract slate frame --- pype/plugins/nuke/publish/extract_slate_frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/plugins/nuke/publish/extract_slate_frame.py b/pype/plugins/nuke/publish/extract_slate_frame.py index eff51d95d47..369cbe0496b 100644 --- a/pype/plugins/nuke/publish/extract_slate_frame.py +++ b/pype/plugins/nuke/publish/extract_slate_frame.py @@ -157,7 +157,7 @@ def add_comment_slate_node(self, instance): return comment = instance.context.data.get("comment") - intent = instance.context.data.get("intent", {}).get("value") + intent = instance.context.data.get("intent", {}).get("value", "") try: node["f_submission_note"].setValue(comment) From 0d20e27cb3d7912fc5f7a7716473c55df495c24c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 20:13:51 +0100 Subject: [PATCH 7/8] it is used default intent label in ftrack if ftrack's not found --- .../ftrack/publish/integrate_ftrack_note.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pype/plugins/ftrack/publish/integrate_ftrack_note.py b/pype/plugins/ftrack/publish/integrate_ftrack_note.py index 9d040585d5f..a0e7719779d 100644 --- a/pype/plugins/ftrack/publish/integrate_ftrack_note.py +++ b/pype/plugins/ftrack/publish/integrate_ftrack_note.py @@ -71,18 +71,19 @@ def process(self, instance): session = instance.context.data["ftrackSession"] intent_val = instance.context.data.get("intent", {}).get("value") - intent_label = None + intent_label = instance.context.data.get("intent", {}).get("label") + final_label = None if intent_val: - intent_label = self.get_intent_label(session, intent_val) - if intent_label is None: - intent_label = intent_val + final_label = self.get_intent_label(session, intent_val) + if final_label is None: + final_label = intent_label # if intent label is set then format comment # - it is possible that intent_label is equal to "" (empty string) - if intent_label: - msg = "Intent label is to `{}`.".format(intent_label) + if final_label: + msg = "Intent label is set to `{}`.".format(final_label) comment = self.note_with_intent_template.format(**{ - "intent": intent_val, + "intent": final_label, "comment": comment }) @@ -90,7 +91,7 @@ def process(self, instance): msg = ( "Intent is set to `{}` and was not added" " to comment because label is set to `{}`." - ).format(intent_val, intent_label) + ).format(intent_val, final_label) else: msg = "Intent is not set." From c91b49510045afc5903db2eff5813bc8a09bab39 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 16 Mar 2020 20:22:02 +0100 Subject: [PATCH 8/8] fix ftrack json parse --- pype/plugins/ftrack/publish/integrate_ftrack_note.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pype/plugins/ftrack/publish/integrate_ftrack_note.py b/pype/plugins/ftrack/publish/integrate_ftrack_note.py index a0e7719779d..679010ca588 100644 --- a/pype/plugins/ftrack/publish/integrate_ftrack_note.py +++ b/pype/plugins/ftrack/publish/integrate_ftrack_note.py @@ -40,7 +40,8 @@ def get_intent_label(self, session, intent_value): if not config: return - items = config.get("data") + configuration = json.loads(config) + items = configuration.get("data") if not items: return