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

Feature/93 flexible template assignment #114

Merged
merged 3 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pype/nuke/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion pype/plugins/global/publish/extract_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
76 changes: 69 additions & 7 deletions pype/plugins/global/publish/integrate_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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 = []
Expand All @@ -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']

Expand Down Expand Up @@ -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
6 changes: 1 addition & 5 deletions pype/plugins/global/publish/submit_publish_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
}
Expand Down Expand Up @@ -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 [],
}
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions pype/plugins/maya/publish/extract_yeti_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
}
)

Expand Down
6 changes: 2 additions & 4 deletions pype/plugins/maya/publish/extract_yeti_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -179,8 +178,7 @@ def process(self, instance):
'name': 'rigsettings',
'ext': 'rigsettings',
'files': 'yeti.rigsettings',
'stagingDir': dirname,
'anatomy_template': 'publish'
'stagingDir': dirname
}
)

Expand Down
3 changes: 1 addition & 2 deletions pype/plugins/nuke/publish/collect_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def process(self, instance):
representation = {
'name': ext,
'ext': ext,
"stagingDir": output_dir,
"anatomy_template": "render"
"stagingDir": output_dir
}

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

Expand Down
1 change: 0 additions & 1 deletion pype/plugins/nuke/publish/extract_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 1 addition & 14 deletions pype/plugins/standalonepublisher/publish/collect_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down