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

Commit

Permalink
Merge pull request #5949 from ynput/bugfix/OP-7378-blender-deadline_c…
Browse files Browse the repository at this point in the history
…hunk_size_issue

Blender: Fix Deadline Frames per task
  • Loading branch information
LiborBatek committed Nov 29, 2023
2 parents 90e75b4 + 1abbee1 commit 6816169
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 28 deletions.
20 changes: 10 additions & 10 deletions openpype/hosts/blender/api/render_lib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path

import bpy

Expand Down Expand Up @@ -59,7 +59,7 @@ def get_render_product(output_path, name, aov_sep):
instance (pyblish.api.Instance): The instance to publish.
ext (str): The image format to render.
"""
filepath = os.path.join(output_path, name)
filepath = output_path / name.lstrip("/")
render_product = f"{filepath}{aov_sep}beauty.####"
render_product = render_product.replace("\\", "/")

Expand Down Expand Up @@ -180,7 +180,7 @@ def set_node_tree(output_path, name, aov_sep, ext, multilayer):
return []

output.file_slots.clear()
output.base_path = output_path
output.base_path = str(output_path)

aov_file_products = []

Expand All @@ -191,8 +191,9 @@ def set_node_tree(output_path, name, aov_sep, ext, multilayer):

output.file_slots.new(filepath)

aov_file_products.append(
(render_pass.name, os.path.join(output_path, filepath)))
filename = str(output_path / filepath.lstrip("/"))

aov_file_products.append((render_pass.name, filename))

node_input = output.inputs[-1]

Expand All @@ -214,12 +215,11 @@ def imprint_render_settings(node, data):
def prepare_rendering(asset_group):
name = asset_group.name

filepath = bpy.data.filepath
filepath = Path(bpy.data.filepath)
assert filepath, "Workfile not saved. Please save the file first."

file_path = os.path.dirname(filepath)
file_name = os.path.basename(filepath)
file_name, _ = os.path.splitext(file_name)
dirpath = filepath.parent
file_name = Path(filepath.name).stem

project = get_current_project_name()
settings = get_project_settings(project)
Expand All @@ -232,7 +232,7 @@ def prepare_rendering(asset_group):
set_render_format(ext, multilayer)
aov_list, custom_passes = set_render_passes(settings)

output_path = os.path.join(file_path, render_folder, file_name)
output_path = Path.joinpath(dirpath, render_folder, file_name)

render_product = get_render_product(output_path, name, aov_sep)
aov_file_product = set_node_tree(
Expand Down
10 changes: 3 additions & 7 deletions openpype/hosts/blender/plugins/publish/collect_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@


class CollectBlenderRender(pyblish.api.InstancePlugin):
"""Gather all publishable render layers from renderSetup."""
"""Gather all publishable render instances."""

order = pyblish.api.CollectorOrder + 0.01
hosts = ["blender"]
families = ["render"]
label = "Collect Render Layers"
label = "Collect Render"
sync_workfile_version = False

@staticmethod
Expand Down Expand Up @@ -78,8 +78,6 @@ def process(self, instance):

assert render_data, "No render data found."

self.log.debug(f"render_data: {dict(render_data)}")

render_product = render_data.get("render_product")
aov_file_product = render_data.get("aov_file_product")
ext = render_data.get("image_format")
Expand All @@ -101,7 +99,7 @@ def process(self, instance):
expected_files = expected_beauty | expected_aovs

instance.data.update({
"family": "render.farm",
"families": ["render", "render.farm"],
"frameStart": frame_start,
"frameEnd": frame_end,
"frameStartHandle": frame_handle_start,
Expand All @@ -120,5 +118,3 @@ def process(self, instance):
"colorspaceView": "ACES 1.0 SDR-video",
"renderProducts": colorspace.ARenderProduct(),
})

self.log.debug(f"data: {instance.data}")
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class IncrementWorkfileVersion(
optional = True
hosts = ["blender"]
families = ["animation", "model", "rig", "action", "layout", "blendScene",
"pointcache", "render"]
"pointcache", "render.farm"]

def process(self, context):
if not self.is_active(context.data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ValidateDeadlinePublish(pyblish.api.InstancePlugin,
"""

order = ValidateContentsOrder
families = ["render.farm"]
families = ["render"]
hosts = ["blender"]
label = "Validate Render Output for Deadline"
optional = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
import attr
from datetime import datetime

