Add check_inventory_version in create and load callback function - #353
Conversation
There was a problem hiding this comment.
I understand the reasoning here, but I think it's the wrong fix. I wouldn't expect on_script_create to get called when opening a file.
I think the reason why the nuke load event does not trigger and hence on_script_load does not trigger is because of how we open the file here:
ayon-nuke/client/ayon_nuke/api/workio.py
Line 29 in 8a401a7
Essentially, we're not opening a new script - but we're reading it - which is a workaround we have to avoid Nuke opening a new window. Which makes me think we should enforce, from that open logic to trigger the load callback manually then.
So that whenever we do a load, we still expect the load callback to be triggerered.
Looking at that logic it only applies if not ASSIST so it may need to be at the end of that if with some comment as to why we need to trigger the event ourselves.
I'd actually almost go as far as to just put a call to nuke.onScriptLoad() there.
So, confirm this is indeed the case, and if so - add the dedicated call to nuke.onScriptLoad() to enforce it.
|
@moonyuet I noticed you already re-requested review, but this wasn't added yet - right?
|
so we dont need this PR basically, right? If you talk about adding the script load callback in the open workfile, we might need to find if there is some alternatives for that like the callback for workfile |
…d-be-called-on-workfile-load-(via-workfiles-app)
|
@moonyuet @BigRoy ayon-nuke/client/ayon_nuke/api/workio.py Line 29 in 8a401a7 Something like should do the trick. The problem is, that nuke.addOnCreate callbacks will be executed aswell and most likely execute some functions twice. |
…-workfile-load-(via-workfiles-app)' of https://github.com/ynput/ayon-nuke into bugfix/352-check_inventory_versions-should-be-called-on-workfile-load-(via-workfiles-app)
… tool and host implementation
No need, you can just call
I think we shouldn't actually. I think we should make our "open file" behavior mimic as if the user would do File > Open manually as much as possible. it seems like, if the user does that - it also triggers both the on create root callback and the script open callback. The assumption that on create would only happen on "new" files and not on scene open then maybe is wrong. I've now pushed two commits that should make it behave as we'd expect. |
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure check_inventory_versions is applied when a Nuke workfile is opened via the Workfiles tools within an existing Nuke session (matching issue #352), so container “version state” coloring stays correct on workfile loads that bypass Nuke’s usual script-open flow.
Changes:
- Manually triggers “script load” handling after loading a script via
scriptClear()+scriptReadFile()inworkio.open_file. - Moves
check_inventory_versions()execution into theon_script_loadcallback (instead of registering it as a separateaddOnScriptLoadcallback). - Adjusts
on_root_createbehavior to try to only apply “new scene creation” settings when no current file is set.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
client/ayon_nuke/api/workio.py |
Attempts to manually trigger script-load behavior after scriptReadFile so workfile-open flow runs expected callbacks. |
client/ayon_nuke/api/pipeline.py |
Consolidates inventory version checking into on_script_load and refines on_root_create logic for new-scene-only settings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…he user before opening the nuke script
|
I pushed some tweaks @moonyuet. Essentially now it should behave similar to regular file open as to the callbacks that get called.
Things to test would be:
|
Changelog Description
This PR is to add
check_inventory_versionin create and load callback function to ensure the check_inventory_version would apply when the nuke session is opened via workfile tools.Additional review information
Fix #352
Testing notes: