Skip to content

Commit

Permalink
Addressing comments for PR 166
Browse files Browse the repository at this point in the history
  • Loading branch information
Haejung Choi committed Sep 18, 2024
1 parent c3fd74d commit 150e7c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 41 deletions.
21 changes: 9 additions & 12 deletions src/deadline/nuke_submitter/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,24 @@ def get_scene_asset_references() -> AssetReferences:
for search_path in ocio_config_search_paths:
asset_references.input_directories.add(search_path)
else:
nuke.alert(
"OCIO config file specified(%s) is not an existing file." % ocio_config_path
raise DeadlineOperationError(
"OCIO config file specified(%s) is not an existing file. Please check and update the config file before proceeding."
% ocio_config_path
)

return asset_references


def get_ocio_config_path() -> Optional[str]:
ocio_config_path = None

# if using a custom OCIO environment variable
if nuke_ocio.is_env_config_enabled():
ocio_config_path = nuke_ocio.get_env_config_path()
return nuke_ocio.get_env_config_path()
elif nuke_ocio.is_custom_config_enabled():
return nuke_ocio.get_custom_config_path()
elif nuke_ocio.is_stock_config_enabled():
return nuke_ocio.get_stock_config_path()
else:
print("here?")
# if using a custom OCIO config file
if nuke_ocio.is_custom_config_enabled():
ocio_config_path = nuke_ocio.get_custom_config_path()
elif nuke_ocio.is_stock_config_enabled():
ocio_config_path = nuke_ocio.get_stock_config_path()
return ocio_config_path
return None


def find_all_write_nodes() -> set:
Expand Down
22 changes: 7 additions & 15 deletions src/deadline/nuke_submitter/deadline_submitter_for_nuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,7 @@ def _add_ocio_path_to_job_template(job_template: dict[str, Any]) -> None:
0,
{
"name": "Add OCIO Path to Environment Variable",
"script": {
"actions": {"onEnter": {"command": "{{Env.File.Enter}}"}},
"embeddedFiles": [
{
"name": "Enter",
"type": "TEXT",
"runnable": True,
"data": """#!/bin/bash
echo 'openjd_env: OCIO={{Param.OCIOConfigPath}}'
""",
}
],
},
"variables": {"OCIO": "{{Param.OCIOConfigPath}}"},
},
)

Expand Down Expand Up @@ -289,8 +277,12 @@ def _get_parameter_values(
# Set the OCIO config path value
if nuke_ocio.is_OCIO_enabled():
ocio_config_path = get_ocio_config_path()
parameter_values.append({"name": "OCIOConfigPath", "value": ocio_config_path})

if ocio_config_path:
parameter_values.append({"name": "OCIOConfigPath", "value": ocio_config_path})
else:
raise DeadlineOperationError(
"OCIO is enabled but OCIO config file is not specified. Please check and update the config file before proceeding."
)
if settings.include_adaptor_wheels:
wheels_path = str(Path(__file__).parent.parent.parent.parent / "wheels")
parameter_values.append({"name": "AdaptorWheels", "value": wheels_path})
Expand Down
2 changes: 1 addition & 1 deletion src/deadline/nuke_util/ocio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_env_config_path() -> Optional[str]:


def is_stock_config_enabled() -> bool:
"""True if the script is using a custom OCIO config"""
"""True if the script is using a default OCIO config"""
return (
nuke.root().knob("colorManagement").value() == "OCIO"
and nuke.root().knob("OCIO_config").value() != "custom"
Expand Down
14 changes: 1 addition & 13 deletions test/unit/deadline_submitter_for_nuke/test_ocio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,7 @@ def test_add__dir_to_job_template():

expected_environment = {
"name": "Add OCIO Path to Environment Variable",
"script": {
"actions": {"onEnter": {"command": "{{Env.File.Enter}}"}},
"embeddedFiles": [
{
"name": "Enter",
"type": "TEXT",
"runnable": True,
"data": """#!/bin/bash
echo 'openjd_env: OCIO={{Param.OCIOConfigPath}}'
""",
}
],
},
"variables": {"OCIO": "{{Param.OCIOConfigPath}}"},
}

assert len(job_template["jobEnvironments"]) == 1
Expand Down

0 comments on commit 150e7c3

Please sign in to comment.