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

fix: OutputPath is read from the scene in the submitter #231

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link

Choose a reason for hiding this comment

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

OK so we are just getting rootDirectory instead of directory

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