Skip to content

Commit 58a5bb7

Browse files
authored
feat: add version information to submitter dialog (#279)
Signed-off-by: Morgan Epp <60796713+epmog@users.noreply.github.com>
1 parent f50ab7f commit 58a5bb7

7 files changed

Lines changed: 64 additions & 10 deletions

File tree

src/deadline/max_adaptor/MaxClient/render_handlers/vray_handler.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55
"""
66

7-
import math
87
import os
98
import sys
109
from typing import Any
@@ -13,6 +12,7 @@
1312

1413
from deadline.max_shared.utilities.max_utils import (
1514
configure_vray_raw_output,
15+
get_max_version_year,
1616
is_vray_raw_output_format,
1717
)
1818

@@ -39,11 +39,8 @@ def _validate_vray_environment(self) -> None:
3939
Validates that required VRay environment variables are set.
4040
Raises RuntimeError with actionable message if variables are missing.
4141
"""
42-
# Get 3ds Max year using the same formula as max_render_submitter.py
43-
max_version: Any = rt.maxVersion()
44-
# Convert to int to handle both real values and mock objects
45-
version_major: int = int(max_version[0])
46-
year: int = 2000 + math.ceil(version_major / 1000.0) - 2
42+
# Get 3ds Max release year (e.g. 2025)
43+
year: int = get_max_version_year()
4744

4845
# Define required environment variables
4946
required_vars: list[str] = [

src/deadline/max_shared/utilities/max_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
import logging
12+
import math
1213
import os
1314
import re
1415
from dataclasses import dataclass, field
@@ -21,6 +22,21 @@
2122
_logger = logging.getLogger(__name__)
2223

2324

25+
def get_max_version_year() -> int:
26+
"""
27+
Get the 3ds Max release year (e.g. 2025) from the running application.
28+
29+
3ds Max's internal major version number (``rt.maxVersion()[0]``) encodes the
30+
release as ``(year - 1998) * 1000`` (e.g. 27000 for 2025). This converts it
31+
back to the human-readable release year.
32+
33+
:returns: the 3ds Max release year, e.g. 2025
34+
"""
35+
# int() handles both real values and mocked values used in tests
36+
version_major: int = int(rt.maxVersion()[0])
37+
return 2000 + math.ceil(version_major / 1000.0) - 2
38+
39+
2440
@dataclass
2541
class RenderElementInfo:
2642
"""

src/deadline/max_submitter/max_render_submitter.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
import logging
8-
import math
98
import os
109
from os.path import abspath, join, normpath
1110
from pathlib import Path
@@ -25,6 +24,7 @@
2524
TEMP_BACKUP_FILENAME,
2625
UI_GROUP_LABEL,
2726
)
27+
from deadline.client.dataclasses import SubmitterInfo
2828
from deadline.client.job_bundle._yaml import deadline_yaml_dump
2929
from deadline.client.job_bundle.submission import AssetReferences
3030
from deadline.client.ui.dialogs._types import JobBundlePurpose
@@ -37,9 +37,11 @@
3737
from utilities import max_utils, submission_utils
3838
from deadline.max_shared.utilities.max_utils import (
3939
get_batch_render_views,
40+
get_max_version_year,
4041
get_render_elements_output_directories,
4142
)
4243

44+
from _version import version
4345
from _version import version_tuple as adaptor_version_tuple
4446

4547
_logger = logging.getLogger(__name__)
@@ -354,10 +356,18 @@ def show_job_bundle_submitter():
354356
output_directories=set(render_settings.output_directories),
355357
)
356358

357-
max_version = 2000 + (math.ceil(rt.maxVersion()[0] / 1000.0) - 2)
359+
max_version = get_max_version_year()
358360
adaptor_version = ".".join(str(v) for v in adaptor_version_tuple[:2])
359361
conda_packages = f"3dsmax={max_version}.* 3dsmax-openjd={adaptor_version}.*"
360362

363+
submitter_info = SubmitterInfo(
364+
submitter_name="3dsMax",
365+
submitter_package_name="deadline-cloud-for-3ds-max",
366+
submitter_package_version=version,
367+
host_application_name="3ds Max",
368+
host_application_version=str(max_version),
369+
)
370+
361371
# Instantiate and show the Submitter UI
362372
window = SubmitMaxJobToDeadlineDialog(
363373
job_setup_widget_type=SceneSettingsWidget,
@@ -371,6 +381,7 @@ def show_job_bundle_submitter():
371381
parent=main_window,
372382
f=Qt.Tool,
373383
show_host_requirements_tab=True,
384+
submitter_info=submitter_info,
374385
)
375386
window.show()
376387
return window

src/deadline/max_submitter/utilities/vray_executable_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from pymxs import runtime as rt
99

10+
from deadline.max_shared.utilities.max_utils import get_max_version_year
11+
1012
_logger = logging.getLogger(__name__)
1113

1214

@@ -24,7 +26,7 @@ def get_vray_executable_path() -> str:
2426

2527
# Fallback: derive from V-Ray's own env vars (set by V-Ray installer)
2628
try:
27-
max_version = 2000 + (int(rt.maxVersion()[0] / 1000.0) - 2)
29+
max_version = get_max_version_year()
2830
vray_main = os.environ.get(f"VRAY_FOR_3DSMAX{max_version}_MAIN", "")
2931
if vray_main:
3032
candidate = os.path.join(vray_main, "vray.exe")

src/deadline/max_submitter/vray_standalone_submitter.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
import pymxs # noqa
1313
import qtmax
14+
from deadline.client.dataclasses import SubmitterInfo
1415
from deadline.client.job_bundle._yaml import deadline_yaml_dump
1516
from deadline.client.job_bundle.submission import AssetReferences
1617
from deadline.client.ui.dialogs._types import JobBundlePurpose
18+
from deadline.max_shared.utilities.max_utils import get_max_version_year
1719
from pymxs import runtime as rt
1820
from qtpy.QtCore import Qt # type: ignore
1921
from ui.submit_dialog import SubmitMaxJobToDeadlineDialog
@@ -39,6 +41,8 @@
3941
)
4042
from vrscene_settings import VRSceneRenderSubmitterUISettings
4143

44+
from _version import version
45+
4246
_logger = logging.getLogger(__name__)
4347

4448

@@ -532,6 +536,15 @@ def show_vray_standalone_submitter():
532536
# For V-Ray Standalone, we need vray package instead of 3dsmax
533537
conda_packages = "vray imagemagick ffmpeg"
534538

539+
max_version = get_max_version_year()
540+
submitter_info = SubmitterInfo(
541+
submitter_name="VRayStandalone",
542+
submitter_package_name="deadline-cloud-for-3ds-max",
543+
submitter_package_version=version,
544+
host_application_name="3ds Max",
545+
host_application_version=str(max_version),
546+
)
547+
535548
# Instantiate and show the Submitter UI
536549
window = SubmitMaxJobToDeadlineDialog(
537550
job_setup_widget_type=VRayStandaloneSettingsWidget,
@@ -545,6 +558,7 @@ def show_vray_standalone_submitter():
545558
parent=main_window,
546559
f=Qt.Tool,
547560
show_host_requirements_tab=False, # Not needed for vrscene rendering
561+
submitter_info=submitter_info,
548562
)
549563
window.show()
550564
return window

test/unit/deadline_adaptor_for_3ds_max/MaxClient/render_handlers/test_vray_handler.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import pytest
66

77

8+
@patch(
9+
"deadline.max_adaptor.MaxClient.render_handlers.vray_handler.get_max_version_year",
10+
new=lambda: 2025,
11+
)
812
class TestVrayHandler:
913
"""Tests for VrayHandler environment variable validation"""
1014

@@ -51,7 +55,13 @@ def test_vray_handler_with_valid_env_vars(
5155
) -> None:
5256
"""Test VRay handler initializes successfully with all required env vars"""
5357
with patch.dict("os.environ", env_vars, clear=True):
54-
with patch("deadline.max_adaptor.MaxClient.render_handlers.vray_handler.rt") as mock_rt:
58+
with (
59+
patch("deadline.max_adaptor.MaxClient.render_handlers.vray_handler.rt") as mock_rt,
60+
patch(
61+
"deadline.max_adaptor.MaxClient.render_handlers.vray_handler.get_max_version_year",
62+
return_value=year,
63+
),
64+
):
5565
mock_rt.maxVersion.return_value = max_version
5666

5767
from deadline.max_adaptor.MaxClient.render_handlers.vray_handler import (

test/unit/deadline_adaptor_for_3ds_max/MaxClient/render_handlers/test_vray_path_mapping.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import pytest
66

77

8+
@patch(
9+
"deadline.max_adaptor.MaxClient.render_handlers.vray_handler.get_max_version_year",
10+
new=lambda: 2025,
11+
)
812
class TestVrayProxyPathMapping:
913
"""Tests for VrayHandler path mapping functionality."""
1014

0 commit comments

Comments
 (0)