Skip to content

Fixing effect loader for macos resources #245

Open
jakubjezek001 wants to merge 3 commits into
developfrom
bugfix/macos-load-effects-resources-paths-localisation
Open

Fixing effect loader for macos resources #245
jakubjezek001 wants to merge 3 commits into
developfrom
bugfix/macos-load-effects-resources-paths-localisation

Conversation

@jakubjezek001
Copy link
Copy Markdown
Member

@jakubjezek001 jakubjezek001 commented Apr 20, 2026

Changelog Description

Fixes effect loader on macOS by properly resolving resource file paths using AYON Anatomy templates. This ensures effects reference resources with correct platform-specific paths, resolving issues with effect loading on macOS systems.

Additional info

The loader now uses the Anatomy system to convert absolute paths into platform-agnostic template paths. When setting node attributes with file references, the code:

  1. Detects file path knobs in the effect node structure
  2. Retrieves the Anatomy configuration for the current project
  3. Converts absolute paths to rootless template paths
  4. Resolves the template with current root mappings to generate correct platform-specific paths

This approach ensures effects work correctly across different OS environments and project configurations.

Testing notes:

  1. Load an effect with external resources on macOS
  2. Verify effect resources are correctly located and loaded
  3. Test with multiple project root configurations
  4. Confirm effects function identically across Windows, macOS, and Linux

Add new imports for StringTemplate and Anatomy to enhance
file path processing in LoadEffects class.
@jakubjezek001 jakubjezek001 added the type: bug Something isn't working label Apr 20, 2026
@jakubjezek001 jakubjezek001 self-assigned this Apr 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes Nuke effect loading on macOS by resolving effect resource file paths through AYON Anatomy root templates, aiming to produce correct platform-specific absolute paths at load time.

Changes:

  • Add AYON Anatomy + StringTemplate-based path resolution for file knob values when recreating effect nodes.
  • Convert resource paths via find_root_template_from_path + template formatting using Anatomy roots.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.log.warning(e)
continue

# check if `file` in knob name
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The comment says “check if file in knob name” but the condition is k == "file". Either update the comment or broaden the condition (if the intent is to catch other file-like knobs) to avoid confusion for future maintainers.

Suggested change
# check if `file` in knob name
# check if the knob name is exactly `file`

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +117
success, rootless_path = \
anatomy.find_root_template_from_path(file_path)
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Avoid using a backslash line continuation here; wrap the call in parentheses instead. This is easier to edit and less error-prone if trailing whitespace changes.

Suggested change
success, rootless_path = \
anatomy.find_root_template_from_path(file_path)
success, rootless_path = (
anatomy.find_root_template_from_path(file_path)
)

Copilot uses AI. Check for mistakes.
continue

# check if `file` in knob name
print(f"{k}: {v}")
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Remove the direct print debug output (or switch it to self.log.debug). Printing every knob/value during load will spam Nuke’s Script Editor/stdout and is hard to control via log levels.

Suggested change
print(f"{k}: {v}")
self.log.debug(f"{k}: {v}")

Copilot uses AI. Check for mistakes.
Comment on lines +110 to +113
file_path = v
project_name = get_current_project_name()
anatomy = Anatomy(project_name=project_name)
_template_data = {
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

get_current_project_name() inside the knob loop can resolve roots for the currently active project rather than the project being loaded from context. Since _load_effects_to_group already has context, consider passing context["project"]["name"] (or a prebuilt Anatomy) down into _create_nodes_order to avoid mismatches.

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +115
project_name = get_current_project_name()
anatomy = Anatomy(project_name=project_name)
_template_data = {
"root": anatomy.roots,
}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

Anatomy(...) is created inside the per-node/per-knob loop. If this hits settings/API each time, it can become a noticeable load-time cost. Create anatomy (and the template data dict) once before iterating nodes/knobs and reuse it.

Copilot uses AI. Check for mistakes.
Comment on lines +119 to +125
self.log.info(f"rootless_path: {rootless_path}")
if success:
abs_resources_path = StringTemplate.format_strict_template(
rootless_path, _template_data
)
v = abs_resources_path
self.log.info(f"File path: {abs_resources_path}")
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

These info logs will run for every file knob and will emit resolved absolute paths, which can be very noisy in normal usage. Consider lowering to debug (and/or logging only on failure) so routine loads don’t flood logs.

Suggested change
self.log.info(f"rootless_path: {rootless_path}")
if success:
abs_resources_path = StringTemplate.format_strict_template(
rootless_path, _template_data
)
v = abs_resources_path
self.log.info(f"File path: {abs_resources_path}")
self.log.debug(f"rootless_path: {rootless_path}")
if success:
abs_resources_path = StringTemplate.format_strict_template(
rootless_path, _template_data
)
v = abs_resources_path
self.log.debug(f"File path: {abs_resources_path}")

Copilot uses AI. Check for mistakes.

file = self.filepath_from_context(context).replace("\\", "/")
with open(file, "r") as f:
with open(file) as f:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
with open(file) as f:
with open(file, "r") as f:

Comment on lines +108 to +109
project_name = get_current_project_name()
anatomy = Anatomy(project_name=project_name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should use the project from which we're loading. Mostly would be current project, but you can also load from library project. The project entity is stored in context, so you could just do

project_entity = context["project"]
anatomy = Anatomy(project_entity["name"], project_entity=project_entity)

Also could happen only once for the whole load logic in case the anatomy would be created multiple times.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Side note: Why is this actually happening? The loaded "files" can have loaded other files? That might be a mess. Imagine having file that is e.g. ocio file defined with environment variables instead of anatomy roots, it would just collapse.

rootless_path, _template_data
)
v = abs_resources_path
self.log.info(f"File path: {abs_resources_path}")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
self.log.info(f"File path: {abs_resources_path}")

# so it is multiplatform compatible
if k == "file":
file_path = v
project_name = get_current_project_name()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

2 things:

  • it is possible to load from other projects
  • the Anatomy creation can be very heavy operation

Rather prepare the anatomy ahead in _load_effects_to_group and use project entity from context.

project_entity = context["project"]
anatomy = Anatomy(
    project_entity["name"], project_entity=project_entity
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants