Run version specific code before or after an update.
Conversation on Discord; Discord
A case for us was to be able to update a rig but change some behaviour of controllers while preserving the animation, for example changing a controller to go in y direction instead of negative x direction. The code for updating the rig while preserving the animation is relatively simple but ensuring it gets executed is very prone to error, so why not use the update mechanism of OpenPype?
To be as flexible as possible we could offer code execution before and after the asset version is updated; pre and post hooks.
These pre/post hooks would take the form of python scripts, which reside in the version folder alongside the rest of the asset versions representations.
# pseudo code class CustomFixRig(VersionPostUpdateHook): host = "maya" def process(self): if not self.current_version == 2 and self.update_version 3: return # do your magic ...
How we specify the python scripts when publishing is up for debate. An idea is to just to the new publisher which has the ability to generate temporary instances from (external) files.
Maybe the python script path should be persistent in the workfile?
How do we account for version downgrading and skipping?
How do we deal with version hooks that are wrong or missing code?
Should this be an opt-in feature, so ask users to run pre/post hooks every time they exist?