Skip to content

Commit

Permalink
fix: properly fill out allowed values for camera job parameter (#103)
Browse files Browse the repository at this point in the history
Signed-off-by: Morgan Epp <[email protected]>
  • Loading branch information
epmog authored Feb 27, 2024
1 parent 21055e5 commit 3c2d42f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
26 changes: 24 additions & 2 deletions src/deadline/maya_submitter/job_bundle_output_test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
Defines the Render submitter command which is registered in Maya.
"""
from contextlib import contextmanager
import os
import tempfile
from unittest import mock
Expand Down Expand Up @@ -30,6 +31,24 @@
# The following functions expose a DCC interface to the job bundle output test logic.


@contextmanager
def _consistent_machine_settings():
"""Set all machine level options to be consistent across users performing job bundle test runs.
Re-apply old options on exit"""
try:
# setting renderSetup_includeAllLights to True, unless you know better
old_render_setup_include_all_lights: int = maya.mel.eval(
"optionVar -q renderSetup_includeAllLights"
)
maya.cmds.optionVar(intValue=("renderSetup_includeAllLights", int(True)))

yield
finally:
maya.cmds.optionVar(
intValue=("renderSetup_includeAllLights", old_render_setup_include_all_lights)
)


def _get_dcc_main_window() -> Any:
app = QApplication.instance()
return [widget for widget in app.topLevelWidgets() if widget.objectName() == "MayaWindow"][0]
Expand Down Expand Up @@ -112,7 +131,10 @@ def run_maya_render_submitter_job_bundle_output_test():
mainwin = _get_dcc_main_window()
count_succeeded = 0
count_failed = 0
with gui_error_handler("Error running job bundle output test", mainwin):

with gui_error_handler(
"Error running job bundle output test", mainwin
), _consistent_machine_settings():
default_tests_dir = Path(__file__).parent.parent.parent.parent / "job_bundle_output_tests"

tests_dir = QFileDialog.getExistingDirectory(
Expand Down Expand Up @@ -161,7 +183,7 @@ def run_maya_render_submitter_job_bundle_output_test():
QMessageBox.information(
mainwin,
"All Job Bundle Tests Passed",
f"Ran {count_succeeded} tests in total.",
f"Success! Ran {count_succeeded} tests in total.",
)
report_fh.write(f"Timestamp: {_timestamp_string()}\n")

Expand Down
29 changes: 15 additions & 14 deletions src/deadline/maya_submitter/maya_render_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def _get_job_template(
settings: RenderSubmitterUISettings,
renderers: set[str],
render_layers: list[RenderLayerData],
all_layer_selectable_cameras,
current_layer_selectable_cameras,
all_layer_selectable_cameras: list[str],
current_layer_selectable_cameras: list[str],
) -> dict[str, Any]:
job_template = deepcopy(default_job_template)

Expand Down Expand Up @@ -177,10 +177,12 @@ def _get_job_template(

# If we're rendering a specific camera, add the Camera job parameter
if settings.camera_selection != ALL_CAMERAS:
selectable_cameras: list[str]
if settings.render_layer_selection == LayerSelection.ALL:
selectable_cameras = all_layer_selectable_cameras
else:
selectable_cameras = current_layer_selectable_cameras

camera_param = {
"name": "Camera",
"type": "STRING",
Expand Down Expand Up @@ -502,20 +504,19 @@ def show_maya_render_submitter(parent, f=Qt.WindowFlags()) -> "Optional[SubmitJo
render_layers.sort(key=lambda layer: layer.display_name)

# Tell the settings tab the selectable cameras when only the current layer is in the job
current_layer_selectable_cameras = get_renderable_camera_names()
current_layer_selectable_cameras: list[str] = get_renderable_camera_names()
render_settings.current_layer_selectable_cameras = [ALL_CAMERAS] + sorted(
current_layer_selectable_cameras
)

# Tell the settings tab the selectable cameras when all layers are in the job
all_layer_selectable_cameras = set(render_layers[0].renderable_camera_names)
all_layer_selectable_cameras_set: set[str] = set(render_layers[0].renderable_camera_names)
for layer in render_layers:
all_layer_selectable_cameras = all_layer_selectable_cameras.intersection(
all_layer_selectable_cameras_set = all_layer_selectable_cameras_set.intersection(
layer.renderable_camera_names
)
render_settings.all_layer_selectable_cameras = [ALL_CAMERAS] + sorted(
all_layer_selectable_cameras
)
all_layer_selectable_cameras: list[str] = list(sorted(all_layer_selectable_cameras_set))
render_settings.all_layer_selectable_cameras = [ALL_CAMERAS] + all_layer_selectable_cameras

all_renderers: set[str] = {layer_data.renderer_name for layer_data in render_layers}

Expand Down Expand Up @@ -594,12 +595,12 @@ def on_create_job_bundle_callback(
renderers: set[str] = {layer_data.renderer_name for layer_data in submit_render_layers}

job_template = _get_job_template(
default_job_template,
settings,
renderers,
submit_render_layers,
all_layer_selectable_cameras,
current_layer_selectable_cameras,
default_job_template=default_job_template,
settings=settings,
renderers=renderers,
render_layers=submit_render_layers,
all_layer_selectable_cameras=all_layer_selectable_cameras,
current_layer_selectable_cameras=current_layer_selectable_cameras,
)
parameter_values = _get_parameter_values(
settings, renderers, submit_render_layers, queue_parameters
Expand Down

0 comments on commit 3c2d42f

Please sign in to comment.