Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add frame range to Blender command in CueSubmit #1337

Merged
5 changes: 3 additions & 2 deletions cuesubmit/cuesubmit/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

Some values can be overridden by custom config, see Config.py."""


from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
Expand All @@ -38,6 +37,8 @@
NUKE_RENDER_CMD = config.get('NUKE_RENDER_CMD', 'nuke')
BLENDER_RENDER_CMD = config.get('BLENDER_RENDER_CMD', 'blender')
FRAME_TOKEN = config.get('FRAME_TOKEN', '#IFRAME#')
FRAME_START_TOKEN = config.get('FRAME_START', '#FRAME_START#')
FRAME_END_TOKEN = config.get('FRAME_END', '#FRAME_END#')

# Tokens are replaced by cuebot during dispatch with their computed value.
# see: cuebot/src/main/java/com/imageworks/spcue/dispatcher/DispatchSupportService.java
Expand All @@ -55,7 +56,7 @@
BLENDER_FORMATS = ['', 'AVIJPEG', 'AVIRAW', 'BMP', 'CINEON', 'DPX', 'EXR', 'HDR', 'IRIS', 'IRIZ',
'JP2', 'JPEG', 'MPEG', 'MULTILAYER', 'PNG', 'RAWTGA', 'TGA', 'TIFF']
BLENDER_OUTPUT_OPTIONS_URL = \
'https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html#render-options'
'https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html#render-options'

DIR_PATH = os.path.dirname(__file__)

Expand Down
11 changes: 9 additions & 2 deletions cuesubmit/cuesubmit/Submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def buildBlenderCmd(layerData):
blenderFile = layerData.cmd.get('blenderFile')
outputPath = layerData.cmd.get('outputPath')
outputFormat = layerData.cmd.get('outputFormat')
frameRange = layerData.layerRange
if not blenderFile:
raise ValueError('No Blender file provided. Cannot submit job.')

Expand All @@ -72,8 +73,14 @@ def buildBlenderCmd(layerData):
renderCommand += ' -o {}'.format(outputPath)
if outputFormat:
renderCommand += ' -F {}'.format(outputFormat)
# The render frame must come after the scene and output
renderCommand += ' -f {frameToken}'.format(frameToken=Constants.FRAME_TOKEN)
if frameRange:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you could add unit tests to cover both the single-frame and start/end frame cases.

https://github.com/AcademySoftwareFoundation/OpenCue/blob/master/cuesubmit/tests/Submission_tests.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 2d4ba88

@bcipriano however, I'm having a bit of trouble with lines #178 and #153 of Submission_tests.py
The test fails when I set it to blender but passes when I set it to shell. This is despite the layerType being set as Blender. Any thoughts on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @bcipriano

# Render frames from start to end (inclusive) via '-a' command argument
renderCommand += (' -s {startFrame} -e {endFrame} -a'
n-jay marked this conversation as resolved.
Show resolved Hide resolved
.format(startFrame=Constants.FRAME_START_TOKEN,
endFrame=Constants.FRAME_END_TOKEN))
else:
# The render frame must come after the scene and output
renderCommand += ' -f {frameToken}'.format(frameToken=Constants.FRAME_TOKEN)
return renderCommand


Expand Down
68 changes: 68 additions & 0 deletions cuesubmit/tests/Submission_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@
'services': ['nuke'],
}

BLENDER_MULTI_LAYER_DATA = {
'name': 'arbitraryBlenderLayer_name',
'layerType': cuesubmit.JobTypes.JobTypes.BLENDER,
'cmd': {'outputPath': '/path/to/output',
'blenderFile': '/path/to/scene.blend',
'outputFormat': 'PNG'},
'layerRange': '3-9',
'cores': '2'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to add a services line like the Maya / Nuke tests do?

I think this is causing the job to default to the shell service, so the assertion on line 153 fails.

Copy link
Contributor Author

@n-jay n-jay May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcipriano noted, didn't catch that one. 😄
Resolved in a17be62

A new set of unit test failures seem to be coming from some unrelated changes.
Unsure, but I think the CueGUI fail is caused by this one: 65b74fe
CC: @DiegoTavares

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, I'm fixing the pipeline on muster

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pipeline fixed by #1360

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted @DiegoTavares, thanks for the update!

}

BLENDER_SINGLE_LAYER_DATA = {
'name': 'arbitraryBlenderLayer_name',
'layerType': cuesubmit.JobTypes.JobTypes.BLENDER,
'cmd': {'outputPath': '/path/to/output',
'blenderFile': '/path/to/scene.blend',
'outputFormat': 'PNG'},
'cores': '2'
}

SHELL_LAYER_DATA = {
'name': 'arbitraryShellLayer_name',
'layerType': cuesubmit.JobTypes.JobTypes.SHELL,
Expand Down Expand Up @@ -109,6 +128,55 @@ def testSubmitNukeJob(self, launchMock):
self.assertEqual(NUKE_LAYER_DATA['layerRange'], layer.get_frame_range())
self.assertEqual('nuke', layer.get_service())

def testSubmitSingleFrameBlenderJob(self, launchMock):
cuesubmit.Submission.submitJob({
'name': 'arbitrary-blender-job',
'shot': 'arbitrary-shot-name',
'show': 'arbitrary-show-name',
'username': 'arbitrary-user',
'layers': [cuesubmit.Layer.LayerData.buildFactory(**BLENDER_SINGLE_LAYER_DATA)],
})

ol = launchMock.call_args[0][0]
self.assertEqual(1, len(ol.get_layers()))
layer = ol.get_layer(BLENDER_SINGLE_LAYER_DATA['name'])
self.assertEqual(BLENDER_SINGLE_LAYER_DATA['name'], layer.get_name())
self.assertEqual(
[
'blender', '-b', '-noaudio', BLENDER_SINGLE_LAYER_DATA['cmd']['blenderFile'],
'-o', BLENDER_SINGLE_LAYER_DATA['cmd']['outputPath'],
'-F', BLENDER_SINGLE_LAYER_DATA['cmd']['outputFormat'],
'-f', '#IFRAME#'
],
layer.get_arg('command')
)
self.assertEqual('blender', layer.get_service())

def testSubmitMultiFrameBlenderJob(self, launchMock):
cuesubmit.Submission.submitJob({
'name': 'arbitrary-blender-job',
'shot': 'arbitrary-shot-name',
'show': 'arbitrary-show-name',
'username': 'arbitrary-user',
'layers': [cuesubmit.Layer.LayerData.buildFactory(**BLENDER_MULTI_LAYER_DATA)],
})

ol = launchMock.call_args[0][0]
self.assertEqual(1, len(ol.get_layers()))
layer = ol.get_layer(BLENDER_MULTI_LAYER_DATA['name'])
self.assertEqual(BLENDER_MULTI_LAYER_DATA['name'], layer.get_name())
self.assertEqual(
[
'blender', '-b', '-noaudio', BLENDER_MULTI_LAYER_DATA['cmd']['blenderFile'],
'-o', BLENDER_MULTI_LAYER_DATA['cmd']['outputPath'],
'-F', BLENDER_MULTI_LAYER_DATA['cmd']['outputFormat'],
'-s', '#FRAME_START#', '-e', '#FRAME_END#', '-a'
],
layer.get_arg('command')
)
self.assertEqual(BLENDER_MULTI_LAYER_DATA['layerRange'], layer.get_frame_range())
self.assertEqual('blender', layer.get_service())

def testSubmitMayaAndShellJob(self, launchMock):
cuesubmit.Submission.submitJob({
'name': 'arbitrary-maya-shell-job',
Expand Down
Loading