from openpype.lib import is_running_from_build
from openpype.lib import (
is_running_from_build,
BoolDef,
NumberDef,
TextDef,
)
from openpype.pipeline import legacy_io
from openpype.pipeline.publish import OpenPypePyblishPluginMixin
from openpype.pipeline.farm.tools import iter_expected_files
from openpype.tests.lib import is_in_tests

Expand All @@ -22,17 +28,19 @@ class BlenderPluginInfo():
SaveFile = attr.ib(default=True)


class BlenderSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
class BlenderSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline,
OpenPypePyblishPluginMixin):
label = "Submit Render to Deadline"
hosts = ["blender"]
families = ["render.farm"]
families = ["render"]

use_published = True
priority = 50
chunk_size = 1
jobInfo = {}
pluginInfo = {}
group = None
job_delay = "00:00:00:00"

def get_job_info(self):
job_info = DeadlineJobInfo(Plugin="Blender")
Expand Down Expand Up @@ -67,8 +75,7 @@ def get_job_info(self):

job_info.Pool = instance.data.get("primaryPool")
job_info.SecondaryPool = instance.data.get("secondaryPool")
job_info.Comment = context.data.get("comment")
job_info.Priority = instance.data.get("priority", self.priority)
job_info.Comment = instance.data.get("comment")

if self.group != "none" and self.group:
job_info.Group = self.group
Expand All @@ -83,8 +90,10 @@ def get_job_info(self):
machine_list_key = "Blacklist"
render_globals[machine_list_key] = machine_list

job_info.Priority = attr_values.get("priority")
job_info.ChunkSize = attr_values.get("chunkSize")
job_info.ChunkSize = attr_values.get("chunkSize", self.chunk_size)
job_info.Priority = attr_values.get("priority", self.priority)
job_info.ScheduledType = "Once"
job_info.JobDelay = attr_values.get("job_delay", self.job_delay)

# Add options from RenderGlobals
render_globals = instance.data.get("renderGlobals", {})
Expand Down Expand Up @@ -180,3 +189,39 @@ def from_published_scene(self):
the metadata and the rendered files are in the same location.
"""
return super().from_published_scene(False)

@classmethod
def get_attribute_defs(cls):
defs = super(BlenderSubmitDeadline, cls).get_attribute_defs()
defs.extend([
BoolDef("use_published",
default=cls.use_published,
label="Use Published Scene"),

NumberDef("priority",
minimum=1,
maximum=250,
decimals=0,
default=cls.priority,
label="Priority"),

NumberDef("chunkSize",
minimum=1,
maximum=50,
decimals=0,
default=cls.chunk_size,
label="Frame Per Task"),

TextDef("group",
default=cls.group,
label="Group Name"),

TextDef("job_delay",
default=cls.job_delay,
label="Job Delay",
placeholder="dd:hh:mm:ss",
tooltip="Delay the job by the specified amount of time. "
"Timecode: dd:hh:mm:ss."),
])

return defs
3 changes: 2 additions & 1 deletion openpype/settings/defaults/project_settings/deadline.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"use_published": true,
"priority": 50,
"chunk_size": 10,
"group": "none"
"group": "none",
"job_delay": "00:00:00:00"
},
"ProcessSubmittedCacheJobOnFarm": {
"enabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@
"type": "text",
"key": "group",
"label": "Group Name"
},
{
"type": "text",
"key": "job_delay",
"label": "Delay job (timecode dd:hh:mm:ss)"
}
]
},
Expand Down
4 changes: 3 additions & 1 deletion server_addon/deadline/server/settings/publish_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class BlenderSubmitDeadlineModel(BaseSettingsModel):
priority: int = Field(title="Priority")
chunk_size: int = Field(title="Frame per Task")
group: str = Field("", title="Group Name")
job_delay: str = Field("", title="Delay job (timecode dd:hh:mm:ss)")


class AOVFilterSubmodel(BaseSettingsModel):
Expand Down Expand Up @@ -438,7 +439,8 @@ class PublishPluginsModel(BaseSettingsModel):
"use_published": True,
"priority": 50,
"chunk_size": 10,
"group": "none"
"group": "none",
"job_delay": "00:00:00:00"
},
"ProcessSubmittedCacheJobOnFarm": {
"enabled": True,
Expand Down

0 comments on commit 6816169

Please sign in to comment.