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

Feature/PYPE-733 intent store label value #2

Merged
merged 8 commits into from
Mar 17, 2020
2 changes: 1 addition & 1 deletion pype/plugins/ftrack/publish/integrate_ftrack_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
73 changes: 66 additions & 7 deletions pype/plugins/ftrack/publish/integrate_ftrack_note.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
import json
import pyblish.api
import six

Expand All @@ -18,6 +19,48 @@ 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

configuration = json.loads(config)
items = configuration.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:
Expand All @@ -26,17 +69,34 @@ 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 = instance.context.data.get("intent", {}).get("label")
final_label = None
if 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 final_label:
msg = "Intent label is set to `{}`.".format(final_label)
comment = self.note_with_intent_template.format(**{
"intent": intent,
"intent": final_label,
"comment": comment
})

elif intent_val:
msg = (
"Intent is set to `{}` and was not added"
" to comment because label is set to `{}`."
).format(intent_val, final_label)

else:
msg = "Intent is not set."

self.log.debug(msg)

asset_versions_key = "ftrackIntegratedAssetVersions"
Expand All @@ -45,7 +105,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()
Expand Down
4 changes: 0 additions & 4 deletions pype/plugins/global/publish/collect_anatomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pype/plugins/global/publish/collect_rendered_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions pype/plugins/global/publish/extract_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
"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']

Expand Down
2 changes: 1 addition & 1 deletion pype/plugins/nuke/publish/extract_slate_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down