Skip to content

Commit

Permalink
PDG: Tickets and Environment parameters added.
Browse files Browse the repository at this point in the history
Scheduler node screenshot for documentation added.

References: #514.
  • Loading branch information
timurhai committed Aug 3, 2021
1 parent 0bbb2ae commit eb70e63
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 7 deletions.
12 changes: 12 additions & 0 deletions docs/software/houdini.rst
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,18 @@ This can be used to explain other ROP network what to do with Afanasy node.
Afanasy TOP
===========

.. figure:: images/houdini_pdg_scheduler.png

Afanasy TOP Shecduler tab

.. figure:: images/houdini_pdg_parameters.png

Afanasy TOP Tasks Parameters tab

.. figure:: images/houdini_pdg_adjustment.png

Afanasy TOP Adjustment tab

Examples
========

Expand Down
Binary file added docs/software/images/houdini_pdg_adjustment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/software/images/houdini_pdg_scheduler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/houdini/otls/afanasyscheduler.hda
Binary file not shown.
69 changes: 62 additions & 7 deletions plugins/houdini/pdg/types/afanasyscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@
import af


def displayError(msg, exception=None):
"""Pop up a message dialog to display the given error message.
If the ui is unavailable, then it writes the message to the console.
"""
if hou.isUIAvailable():
details = (str(exception) if exception is not None else None)
hou.ui.displayMessage(msg, severity=hou.severityType.Error, details=details)
else:
if exception is not None:
msg += "\n" + str(exception)
raise hou.OperationFailed(msg)

def displayMessage(msg):
"""Pop up a message dialog to display the given message.
If the ui is unavailable, then it writes the message to the console.
"""
if hou.isUIAvailable():
hou.ui.displayMessage(msg, severity=hou.severityType.Message)
else:
print(msg)


class AfanasyScheduler(CallbackServerMixin, PyScheduler):
"""
Scheduler implementation that interfaces with a Afanasy farm instance.
Expand Down Expand Up @@ -53,13 +75,34 @@ def _log(self, i_msg):
print(self.topNode().name() + ': ' + str(i_msg))


def _getWorkItemServiceAndParser(self, work_item):
def _getTicketsDictFromString(self, i_str):
tickets = dict()

if i_str is None or len(i_str) == 0:
return tickets

for ticket in i_str.split(','):
ticket = ticket.strip().split(':')
if len(ticket) != 2:
displayMessage('Invalid ticket data: "%s".' % ticket)
tickets[ticket[0]] = int(ticket[1])

return tickets


def _getWorkItemServiceParserTickets(self, i_work_item):
# Set the default service values
service = 'hbatch'
# PDG uses "ALF_PROGRESS" everywhere
parser = 'mantra'

topnode = work_item.node.topNode()
# By default there are no tickets at all
tickets = dict()
tickets_auto = self['afanasy_tickets_auto'].evaluateInt()
if tickets_auto:
# If auto tickets, almost all nodes launches hython
tickets['HYTHON'] = 1

topnode = i_work_item.node.topNode()
toptype = topnode.type().name()
if toptype == 'ropfetch':
# Try to detect ROP type
Expand All @@ -70,21 +113,28 @@ def _getWorkItemServiceAndParser(self, work_item):
roptype = ropnode.type().name()
if roptype == 'ifd':
service = 'hbatch_mantra'
if tickets_auto:
tickets['MANTRA'] = 1
elif toptype == 'ffmpegencodevideo':
service = 'ffmpeg'
parser = 'ffmpeg'
tickets.pop('HYTHON', None)

# Service can be specified directly:
value = self.evaluateStringOverride(work_item.node, self.parmprefix, 'service', work_item, '')
value = self.evaluateStringOverride(i_work_item.node, self.parmprefix, 'service', i_work_item, '')
if value is not None and len(value):
service = value

# Parser can be specified directly:
value = self.evaluateStringOverride(work_item.node, self.parmprefix, 'parser', work_item, '')
value = self.evaluateStringOverride(i_work_item.node, self.parmprefix, 'parser', i_work_item, '')
if value is not None and len(value):
parser = value

return service, parser
# Add tickets that are specified directly:
value = self.evaluateStringOverride(i_work_item.node, self.parmprefix, 'tickets', i_work_item, '')
tickets.update(self._getTicketsDictFromString(value))

return service, parser, tickets


def _constructJob(self):
Expand All @@ -100,9 +150,11 @@ def _constructJob(self):


def _constructBlock(self, work_item):
service, parser = self._getWorkItemServiceAndParser(work_item)
service, parser, tickets = self._getWorkItemServiceParserTickets(work_item)
block = af.Block(work_item.node.name, service)
block.setParser(parser)
for name in tickets:
block.addTicket(name, tickets[name])
block.setCapacity(self.evaluateIntOverride(work_item.node, self.parmprefix, 'capacity', work_item, -1))
block.setHostsMask(self.evaluateStringOverride(work_item.node, self.parmprefix, 'hosts_mask', work_item, ''))
block.setHostsMaskExclude(self.evaluateStringOverride(work_item.node, self.parmprefix, 'hosts_mask_exclude', work_item, ''))
Expand All @@ -111,6 +163,9 @@ def _constructBlock(self, work_item):
block.setNeedMemory(self.evaluateIntOverride(work_item.node, self.parmprefix, 'need_memory', work_item, -1)*1024)
block.setTaskMinRunTime(self.evaluateIntOverride(work_item.node, self.parmprefix, 'task_min_run_time', work_item, -1))
block.setTaskMaxRunTime(int(self.evaluateFloatOverride(work_item.node, self.parmprefix, 'task_max_run_time', work_item, -1)*3600.0))
env_dict, removekeys = self.resolveEnvParams(self.parmprefix, work_item, False)
for name in env_dict:
block.setEnv(name, env_dict[name])

return block

Expand Down
39 changes: 39 additions & 0 deletions plugins/houdini/topscheduler.user.ds
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,42 @@
help "Tasks output parser."
}


parm {
name "afanasy_tickets"
label "Tickets"
type string
default { "" }
parmtag { "pdg::scheduler" "" }
parmtag { spare_category "Afanasy" }
help "Tasks block tickets. A comma separated list of key:count. Example: MEM:64,GPU:1"
}


multiparm {
name "afanasy_envmulti"
label "Extra Environment"
parmtag { "pdg::nocopy" "" }
parmtag { "pdg::scheduler" "" }
parmtag { spare_category "Afanasy" }

parm {
name "afanasy_envname#"
label "Name"
type string
joinnext
default { "" }
parmtag { "pdg::scheduler" "" }
parmtag { spare_category "Afanasy" }
help "Name of the work item environment variable."
}
parm {
name "afanasy_envvalue#"
label "Value"
type string
default { "" }
parmtag { "pdg::scheduler" "" }
parmtag { spare_category "Afanasy" }
help "Value of the work item environment variable."
}
}

0 comments on commit eb70e63

Please sign in to comment.