Skip to content

Commit

Permalink
fix: OutputPath is read from the scene in the submitter (#231)
Browse files Browse the repository at this point in the history
* fix: Load scene settings when the submitter is open

Signed-off-by: Jair Ruiz <[email protected]>

* fix: OutputPath is read from the scene in the submitter

Signed-off-by: Jair Ruiz <[email protected]>

---------

Signed-off-by: Jair Ruiz <[email protected]>
  • Loading branch information
jairaws authored Feb 10, 2025
1 parent 94ee920 commit d77f474
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/deadline/maya_submitter/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def project_path() -> str:
"""
Returns the base path to the project the current scene is in
"""
return maya.cmds.workspace(query=True, directory=True)
return maya.cmds.workspace(query=True, rootDirectory=True)

@staticmethod
def output_path() -> str:
Expand All @@ -140,9 +140,9 @@ def output_path() -> str:
# This one didn't work translated to the maya.cmds equivalent
image_rule = maya.mel.eval('workspace -q -fileRuleEntry "images"')
if image_rule:
return os.path.join(maya.cmds.workspace(query=True, directory=True), image_rule)
return os.path.join(Scene.project_path(), image_rule)
else:
return maya.cmds.workspace(query=True, directory=True)
return Scene.project_path()

@staticmethod
def autotx() -> bool:
Expand Down
41 changes: 37 additions & 4 deletions test/unit/deadline_submitter_for_maya/scripts/test_scene.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

from typing import Optional

import pytest
import os
from unittest.mock import patch, Mock

from deadline.maya_submitter.scene import (
FrameRange,
)
from deadline.maya_submitter.scene import FrameRange, Scene


class TestFrameRange:
Expand Down Expand Up @@ -42,3 +41,37 @@ def test_frame_repr(self, start: int, stop: int, step: Optional[int]) -> None:
assert fr_repr == f"{start}-{stop}"
else:
assert fr_repr == f"{start}-{stop}:{step}"


class TestScene:

@patch("deadline.maya_submitter.scene.maya.cmds")
def test_project_path(self, mock_maya_cmds: Mock) -> None:
Scene.project_path()

mock_maya_cmds.workspace.assert_called_once_with(query=True, rootDirectory=True)

@patch.object(Scene, "project_path")
@patch("deadline.maya_submitter.scene.maya")
def test_output_path_with_images_suffix(self, mock_maya: Mock, mock_project_path: Mock) -> None:
test_images_dir: str = "test_images_dir"
test_project_path: str = "test_project_path"
mock_maya.mel.eval.return_value = test_images_dir
mock_project_path.return_value = test_project_path

output_path: str = Scene.output_path()

assert output_path == os.path.join(test_project_path, test_images_dir)

@patch.object(Scene, "project_path")
@patch("deadline.maya_submitter.scene.maya")
def test_output_path_without_images_suffix(
self, mock_maya: Mock, mock_project_path: Mock
) -> None:
test_project_path: str = "test_project_path"
mock_maya.mel.eval.return_value = None
mock_project_path.return_value = test_project_path

output_path: str = Scene.output_path()

assert output_path == test_project_path

0 comments on commit d77f474

Please sign in to comment.