From b68f049a7cae8fbd08510185ffcbbad74688819e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 30 Apr 2020 17:55:46 +0200 Subject: [PATCH 1/2] removed usage and setting of "anatomy_template" key in representations --- pype/nuke/lib.py | 1 - pype/plugins/global/publish/extract_burnin.py | 1 - pype/plugins/global/publish/submit_publish_job.py | 6 +----- pype/plugins/maya/publish/extract_yeti_cache.py | 4 +--- pype/plugins/maya/publish/extract_yeti_rig.py | 6 ++---- pype/plugins/nuke/publish/collect_writes.py | 3 +-- pype/plugins/nuke/publish/extract_render_local.py | 3 +-- pype/plugins/nuke/publish/extract_thumbnail.py | 1 - .../publish/collect_context.py | 15 +-------------- 9 files changed, 7 insertions(+), 33 deletions(-) diff --git a/pype/nuke/lib.py b/pype/nuke/lib.py index 423738dd7ff..249a3f8f5b9 100644 --- a/pype/nuke/lib.py +++ b/pype/nuke/lib.py @@ -1412,7 +1412,6 @@ def get_representation_data(self, tags=None, range=False): 'ext': self.ext, 'files': self.file, "stagingDir": self.staging_dir, - "anatomy_template": "render", "tags": [self.name.replace("_", "-")] + add_tags } diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index c151752c8fc..7668eafd2a7 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -193,7 +193,6 @@ def process(self, instance): self.log.debug("Output: {}".format(output)) repre_update = { - "anatomy_template": "render", "files": movieFileBurnin, "name": repre["name"], "tags": [x for x in repre["tags"] if x != "delete"] diff --git a/pype/plugins/global/publish/submit_publish_job.py b/pype/plugins/global/publish/submit_publish_job.py index 843760f9eca..b9c14d4fe43 100644 --- a/pype/plugins/global/publish/submit_publish_job.py +++ b/pype/plugins/global/publish/submit_publish_job.py @@ -380,7 +380,6 @@ def _create_instances_for_aov(self, instance_data, exp_files): "frameEnd": int(instance_data.get("frameEndHandle")), # If expectedFile are absolute, we need only filenames "stagingDir": staging, - "anatomy_template": "render", "fps": new_instance.get("fps"), "tags": ["review"] if preview else [] } @@ -443,7 +442,6 @@ def _get_representations(self, instance, exp_files): "frameEnd": int(instance.get("frameEndHandle")), # If expectedFile are absolute, we need only filenames "stagingDir": os.path.dirname(list(c)[0]), - "anatomy_template": "render", "fps": instance.get("fps"), "tags": ["review", "preview"] if preview else [], } @@ -462,13 +460,11 @@ def _get_representations(self, instance, exp_files): "name": ext, "ext": ext, "files": os.path.basename(r), - "stagingDir": os.path.dirname(r), - "anatomy_template": "publish" + "stagingDir": os.path.dirname(r) } if r in bake_render_path: rep.update({ "fps": instance.get("fps"), - "anatomy_template": "render", "tags": ["review", "delete"] }) # solve families with `preview` attributes diff --git a/pype/plugins/maya/publish/extract_yeti_cache.py b/pype/plugins/maya/publish/extract_yeti_cache.py index 7d85f396aed..5a67a6ab7e4 100644 --- a/pype/plugins/maya/publish/extract_yeti_cache.py +++ b/pype/plugins/maya/publish/extract_yeti_cache.py @@ -73,7 +73,6 @@ def process(self, instance): 'ext': 'fur', 'files': cache_files[0] if len(cache_files) == 1 else cache_files, 'stagingDir': dirname, - 'anatomy_template': 'publish', 'frameStart': int(start_frame), 'frameEnd': int(end_frame) } @@ -84,8 +83,7 @@ def process(self, instance): 'name': 'fursettings', 'ext': 'fursettings', 'files': os.path.basename(data_file), - 'stagingDir': dirname, - 'anatomy_template': 'publish' + 'stagingDir': dirname } ) diff --git a/pype/plugins/maya/publish/extract_yeti_rig.py b/pype/plugins/maya/publish/extract_yeti_rig.py index 98e7271d1a0..f82cd75c305 100644 --- a/pype/plugins/maya/publish/extract_yeti_rig.py +++ b/pype/plugins/maya/publish/extract_yeti_rig.py @@ -169,8 +169,7 @@ def process(self, instance): 'name': "ma", 'ext': 'ma', 'files': "yeti_rig.ma", - 'stagingDir': dirname, - 'anatomy_template': 'publish' + 'stagingDir': dirname } ) self.log.info("settings file: {}".format("yeti.rigsettings")) @@ -179,8 +178,7 @@ def process(self, instance): 'name': 'rigsettings', 'ext': 'rigsettings', 'files': 'yeti.rigsettings', - 'stagingDir': dirname, - 'anatomy_template': 'publish' + 'stagingDir': dirname } ) diff --git a/pype/plugins/nuke/publish/collect_writes.py b/pype/plugins/nuke/publish/collect_writes.py index 6379a1db879..1850df2d006 100644 --- a/pype/plugins/nuke/publish/collect_writes.py +++ b/pype/plugins/nuke/publish/collect_writes.py @@ -79,8 +79,7 @@ def process(self, instance): representation = { 'name': ext, 'ext': ext, - "stagingDir": output_dir, - "anatomy_template": "render" + "stagingDir": output_dir } try: diff --git a/pype/plugins/nuke/publish/extract_render_local.py b/pype/plugins/nuke/publish/extract_render_local.py index b7aa59a457b..37a67013806 100644 --- a/pype/plugins/nuke/publish/extract_render_local.py +++ b/pype/plugins/nuke/publish/extract_render_local.py @@ -71,8 +71,7 @@ def process(self, instance): 'ext': ext, 'frameStart': "%0{}d".format(len(str(last_frame))) % first_frame, 'files': collected_frames, - "stagingDir": out_dir, - "anatomy_template": "render" + "stagingDir": out_dir } instance.data["representations"].append(repre) diff --git a/pype/plugins/nuke/publish/extract_thumbnail.py b/pype/plugins/nuke/publish/extract_thumbnail.py index 362625c2f5a..5e9302a01a0 100644 --- a/pype/plugins/nuke/publish/extract_thumbnail.py +++ b/pype/plugins/nuke/publish/extract_thumbnail.py @@ -130,7 +130,6 @@ def render_thumbnail(self, instance): "stagingDir": staging_dir, "frameStart": first_frame, "frameEnd": last_frame, - "anatomy_template": "render", "tags": tags } instance.data["representations"].append(repre) diff --git a/pype/plugins/standalonepublisher/publish/collect_context.py b/pype/plugins/standalonepublisher/publish/collect_context.py index 327b99f4322..0567f82755d 100644 --- a/pype/plugins/standalonepublisher/publish/collect_context.py +++ b/pype/plugins/standalonepublisher/publish/collect_context.py @@ -46,7 +46,6 @@ def process(self, context): in_data = json.load(f) asset_name = in_data["asset"] - family_preset_key = in_data.get("family_preset_key", "") family = in_data["family"] subset = in_data["subset"] @@ -57,15 +56,6 @@ def process(self, context): presets = config.get_presets() - # Get from presets anatomy key that will be used for getting template - # - default integrate new is used if not set - anatomy_key = ( - presets.get("standalone_publish", {}) - .get("families", {}) - .get(family_preset_key, {}) - .get("anatomy_template") - ) - project = io.find_one({"type": "project"}) asset = io.find_one({"type": "asset", "name": asset_name}) context.data["project"] = project @@ -98,12 +88,9 @@ def process(self, context): instance.data["source"] = "standalone publisher" for component in in_data["representations"]: - component["destination"] = component["files"] component["stagingDir"] = component["stagingDir"] - # Do not set anatomy_template if not specified - if anatomy_key: - component["anatomy_template"] = anatomy_key + if isinstance(component["files"], list): collections, remainder = clique.assemble(component["files"]) self.log.debug("collecting sequence: {}".format(collections)) From ebdfaf8baaf6caed014aa9f7867b61364eb17d70 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 30 Apr 2020 19:35:03 +0200 Subject: [PATCH 2/2] implemented method for template name determination based on plugin presets --- pype/plugins/global/publish/integrate_new.py | 76 ++++++++++++++++++-- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index 9eab1a15b13..d26cc4e856c 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -40,10 +40,6 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): 'name': representation name (usually the same as extension) 'ext': file extension optional data - 'anatomy_template': 'publish' or 'render', etc. - template from anatomy that should be used for - integrating this file. Only the first level can - be specified right now. "frameStart" "frameEnd" 'fps' @@ -92,6 +88,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): "family", "hierarchy", "task", "username" ] default_template_name = "publish" + template_name_profiles = None def process(self, instance): @@ -268,6 +265,8 @@ def register(self, instance): if 'transfers' not in instance.data: instance.data['transfers'] = [] + template_name = self.template_name_from_instance(instance) + published_representations = {} for idx, repre in enumerate(instance.data["representations"]): published_files = [] @@ -292,9 +291,6 @@ def register(self, instance): if repre.get('stagingDir'): stagingdir = repre['stagingDir'] - template_name = ( - repre.get('anatomy_template') or self.default_template_name - ) if repre.get("outputName"): template_data["output"] = repre['outputName'] @@ -701,3 +697,69 @@ def create_version_data(self, context, instance): version_data[key] = instance.data[key] return version_data + + def main_family_from_instance(self, instance): + """Returns main family of entered instance.""" + family = instance.data.get("family") + if not family: + family = instance.data["families"][0] + return family + + def template_name_from_instance(self, instance): + template_name = self.default_template_name + if not self.template_name_profiles: + self.log.debug(( + "Template name profiles are not set." + " Using default \"{}\"" + ).format(template_name)) + return template_name + + # Task name from session? + task_name = io.Session.get("AVALON_TASK") + family = self.main_family_from_instance(instance) + + matching_profiles = None + highest_value = -1 + for name, filters in self.template_name_profiles: + value = 0 + families = filters.get("families") + if families: + if family not in families: + continue + value += 1 + + tasks = filters.get("tasks") + if tasks: + if task_name not in tasks: + continue + value += 1 + + if value > highest_value: + matching_profiles = {} + highest_value = value + + if value == highest_value: + matching_profiles[name] = filters + + if len(matching_profiles) == 1: + template_name = matching_profiles.keys()[0] + self.log.debug( + "Using template name \"{}\".".format(template_name) + ) + + elif len(matching_profiles) > 1: + template_name = matching_profiles.keys()[0] + self.log.warning(( + "More than one template profiles matched" + " Family \"{}\" and Task: \"{}\"." + " Using first template name in row \"{}\"." + ).format(family, task_name, template_name)) + + else: + self.log.debug(( + "None of template profiles matched" + " Family \"{}\" and Task: \"{}\"." + " Using default template name \"{}\"" + ).format(family, task_name, template_name)) + + return template_name