Automation with Python script in AYON context

Happy new year folks,

What is the recommended way to run a Python script within the AYON Python context, such that AYON automatically uses the Python scripts from the addon version defined by the current bundle?

I’m aware that this can normally be done with the following command:

%LOCALAPPDATA%/Ynput/AYON/shim/ayon_console.exe run [PATH TO PYTHON SCRIPT]

However, I’m not sure what the best approach is for providing the PATH TO PYTHON SCRIPT when the script lives inside an AYON addon and is managed by the addon system.

The directory %LOCALAPPDATA%/Ynput/AYON/addons contains all client-side addon code, but there doesn’t seem to be a way to programmatically select which addon (and version) should be used so that it matches the active bundle context.

Is there a supported way to provide a relative path, or otherwise resolve the script path, so that the correct addon version is used automatically?

Regards,
Tu

Hello, you can pass python script, or you can implement cli for the addon.

You can take a look at ayon-ftrack which does it.

You can then use %LOCALAPPDATA%/Ynput/AYON/shim/ayon_console.exe addon [addon name] [command] *other arguments.

1 Like

Each addon can introduce some commands. For examples, see Addon CLI Interface - Dev Docs.

1 Like

Thank you @iLLiCiT and @mustafa_jafar. Work like a charm.

Thank you for the awesome example and documentation.

1 Like