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

Commit

Permalink
Deadline: adding limit groups
Browse files Browse the repository at this point in the history
implementing #1167
  • Loading branch information
jakubjezek001 committed Mar 29, 2021
1 parent 68e5e7d commit 449334d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
42 changes: 37 additions & 5 deletions pype/modules/deadline/plugins/publish/submit_nuke_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from avalon.vendor import requests
import re
import pyblish.api
import nuke


class NukeSubmitDeadline(pyblish.api.InstancePlugin):
Expand All @@ -29,6 +30,7 @@ class NukeSubmitDeadline(pyblish.api.InstancePlugin):
secondary_pool = ""
group = ""
department = ""
limit_groups = {}

def process(self, instance):
instance.data["toBeRenderedOn"] = "deadline"
Expand Down Expand Up @@ -149,6 +151,10 @@ def payload_submit(self,
if not priority:
priority = self.priority

# resolve any limit groups
limit_groups = self.get_limit_groups()
self.log.info("Limit groups: `{}`".format(limit_groups))

payload = {
"JobInfo": {
# Top-level group name
Expand Down Expand Up @@ -180,7 +186,10 @@ def payload_submit(self,

# Optional, enable double-click to preview rendered
# frames from Deadline Monitor
"OutputFilename0": output_filename_0.replace("\\", "/")
"OutputFilename0": output_filename_0.replace("\\", "/"),

# limiting groups
"LimitGroups": ",".join(limit_groups)

},
"PluginInfo": {
Expand Down Expand Up @@ -329,17 +338,15 @@ def preview_fname(self, path):
return int(search_results[1])
if "#" in path:
self.log.debug("_ path: `{}`".format(path))
return path
else:
return path
return path

def expected_files(self,
instance,
path):
""" Create expected files in instance data
"""
if not instance.data.get("expectedFiles"):
instance.data["expectedFiles"] = list()
instance.data["expectedFiles"] = []

dir = os.path.dirname(path)
file = os.path.basename(path)
Expand All @@ -356,3 +363,28 @@ def expected_files(self,
for i in range(self._frame_start, (self._frame_end + 1)):
instance.data["expectedFiles"].append(
os.path.join(dir, (file % i)).replace("\\", "/"))

def get_limit_groups(self):
"""Search for limit group nodes and return group name.
Limit groups will be defined as pairs in Nuke deadline submitter
presents where the key will be name of limit group and value will be
a list of plugin's node class names. Thus, when a plugin uses more
than one node, these will be captured and the triggered process
will add the appropriate limit group to the payload jobinfo attributes.
Returning:
list: captured groups list
"""
captured_groups = []
for lg_name, list_node_class in self.deadline_limit_groups.items():
for node_class in list_node_class:
for node in nuke.allNodes(recurseGroups=True):
# ignore all nodes not member of defined class
if node.Class() not in node_class:
continue
# ignore all disabled nodes
if node["disable"].value():
continue
# add group name if not already added
if lg_name not in captured_groups:
captured_groups.append(lg_name)
return captured_groups
3 changes: 2 additions & 1 deletion pype/settings/defaults/project_settings/deadline.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"primary_pool": "",
"secondary_pool": "",
"group": "",
"department": ""
"department": "",
"limit_groups": {}
},
"HarmonySubmitDeadline": {
"enabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@
"type": "text",
"key": "department",
"label": "Department"
},
{
"type": "dict-modifiable",
"key": "limit_groups",
"label": "Limit Groups",
"object_type": {
"type": "list",
"object_type": "text"
}
}
]
},
Expand Down

0 comments on commit 449334d

Please sign in to comment.