Skip to content

Commit

Permalink
PDG: work items service and parser auto detection and override
Browse files Browse the repository at this point in the history
Default service is hbatch and parser is mantra.
If it is a ropfetch with mantra, service is hbatch_mantra.
If it is an ffmpegencodevideo service and parser is ffmpeg.
That is all checks for now.
This function will be improved in feature.

References #514.
  • Loading branch information
timurhai committed Jul 27, 2021
1 parent 345b1a7 commit c24b76e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
Binary file modified plugins/houdini/otls/afanasyscheduler.hda
Binary file not shown.
44 changes: 38 additions & 6 deletions plugins/houdini/pdg/types/afanasyscheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,42 @@ def _initData(self):
self._local_addr = self._getLocalAddr()


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

topnode = work_item.node.topNode()
toptype = topnode.type().name()
if toptype == 'ropfetch':
# Try to detect ROP type
roppath = topnode.parm('roppath')
if roppath is not None:
ropnode = hou.node(roppath.eval())
if ropnode:
roptype = ropnode.type().name()
if roptype == 'ifd':
service = 'hbatch_mantra'
elif toptype == 'ffmpegencodevideo':
service = 'ffmpeg'
parser = 'ffmpeg'

# Service can be specified directly:
value = self.evaluateStringOverride(work_item.node, self.parmprefix, 'service', 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, '')
if value is not None and len(value):
parser = value

return service, parser


def _constructJob(self):
job = af.Job(self['job_name'].evaluateString())

job.setBranch(self['job_branch'].evaluateString())
job.setPriority(self['priority'].evaluateInt())
job.setMaxRunningTasks(self['afanasy_max_running_tasks'].evaluateInt())
Expand All @@ -66,7 +99,9 @@ def _constructJob(self):


def _constructBlock(self, work_item):
block = af.Block(work_item.node.name, 'hbatch_mantra')
service, parser = self._getWorkItemServiceAndParser(work_item)
block = af.Block(work_item.node.name, service)
block.setParser(parser)
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 @@ -75,9 +110,6 @@ 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))
# Check service and parser:
# PDG uses "ALF_PROGRESS" everywhere
block.setParser('mantra')

return block

Expand All @@ -86,7 +118,7 @@ def _constructTask(self, work_item):
task = af.Task(work_item.name)
task.setCommand(self.expandCommandTokens(work_item.command, work_item))

# Set Environment Task Variables
# Set environment variables
task.setEnv('PDG_RESULT_SERVER', str(self.workItemResultServerAddr()))
task.setEnv('PDG_ITEM_NAME', str(work_item.name))
task.setEnv('PDG_DIR', str(self.workingDir(False)))
Expand Down
22 changes: 22 additions & 0 deletions plugins/houdini/topscheduler.user.ds
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,25 @@
help "Task maximum running time in hours."
}


parm {
name "afanasy_service"
label "Service"
type string
default { "" }
parmtag { "pdg::scheduler" "" }
parmtag { spare_category "Afanasy" }
help "Tasks service."
}


parm {
name "afanasy_parser"
label "Parser"
type string
default { "" }
parmtag { "pdg::scheduler" "" }
parmtag { spare_category "Afanasy" }
help "Tasks output parser."
}

0 comments on commit c24b76e

Please sign in to comment.