From 3c6d807df54a44d51956a33cda083fb93ec3a92e Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Wed, 20 Oct 2021 10:20:13 +0200 Subject: [PATCH 01/19] add dict for task name short and type --- openpype/hosts/maya/api/customize.py | 9 +++-- .../plugins/publish/extract_harmony_zip.py | 11 ++++-- openpype/lib/anatomy.py | 8 +++++ openpype/lib/avalon_context.py | 36 +++++++++---------- .../defaults/project_anatomy/templates.json | 4 +-- .../schemas/schema_anatomy_templates.json | 4 +++ openpype/settings/lib.py | 7 ++++ openpype/tools/workfiles/app.py | 21 +++++++++-- 8 files changed, 74 insertions(+), 26 deletions(-) diff --git a/openpype/hosts/maya/api/customize.py b/openpype/hosts/maya/api/customize.py index a84412963b..0b95073ea0 100644 --- a/openpype/hosts/maya/api/customize.py +++ b/openpype/hosts/maya/api/customize.py @@ -84,7 +84,7 @@ def override_toolbox_ui(): log.warning("Could not import Loader tool") try: - from avalon.maya.pipeline import launch_workfiles_app + from openpype.tools import workfiles as launch_workfiles_app except Exception: log.warning("Could not import Workfiles tool") @@ -142,7 +142,12 @@ def override_toolbox_ui(): annotation="Work Files", label="Work Files", image=os.path.join(icons, "workfiles.png"), - command=lambda: launch_workfiles_app(), + command=lambda: launch_workfiles_app.show( + os.path.join( + mc.workspace(query=True, rootDirectory=True), + mc.workspace(fileRuleEntry="scene") + ) + ), bgc=background_color, width=icon_size, height=icon_size, diff --git a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py index adbac6ef09..8014349de3 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py @@ -220,6 +220,10 @@ class ExtractHarmonyZip(openpype.api.Extractor): anatomy = openpype.api.Anatomy() project_entity = instance.context.data["projectEntity"] + task_name = instance.data.get("task") + task_type = instance.data['tasks'].get(task_name, {}).get('type') + task_short = project_entity['config']['tasks'][task_type]['short_name'] + data = { "root": api.registered_root(), "project": { @@ -229,14 +233,17 @@ class ExtractHarmonyZip(openpype.api.Extractor): "asset": instance.data["asset"], "hierarchy": openpype.api.get_hierarchy(instance.data["asset"]), "family": instance.data["family"], - "task": instance.data.get("task"), + "task": { + "name": task_name, + "type": task_type, + "short": task_short, + }, "subset": instance.data["subset"], "version": 1, "ext": "zip", } host_name = "harmony" template_name = get_workfile_template_key_from_context( - instance.data["asset"], instance.data.get("task"), host_name, project_name=project_entity["name"], diff --git a/openpype/lib/anatomy.py b/openpype/lib/anatomy.py index 7a4a55363c..78dc323d4d 100644 --- a/openpype/lib/anatomy.py +++ b/openpype/lib/anatomy.py @@ -989,6 +989,10 @@ class Templates: invalid_required = [] missing_required = [] replace_keys = [] + + if "{task[name]}" in orig_template and not isinstance(data["task"], dict): + data['task']= {'name': data.get("task")} + for group in self.key_pattern.findall(template): orig_key = group[1:-1] key = str(orig_key) @@ -1074,6 +1078,10 @@ class Templates: output = collections.defaultdict(dict) for key, orig_value in templates.items(): if isinstance(orig_value, StringType): + # Replace {task} by '{task[name]}' for backward compatibility + if '{task}' in orig_value: + orig_value = orig_value.replace('{task}', '{task[name]}') + output[key] = self._format(orig_value, data) continue diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index b043cbfdb4..1f28a5088f 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -7,6 +7,7 @@ import platform import logging import collections import functools +import getpass from openpype.settings import get_project_settings from .anatomy import Anatomy @@ -346,7 +347,7 @@ def get_latest_version(asset_name, subset_name, dbcon=None, project_name=None): def get_workfile_template_key_from_context( - asset_name, task_name, host_name, project_name=None, + task_info, host_name, project_name=None, dbcon=None, project_settings=None ): """Helper function to get template key for workfile template. @@ -358,9 +359,8 @@ def get_workfile_template_key_from_context( 'project_name' arguments. Args: - asset_name(str): Name of asset document. - task_name(str): Task name for which is template key retrieved. - Must be available on asset document under `data.tasks`. + task_info(dict): Information about the task is used to retrieve the + `type` of the task. host_name(str): Name of host implementation for which is workfile used. project_name(str): Project name where asset and task is. Not required @@ -387,17 +387,6 @@ def get_workfile_template_key_from_context( elif not project_name: project_name = dbcon.Session["AVALON_PROJECT"] - asset_doc = dbcon.find_one( - { - "type": "asset", - "name": asset_name - }, - { - "data.tasks": 1 - } - ) - asset_tasks = asset_doc.get("data", {}).get("tasks") or {} - task_info = asset_tasks.get(task_name) or {} task_type = task_info.get("type") return get_workfile_template_key( @@ -479,15 +468,27 @@ def get_workdir_data(project_doc, asset_doc, task_name, host_name): """ hierarchy = "/".join(asset_doc["data"]["parents"]) + task_type = asset_doc['data']['tasks'].get(task_name, {}).get('type') + + if task_type: + task_code = project_doc['config']['tasks'][task_type]['short_name'] + else: + task_code = None + data = { "project": { "name": project_doc["name"], "code": project_doc["data"].get("code") }, - "task": task_name, + "task": { + "name": task_name, + "type": task_type, + "short": task_code, + }, "asset": asset_doc["name"], "app": host_name, - "hierarchy": hierarchy + "user": getpass.getuser(), + "hierarchy": hierarchy, } return data @@ -530,7 +531,6 @@ def get_workdir_with_workdir_data( if not template_key: template_key = get_workfile_template_key_from_context( - workdir_data["asset"], workdir_data["task"], workdir_data["app"], project_name=workdir_data["project"]["name"], diff --git a/openpype/settings/defaults/project_anatomy/templates.json b/openpype/settings/defaults/project_anatomy/templates.json index 53abd35ed5..c6e79b8dcd 100644 --- a/openpype/settings/defaults/project_anatomy/templates.json +++ b/openpype/settings/defaults/project_anatomy/templates.json @@ -6,8 +6,8 @@ "frame": "{frame:0>{@frame_padding}}" }, "work": { - "folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/work/{task}", - "file": "{project[code]}_{asset}_{task}_{@version}<_{comment}>.{ext}", + "folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/work/{task[user]}", + "file": "{project[code]}_{asset}_{task[user]}_{@version}<_{comment}>.{ext}", "path": "{@folder}/{@file}" }, "render": { diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json index a8534e7e29..be8d6661cf 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json @@ -11,6 +11,10 @@ "type": "dict", "key": "defaults", "children": [ + { + "type": "label", + "label": "The list of existing default placeholders for the construction of paths:
{root[`root_name`]}, {project[name]}, {project[short]}, {hierarchy}, {asset}, {task[name]}, {task[type]}, {task[code]}, {family}, {subset}, {output}, {ext}, {thumbnail_root}, {_id}, {thumbnail_type} " + }, { "type": "number", "key": "version_padding", diff --git a/openpype/settings/lib.py b/openpype/settings/lib.py index 60ed54bd4a..88ce8b6719 100644 --- a/openpype/settings/lib.py +++ b/openpype/settings/lib.py @@ -856,6 +856,13 @@ def get_anatomy_settings( apply_local_settings_on_anatomy_settings( result, local_settings, project_name, site_name ) + + # Replace {task} by '{task[name]}' in all template for backward compatibility + for template in result.get('templates', {}).values(): + for sub_template_name, sub_template_value in template.items(): + if isinstance(sub_template_value, str) and '{task}' in sub_template_value: + template[sub_template_name] = sub_template_value.replace('{task}', '{task[name]}') + return result diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index 6fff0d0278..716c417cd1 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -65,16 +65,33 @@ class NameWindow(QtWidgets.QDialog): {"type": "project"}, { "name": True, - "data.code": True + "data.code": True, + "config.tasks": True, } ) + asset_doc = io.find_one({ + "type": "asset", + "name": asset_name + }) + + task_type = asset_doc['data']['tasks'].get(session["AVALON_TASK"], {}).get('type') + + if task_type: + task_short = project_doc['config']['tasks'][task_type]['short_name'] + else: + task_short = None + self.data = { "project": { "name": project_doc["name"], "code": project_doc["data"].get("code") }, "asset": asset_name, - "task": session["AVALON_TASK"], + "task": { + "name": session["AVALON_TASK"], + "type": task_type, + "short": task_short, + }, "version": 1, "user": getpass.getuser(), "comment": "", From 52ce86060f01028c4921931559f93a2e79fdad24 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Wed, 20 Oct 2021 10:26:09 +0200 Subject: [PATCH 02/19] change task name --- openpype/settings/defaults/project_anatomy/templates.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/settings/defaults/project_anatomy/templates.json b/openpype/settings/defaults/project_anatomy/templates.json index c6e79b8dcd..9a03b893bf 100644 --- a/openpype/settings/defaults/project_anatomy/templates.json +++ b/openpype/settings/defaults/project_anatomy/templates.json @@ -6,8 +6,8 @@ "frame": "{frame:0>{@frame_padding}}" }, "work": { - "folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/work/{task[user]}", - "file": "{project[code]}_{asset}_{task[user]}_{@version}<_{comment}>.{ext}", + "folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/work/{task[name]}", + "file": "{project[code]}_{asset}_{task[name]}_{@version}<_{comment}>.{ext}", "path": "{@folder}/{@file}" }, "render": { From a7f5130741a5eb279ec19ca34debfe10385e3ce0 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 21 Oct 2021 11:20:19 +0200 Subject: [PATCH 03/19] remove change on get_anatomy_settings --- openpype/settings/lib.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/openpype/settings/lib.py b/openpype/settings/lib.py index 88ce8b6719..ff75562413 100644 --- a/openpype/settings/lib.py +++ b/openpype/settings/lib.py @@ -857,12 +857,6 @@ def get_anatomy_settings( result, local_settings, project_name, site_name ) - # Replace {task} by '{task[name]}' in all template for backward compatibility - for template in result.get('templates', {}).values(): - for sub_template_name, sub_template_value in template.items(): - if isinstance(sub_template_value, str) and '{task}' in sub_template_value: - template[sub_template_name] = sub_template_value.replace('{task}', '{task[name]}') - return result From f4641e1eda2b1c0673af0ee3701534b62efed09f Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Thu, 21 Oct 2021 11:20:40 +0200 Subject: [PATCH 04/19] add suggestion --- openpype/lib/anatomy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openpype/lib/anatomy.py b/openpype/lib/anatomy.py index 78dc323d4d..aaf10479fd 100644 --- a/openpype/lib/anatomy.py +++ b/openpype/lib/anatomy.py @@ -990,8 +990,12 @@ class Templates: missing_required = [] replace_keys = [] - if "{task[name]}" in orig_template and not isinstance(data["task"], dict): - data['task']= {'name': data.get("task")} + task_data = data.get("task") + if ( + isinstance(task_data, StringType) + and "{task[name]}" in orig_template + ): + data["task"] = {"name": task_data} for group in self.key_pattern.findall(template): orig_key = group[1:-1] From bb544efbc6c13e584017e75e2464bff0b7052119 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Fri, 22 Oct 2021 07:22:20 +0200 Subject: [PATCH 05/19] Fix line too long --- openpype/tools/workfiles/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index 716c417cd1..9e06a2f310 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -74,10 +74,12 @@ class NameWindow(QtWidgets.QDialog): "name": asset_name }) - task_type = asset_doc['data']['tasks'].get(session["AVALON_TASK"], {}).get('type') + task_type = asset_doc["data"]["tasks"].get( + session["AVALON_TASK"], {}).get("type") if task_type: - task_short = project_doc['config']['tasks'][task_type]['short_name'] + task_short = project_doc["config"]["tasks"].get( + task_type, {}).get("short_name") else: task_short = None From bdf81f21370324e5c46d425368ffdbfe988f1414 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Fri, 22 Oct 2021 16:42:06 +0200 Subject: [PATCH 06/19] remove openpype workfile --- openpype/hosts/maya/api/customize.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/openpype/hosts/maya/api/customize.py b/openpype/hosts/maya/api/customize.py index 0b95073ea0..a84412963b 100644 --- a/openpype/hosts/maya/api/customize.py +++ b/openpype/hosts/maya/api/customize.py @@ -84,7 +84,7 @@ def override_toolbox_ui(): log.warning("Could not import Loader tool") try: - from openpype.tools import workfiles as launch_workfiles_app + from avalon.maya.pipeline import launch_workfiles_app except Exception: log.warning("Could not import Workfiles tool") @@ -142,12 +142,7 @@ def override_toolbox_ui(): annotation="Work Files", label="Work Files", image=os.path.join(icons, "workfiles.png"), - command=lambda: launch_workfiles_app.show( - os.path.join( - mc.workspace(query=True, rootDirectory=True), - mc.workspace(fileRuleEntry="scene") - ) - ), + command=lambda: launch_workfiles_app(), bgc=background_color, width=icon_size, height=icon_size, From af2450fb0401b12b0b1afab52dfae2725c0039a8 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Mon, 25 Oct 2021 15:12:25 +0200 Subject: [PATCH 07/19] remove change on get_workfile_template_key_from_context --- .../plugins/publish/extract_harmony_zip.py | 7 +++--- openpype/lib/avalon_context.py | 25 +++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py index 8014349de3..fd89b089c4 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py @@ -11,7 +11,7 @@ import zipfile import pyblish.api from avalon import api, io import openpype.api -from openpype.lib import get_workfile_template_key_from_context +from openpype.lib import get_workfile_template_key class ExtractHarmonyZip(openpype.api.Extractor): @@ -243,11 +243,10 @@ class ExtractHarmonyZip(openpype.api.Extractor): "ext": "zip", } host_name = "harmony" - template_name = get_workfile_template_key_from_context( - instance.data.get("task"), + template_name = get_workfile_template_key( + instance.data.get("task").get("type"), host_name, project_name=project_entity["name"], - dbcon=io ) # Get a valid work filename first with version 1 diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 1f28a5088f..817e79b7c8 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -347,7 +347,7 @@ def get_latest_version(asset_name, subset_name, dbcon=None, project_name=None): def get_workfile_template_key_from_context( - task_info, host_name, project_name=None, + asset_name, task_name, host_name, project_name=None, dbcon=None, project_settings=None ): """Helper function to get template key for workfile template. @@ -359,10 +359,9 @@ def get_workfile_template_key_from_context( 'project_name' arguments. Args: - task_info(dict): Information about the task is used to retrieve the - `type` of the task. - host_name(str): Name of host implementation for which is workfile - used. + asset_name(str): Name of asset document. + task_name(str): Task name for which is template key retrieved. + Must be available on asset document under `data.tasks`. project_name(str): Project name where asset and task is. Not required when 'dbcon' is passed. dbcon(AvalonMongoDB): Connection to mongo with already set project @@ -387,6 +386,17 @@ def get_workfile_template_key_from_context( elif not project_name: project_name = dbcon.Session["AVALON_PROJECT"] + asset_doc = dbcon.find_one( + { + "type": "asset", + "name": asset_name + }, + { + "data.tasks": 1 + } + ) + asset_tasks = asset_doc.get("data", {}).get("tasks") or {} + task_info = asset_tasks.get(task_name) or {} task_type = task_info.get("type") return get_workfile_template_key( @@ -530,11 +540,10 @@ def get_workdir_with_workdir_data( anatomy = Anatomy(project_name) if not template_key: - template_key = get_workfile_template_key_from_context( - workdir_data["task"], + template_key = get_workfile_template_key( + workdir_data["task"].get("type"), workdir_data["app"], project_name=workdir_data["project"]["name"], - dbcon=dbcon ) anatomy_filled = anatomy.format(workdir_data) From 17af919d7500aaa7a5a51cf9b9977448e917283d Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Mon, 25 Oct 2021 15:16:20 +0200 Subject: [PATCH 08/19] replace docstring --- openpype/lib/avalon_context.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index 817e79b7c8..fa14589760 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -362,6 +362,8 @@ def get_workfile_template_key_from_context( asset_name(str): Name of asset document. task_name(str): Task name for which is template key retrieved. Must be available on asset document under `data.tasks`. + host_name(str): Name of host implementation for which is workfile + used. project_name(str): Project name where asset and task is. Not required when 'dbcon' is passed. dbcon(AvalonMongoDB): Connection to mongo with already set project From 7ec884f2d5082dd8ca9acff8af988cd94fdd51b2 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Tue, 26 Oct 2021 17:22:27 +0200 Subject: [PATCH 09/19] filled anatomyData in publish plugins --- .../plugins/publish/collect_farm_render.py | 3 ++- .../plugins/publish/collect_palettes.py | 2 +- .../plugins/publish/collect_harmony_scenes.py | 18 ++++++++++++- .../plugins/publish/collect_harmony_zips.py | 25 +++++++++++++++---- .../plugins/publish/extract_harmony_zip.py | 12 +++++---- openpype/lib/applications.py | 4 +++ .../plugins/publish/collect_ftrack_api.py | 2 +- .../publish/collect_anatomy_context_data.py | 15 ++++++++++- .../publish/collect_anatomy_instance_data.py | 6 ++--- openpype/plugins/publish/integrate_new.py | 20 ++++++--------- 10 files changed, 76 insertions(+), 31 deletions(-) diff --git a/openpype/hosts/harmony/plugins/publish/collect_farm_render.py b/openpype/hosts/harmony/plugins/publish/collect_farm_render.py index fc80e7c029..31a249591e 100644 --- a/openpype/hosts/harmony/plugins/publish/collect_farm_render.py +++ b/openpype/hosts/harmony/plugins/publish/collect_farm_render.py @@ -126,7 +126,8 @@ class CollectFarmRender(openpype.lib.abstract_collect_render. # because of using 'renderFarm' as a family, replace 'Farm' with # capitalized task name - issue of avalon-core Creator app subset_name = node.split("/")[1] - task_name = context.data["anatomyData"]["task"].capitalize() + task_name = context.data["anatomyData"]["task"][ + "name"].capitalize() replace_str = "" if task_name.lower() not in subset_name.lower(): replace_str = task_name diff --git a/openpype/hosts/harmony/plugins/publish/collect_palettes.py b/openpype/hosts/harmony/plugins/publish/collect_palettes.py index b8671badb3..e47cbaf17e 100644 --- a/openpype/hosts/harmony/plugins/publish/collect_palettes.py +++ b/openpype/hosts/harmony/plugins/publish/collect_palettes.py @@ -28,7 +28,7 @@ class CollectPalettes(pyblish.api.ContextPlugin): # skip collecting if not in allowed task if self.allowed_tasks: - task_name = context.data["anatomyData"]["task"].lower() + task_name = context.data["anatomyData"]["task"]["name"].lower() if (not any([re.search(pattern, task_name) for pattern in self.allowed_tasks])): return diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py index a4fed3bc3f..f76e46bc78 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py @@ -49,10 +49,26 @@ class CollectHarmonyScenes(pyblish.api.InstancePlugin): # fix anatomy data anatomy_data_new = copy.deepcopy(anatomy_data) + + project_entity = context.data["projectEntity"] + asset_entity = context.data["assetEntity"] + + task_type = asset_entity["data"]["tasks"].get(task, {}).get("type") + + if task_type: + task_code = project_entity["config"]["tasks"][task_type][ + "short_name"] + else: + task_code = None + # updating hierarchy data anatomy_data_new.update({ "asset": asset_data["name"], - "task": task, + "task": { + "name": task, + "type": task_type, + "short": task_code, + }, "subset": subset_name }) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py index 93eff85486..f7282ae6e9 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py @@ -27,6 +27,7 @@ class CollectHarmonyZips(pyblish.api.InstancePlugin): anatomy_data = instance.context.data["anatomyData"] repres = instance.data["representations"] files = repres[0]["files"] + project_entity = context.data["projectEntity"] if files.endswith(".zip"): # A zip file was dropped @@ -45,14 +46,28 @@ class CollectHarmonyZips(pyblish.api.InstancePlugin): self.log.info("Copied data: {}".format(new_instance.data)) + task_type = asset_data["data"]["tasks"].get(task, {}).get("type") + + if task_type: + task_code = project_entity["config"]["tasks"][task_type][ + "short_name"] + else: + task_code = None + # fix anatomy data anatomy_data_new = copy.deepcopy(anatomy_data) # updating hierarchy data - anatomy_data_new.update({ - "asset": asset_data["name"], - "task": task, - "subset": subset_name - }) + anatomy_data_new.update( + { + "asset": asset_data["name"], + "task": { + "name": task, + "type": task_type, + "short": task_code, + }, + "subset": subset_name, + } + ) new_instance.data["label"] = f"{instance_name}" new_instance.data["subset"] = subset_name diff --git a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py index fd89b089c4..2318c6176f 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py @@ -31,8 +31,10 @@ class ExtractHarmonyZip(openpype.api.Extractor): # Presets create_workfile = True - default_task = "harmonyIngest" - default_task_type = "Ingest" + default_task = { + "name": "harmonyIngest", + "type": "Ingest", + } default_task_status = "Ingested" assetversion_status = "Ingested" @@ -220,9 +222,9 @@ class ExtractHarmonyZip(openpype.api.Extractor): anatomy = openpype.api.Anatomy() project_entity = instance.context.data["projectEntity"] - task_name = instance.data.get("task") - task_type = instance.data['tasks'].get(task_name, {}).get('type') - task_short = project_entity['config']['tasks'][task_type]['short_name'] + task_name = instance.data.get("task").get("name") + task_type = instance.data.get("task").get("type") + task_short = instance.data.get("task").get("short") data = { "root": api.registered_root(), diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index cc8cb8e7be..c536f9fd15 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1361,6 +1361,10 @@ def _prepare_last_workfile(data, workdir, workfile_template_key): anatomy = data["anatomy"] # Find last workfile file_template = anatomy.templates["work"]["file"] + # Replace {task} by '{task[name]}' for backward compatibility + if '{task}' in file_template: + file_template = file_template.replace('{task}', '{task[name]}') + workdir_data.update({ "version": 1, "user": get_openpype_username(), diff --git a/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py b/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py index a348617cfc..984e76d8ca 100644 --- a/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py +++ b/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py @@ -109,7 +109,7 @@ class CollectFtrackApi(pyblish.api.ContextPlugin): "Checking entities of instance \"{}\"".format(str(instance)) ) instance_asset_name = instance.data.get("asset") - instance_task_name = instance.data.get("task") + instance_task_name = instance.data.get("task").get("name") if not instance_asset_name and not instance_task_name: self.log.debug("Instance does not have set context keys.") diff --git a/openpype/plugins/publish/collect_anatomy_context_data.py b/openpype/plugins/publish/collect_anatomy_context_data.py index ec88d5669d..7d6482e911 100644 --- a/openpype/plugins/publish/collect_anatomy_context_data.py +++ b/openpype/plugins/publish/collect_anatomy_context_data.py @@ -54,6 +54,15 @@ class CollectAnatomyContextData(pyblish.api.ContextPlugin): if hierarchy_items: hierarchy = os.path.join(*hierarchy_items) + task_type = asset_entity['data']['tasks'].get( + task_name, {}).get('type') + + if task_type: + task_code = project_entity['config']['tasks'][task_type][ + 'short_name'] + else: + task_code = None + context_data = { "project": { "name": project_entity["name"], @@ -61,7 +70,11 @@ class CollectAnatomyContextData(pyblish.api.ContextPlugin): }, "asset": asset_entity["name"], "hierarchy": hierarchy.replace("\\", "/"), - "task": task_name, + "task": { + "name": task_name, + "type": task_type, + "short": task_code, + }, "username": context.data["user"], "app": context.data["hostName"] } diff --git a/openpype/plugins/publish/collect_anatomy_instance_data.py b/openpype/plugins/publish/collect_anatomy_instance_data.py index 4fd657167c..e8eba0c5d3 100644 --- a/openpype/plugins/publish/collect_anatomy_instance_data.py +++ b/openpype/plugins/publish/collect_anatomy_instance_data.py @@ -238,9 +238,9 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): anatomy_updates["hierarchy"] = "/".join(parents) # Task - task_name = instance.data.get("task") - if task_name: - anatomy_updates["task"] = task_name + task_info = instance.data.get("task") + if task_info: + anatomy_updates["task"] = task_info # Additional data resolution_width = instance.data.get("resolutionWidth") diff --git a/openpype/plugins/publish/integrate_new.py b/openpype/plugins/publish/integrate_new.py index 451ea1d80d..16b936c0e6 100644 --- a/openpype/plugins/publish/integrate_new.py +++ b/openpype/plugins/publish/integrate_new.py @@ -171,19 +171,13 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): anatomy_data["hierarchy"] = hierarchy # Make sure task name in anatomy data is same as on instance.data - task_name = instance.data.get("task") - if task_name: - anatomy_data["task"] = task_name + task_info = instance.data.get("task") + if task_info: + anatomy_data["task"] = task_info else: - # Just set 'task_name' variable to context task - task_name = anatomy_data["task"] + # Just set 'task_info' variable to context task + task_info = anatomy_data["task"] - # Find task type for current task name - # - this should be already prepared on instance - asset_tasks = ( - asset_entity.get("data", {}).get("tasks") - ) or {} - task_info = asset_tasks.get(task_name) or {} task_type = task_info.get("type") instance.data["task_type"] = task_type @@ -321,7 +315,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): key_values = { "families": family, - "tasks": task_name, + "tasks": task_info.get("name"), "hosts": instance.context.data["hostName"], "task_types": task_type } @@ -804,7 +798,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): # data? # - should we use context task in that case? task_name = ( - instance.data["anatomyData"]["task"] + instance.data["anatomyData"]["task"].get("name") or io.Session["AVALON_TASK"] ) task_type = instance.data["task_type"] From 46de3e116fe3ea297b814947df117723136f097d Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Tue, 26 Oct 2021 17:29:04 +0200 Subject: [PATCH 10/19] fix indent error --- openpype/plugins/publish/collect_anatomy_context_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/collect_anatomy_context_data.py b/openpype/plugins/publish/collect_anatomy_context_data.py index 7d6482e911..96cf39cd2a 100644 --- a/openpype/plugins/publish/collect_anatomy_context_data.py +++ b/openpype/plugins/publish/collect_anatomy_context_data.py @@ -61,7 +61,7 @@ class CollectAnatomyContextData(pyblish.api.ContextPlugin): task_code = project_entity['config']['tasks'][task_type][ 'short_name'] else: - task_code = None + task_code = None context_data = { "project": { From 90c9f6cd10ed7f1a6661f336bf215a77f10b93ba Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Fri, 29 Oct 2021 10:11:44 +0200 Subject: [PATCH 11/19] Update documentation --- .../projects_schema/schemas/schema_anatomy_templates.json | 2 +- website/docs/admin_settings_project_anatomy.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json index be8d6661cf..e208069e6f 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_anatomy_templates.json @@ -13,7 +13,7 @@ "children": [ { "type": "label", - "label": "The list of existing default placeholders for the construction of paths:
{root[`root_name`]}, {project[name]}, {project[short]}, {hierarchy}, {asset}, {task[name]}, {task[type]}, {task[code]}, {family}, {subset}, {output}, {ext}, {thumbnail_root}, {_id}, {thumbnail_type} " + "label": "The list of existing placeholders is available here:
https://openpype.io/docs/admin_settings_project_anatomy/#available-template-keys " }, { "type": "number", diff --git a/website/docs/admin_settings_project_anatomy.md b/website/docs/admin_settings_project_anatomy.md index 54023d468f..30784686e2 100644 --- a/website/docs/admin_settings_project_anatomy.md +++ b/website/docs/admin_settings_project_anatomy.md @@ -57,7 +57,9 @@ We have a few required anatomy templates for OpenPype to work properly, however | `project[code]` | Project's code | | `hierarchy` | All hierarchical parents as subfolders | | `asset` | Name of asset or shot | -| `task` | Name of task | +| `task[name]` | Name of task | +| `task[type]` | Type of task | +| `task[short]` | Shortname of task | | `version` | Version number | | `subset` | Subset name | | `family` | Main family name | From 30ec2f5218af3dc9164267f23171ac282b9e6188 Mon Sep 17 00:00:00 2001 From: "clement.hector" Date: Tue, 2 Nov 2021 09:56:52 +0100 Subject: [PATCH 12/19] Get task type and short_name from db --- .../plugins/publish/extract_harmony_zip.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py index 2318c6176f..ceac710bb5 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/extract_harmony_zip.py @@ -221,10 +221,19 @@ class ExtractHarmonyZip(openpype.api.Extractor): # Setup the data needed to form a valid work path filename anatomy = openpype.api.Anatomy() project_entity = instance.context.data["projectEntity"] + asset_entity = io.find_one({ + "type": "asset", + "name": instance.data["asset"] + }) - task_name = instance.data.get("task").get("name") - task_type = instance.data.get("task").get("type") - task_short = instance.data.get("task").get("short") + task_name = instance.data.get("task") + task_type = asset_entity["data"]["tasks"][task_name].get("type") + + if task_type: + task_short = project_entity["config"]["tasks"].get( + task_type, {}).get("short_name") + else: + task_short = None data = { "root": api.registered_root(), From 1f4777c48a98f53dbe0f04cf7746c38275bce173 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 15:22:40 +0100 Subject: [PATCH 13/19] removed unused argument --- openpype/lib/applications.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index c536f9fd15..3a82e4b068 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1295,10 +1295,10 @@ def prepare_context_environments(data): ) data["env"].update(context_env) - _prepare_last_workfile(data, workdir, workfile_template_key) + _prepare_last_workfile(data, workdir) -def _prepare_last_workfile(data, workdir, workfile_template_key): +def _prepare_last_workfile(data, workdir): """last workfile workflow preparation. Function check if should care about last workfile workflow and tries From 789e13b1a51df605ddff340508fb97c44e50e36b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 15:23:03 +0100 Subject: [PATCH 14/19] removed dbcon argument as is not used --- openpype/lib/avalon_context.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index fa14589760..e74ecd7281 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -506,8 +506,7 @@ def get_workdir_data(project_doc, asset_doc, task_name, host_name): def get_workdir_with_workdir_data( - workdir_data, anatomy=None, project_name=None, - template_key=None, dbcon=None + workdir_data, anatomy=None, project_name=None, template_key=None ): """Fill workdir path from entered data and project's anatomy. @@ -659,7 +658,7 @@ def create_workfile_doc(asset_doc, task_name, filename, workdir, dbcon=None): anatomy = Anatomy(project_doc["name"]) # Get workdir path (result is anatomy.TemplateResult) template_workdir = get_workdir_with_workdir_data( - workdir_data, anatomy, dbcon=dbcon + workdir_data, anatomy ) template_workdir_path = str(template_workdir).replace("\\", "/") From 73ead413a27287c4a614f50e567d66e28bc31f7e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 15:23:22 +0100 Subject: [PATCH 15/19] we know that type key is available on workdir data --- openpype/lib/avalon_context.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index e74ecd7281..bf04aa4435 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -542,9 +542,9 @@ def get_workdir_with_workdir_data( if not template_key: template_key = get_workfile_template_key( - workdir_data["task"].get("type"), + workdir_data["task"]["type"], workdir_data["app"], - project_name=workdir_data["project"]["name"], + project_name=workdir_data["project"]["name"] ) anatomy_filled = anatomy.format(workdir_data) From c4c8cc17f4d93b1b8d7efc4276e846359d48ff3b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 15:39:04 +0100 Subject: [PATCH 16/19] simplified application launch --- openpype/lib/applications.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/openpype/lib/applications.py b/openpype/lib/applications.py index 3a82e4b068..e190c38fd9 100644 --- a/openpype/lib/applications.py +++ b/openpype/lib/applications.py @@ -1246,23 +1246,12 @@ def prepare_context_environments(data): anatomy = data["anatomy"] - asset_tasks = asset_doc.get("data", {}).get("tasks") or {} - task_info = asset_tasks.get(task_name) or {} - task_type = task_info.get("type") + task_type = workdir_data["task"]["type"] # Temp solution how to pass task type to `_prepare_last_workfile` data["task_type"] = task_type - workfile_template_key = get_workfile_template_key( - task_type, - app.host_name, - project_name=project_name, - project_settings=project_settings - ) - try: - workdir = get_workdir_with_workdir_data( - workdir_data, anatomy, template_key=workfile_template_key - ) + workdir = get_workdir_with_workdir_data(workdir_data, anatomy) except Exception as exc: raise ApplicationLaunchFailed( From 733448e132ba5b727e5de0114585e293ccdc128c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 15:40:23 +0100 Subject: [PATCH 17/19] simplified getting short name --- .../plugins/publish/collect_harmony_scenes.py | 8 ++----- .../plugins/publish/collect_harmony_zips.py | 10 +++----- openpype/lib/avalon_context.py | 6 ++--- .../publish/collect_anatomy_context_data.py | 11 ++++----- openpype/tools/workfiles/app.py | 24 +++++++++---------- 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py index f76e46bc78..48c36aa067 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_scenes.py @@ -54,12 +54,8 @@ class CollectHarmonyScenes(pyblish.api.InstancePlugin): asset_entity = context.data["assetEntity"] task_type = asset_entity["data"]["tasks"].get(task, {}).get("type") - - if task_type: - task_code = project_entity["config"]["tasks"][task_type][ - "short_name"] - else: - task_code = None + project_task_types = project_entity["config"]["tasks"] + task_code = project_task_types.get(task_type, {}).get("short_name") # updating hierarchy data anatomy_data_new.update({ diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py index f7282ae6e9..40a969f8df 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_harmony_zips.py @@ -47,12 +47,8 @@ class CollectHarmonyZips(pyblish.api.InstancePlugin): self.log.info("Copied data: {}".format(new_instance.data)) task_type = asset_data["data"]["tasks"].get(task, {}).get("type") - - if task_type: - task_code = project_entity["config"]["tasks"][task_type][ - "short_name"] - else: - task_code = None + project_task_types = project_entity["config"]["tasks"] + task_code = project_task_types.get(task_type, {}).get("short_name") # fix anatomy data anatomy_data_new = copy.deepcopy(anatomy_data) @@ -65,7 +61,7 @@ class CollectHarmonyZips(pyblish.api.InstancePlugin): "type": task_type, "short": task_code, }, - "subset": subset_name, + "subset": subset_name } ) diff --git a/openpype/lib/avalon_context.py b/openpype/lib/avalon_context.py index bf04aa4435..dd9e8b2ab8 100644 --- a/openpype/lib/avalon_context.py +++ b/openpype/lib/avalon_context.py @@ -482,10 +482,8 @@ def get_workdir_data(project_doc, asset_doc, task_name, host_name): task_type = asset_doc['data']['tasks'].get(task_name, {}).get('type') - if task_type: - task_code = project_doc['config']['tasks'][task_type]['short_name'] - else: - task_code = None + project_task_types = project_doc["config"]["tasks"] + task_code = project_task_types.get(task_type, {}).get("short_name") data = { "project": { diff --git a/openpype/plugins/publish/collect_anatomy_context_data.py b/openpype/plugins/publish/collect_anatomy_context_data.py index 96cf39cd2a..6b95979b76 100644 --- a/openpype/plugins/publish/collect_anatomy_context_data.py +++ b/openpype/plugins/publish/collect_anatomy_context_data.py @@ -54,14 +54,11 @@ class CollectAnatomyContextData(pyblish.api.ContextPlugin): if hierarchy_items: hierarchy = os.path.join(*hierarchy_items) - task_type = asset_entity['data']['tasks'].get( - task_name, {}).get('type') + asset_tasks = asset_entity["data"]["tasks"] + task_type = asset_tasks.get(task_name, {}).get("type") - if task_type: - task_code = project_entity['config']['tasks'][task_type][ - 'short_name'] - else: - task_code = None + project_task_types = project_entity["config"]["tasks"] + task_code = project_task_types.get(task_type, {}).get("short_name") context_data = { "project": { diff --git a/openpype/tools/workfiles/app.py b/openpype/tools/workfiles/app.py index 9e06a2f310..314ec0a0e1 100644 --- a/openpype/tools/workfiles/app.py +++ b/openpype/tools/workfiles/app.py @@ -61,6 +61,7 @@ class NameWindow(QtWidgets.QDialog): # Set work file data for template formatting asset_name = session["AVALON_ASSET"] + task_name = session["AVALON_TASK"] project_doc = io.find_one( {"type": "project"}, { @@ -69,19 +70,18 @@ class NameWindow(QtWidgets.QDialog): "config.tasks": True, } ) - asset_doc = io.find_one({ - "type": "asset", - "name": asset_name - }) + asset_doc = io.find_one( + { + "type": "asset", + "name": asset_name + }, + {"data.tasks": True} + ) - task_type = asset_doc["data"]["tasks"].get( - session["AVALON_TASK"], {}).get("type") + task_type = asset_doc["data"]["tasks"].get(task_name, {}).get("type") - if task_type: - task_short = project_doc["config"]["tasks"].get( - task_type, {}).get("short_name") - else: - task_short = None + project_task_types = project_doc["config"]["tasks"] + task_short = project_task_types.get(task_type, {}).get("short_name") self.data = { "project": { @@ -90,7 +90,7 @@ class NameWindow(QtWidgets.QDialog): }, "asset": asset_name, "task": { - "name": session["AVALON_TASK"], + "name": task_name, "type": task_type, "short": task_short, }, From c3738a4d2f16ca115dc4866c45ad6af7483f120b Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 4 Nov 2021 15:43:34 +0100 Subject: [PATCH 18/19] instance.data["task"] is not task info but string --- .../plugins/publish/collect_ftrack_api.py | 2 +- .../publish/collect_anatomy_instance_data.py | 19 ++++++++-- openpype/plugins/publish/integrate_new.py | 36 +++++++++++-------- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py b/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py index 984e76d8ca..a348617cfc 100644 --- a/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py +++ b/openpype/modules/default_modules/ftrack/plugins/publish/collect_ftrack_api.py @@ -109,7 +109,7 @@ class CollectFtrackApi(pyblish.api.ContextPlugin): "Checking entities of instance \"{}\"".format(str(instance)) ) instance_asset_name = instance.data.get("asset") - instance_task_name = instance.data.get("task").get("name") + instance_task_name = instance.data.get("task") if not instance_asset_name and not instance_task_name: self.log.debug("Instance does not have set context keys.") diff --git a/openpype/plugins/publish/collect_anatomy_instance_data.py b/openpype/plugins/publish/collect_anatomy_instance_data.py index e8eba0c5d3..286a14485f 100644 --- a/openpype/plugins/publish/collect_anatomy_instance_data.py +++ b/openpype/plugins/publish/collect_anatomy_instance_data.py @@ -212,6 +212,8 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): project_doc = context.data["projectEntity"] context_asset_doc = context.data["assetEntity"] + project_task_types = project_doc["config"]["tasks"] + for instance in context: version_number = instance.data.get("version") # If version is not specified for instance or context @@ -238,9 +240,20 @@ class CollectAnatomyInstanceData(pyblish.api.ContextPlugin): anatomy_updates["hierarchy"] = "/".join(parents) # Task - task_info = instance.data.get("task") - if task_info: - anatomy_updates["task"] = task_info + task_name = instance.data.get("task") + if task_name: + asset_tasks = asset_doc["data"]["tasks"] + task_type = asset_tasks.get(task_name, {}).get("type") + task_code = ( + project_task_types + .get(task_type, {}) + .get("short_name") + ) + anatomy_updates["task"] = { + "name": task_name, + "type": task_type, + "short": task_code + } # Additional data resolution_width = instance.data.get("resolutionWidth") diff --git a/openpype/plugins/publish/integrate_new.py b/openpype/plugins/publish/integrate_new.py index 16b936c0e6..0898275cd8 100644 --- a/openpype/plugins/publish/integrate_new.py +++ b/openpype/plugins/publish/integrate_new.py @@ -171,15 +171,26 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): anatomy_data["hierarchy"] = hierarchy # Make sure task name in anatomy data is same as on instance.data - task_info = instance.data.get("task") - if task_info: - anatomy_data["task"] = task_info - else: - # Just set 'task_info' variable to context task - task_info = anatomy_data["task"] + asset_tasks = ( + asset_entity.get("data", {}).get("tasks") + ) or {} + task_name = instance.data.get("task") + if task_name: + task_info = asset_tasks.get(task_name) or {} + task_type = task_info.get("type") - task_type = task_info.get("type") - instance.data["task_type"] = task_type + project_task_types = project_entity["config"]["tasks"] + task_code = project_task_types.get(task_type, {}).get("short_name") + anatomy_data["task"] = { + "name": task_name, + "type": task_type, + "short": task_code + } + + else: + # Just set 'task_name' variable to context task + task_name = anatomy_data["task"]["name"] + task_type = anatomy_data["task"]["type"] # Fill family in anatomy data anatomy_data["family"] = instance.data.get("family") @@ -315,7 +326,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): key_values = { "families": family, - "tasks": task_info.get("name"), + "tasks": task_name, "hosts": instance.context.data["hostName"], "task_types": task_type } @@ -797,11 +808,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): # - is there a chance that task name is not filled in anatomy # data? # - should we use context task in that case? - task_name = ( - instance.data["anatomyData"]["task"].get("name") - or io.Session["AVALON_TASK"] - ) - task_type = instance.data["task_type"] + task_name = instance.data["anatomyData"]["task"]["name"] + task_type = instance.data["anatomyData"]["task"]["type"] filtering_criteria = { "families": instance.data["family"], "hosts": instance.context.data["hostName"], From 77927bdeeacb6251386ca61148d85abbbe6d8b2c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 9 Nov 2021 10:31:03 +0100 Subject: [PATCH 19/19] fix burnin templates --- openpype/plugins/publish/extract_burnin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 06eb85c593..cbebed927a 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -184,7 +184,9 @@ class ExtractBurnin(openpype.api.Extractor): for key in self.positions: value = burnin_def.get(key) if value: - burnin_values[key] = value + burnin_values[key] = value.replace( + "{task}", "{task[name]}" + ) # Remove "delete" tag from new representation if "delete" in new_repre["tags"]: