I’m trying to set up a coding test bed in VS Code so that I can interact with the Ayon modules kind of like you can in the Nuke script editor. I’ve followed some of the steps in @mustafa_jafar’s Ayon Development Workbench repo to get all of our internal Ayon dev repos into the PYTHONPATH. So that everything is accessible from my VS Code workspace. But I want to be able to run Ayon code in VS Code.
I was just curious to see what it would take to set VS Code up for this or if anyone else has tried it…
As long as I gave my test code the proper arguments (project_name, folder_path, task_name,host_name) I was able to ayon_core.pipeline.template_data.get_template_data() and get data returned.
This allowed me to edit some code in ayon_core and do some testing right away without having to open Nuke. It’s probably not the perfect setup to cover all dev possibilities. But it’s enough to get me what wanted for now.
You could also run ayon_console run /path/to/pythonscript.py which would go through the core addon CLI here
However, it’d run slower than just a python interpreter - but at least it’d go through the full ayon ‘initialization’ of the core itself?
Note that you can also do ayon_core interactive (which is one of the other CLI entry points in core in the linked code but a bit lower here
But, you could set up your IDE to run ayon_console run {current_file} and you’re off to a good start potentially?
Also, are you aware of the DEV mode in AYON? Basically you can run, e.g. Nuke integration (and launcher, etc.) from live source code on your machine instead of installed packages. I’d say that’s critical for development workflows with AYON.
Let me just spell out some thoughts:
(As far as I know and please correct me if I’m wrong.)
Testing integration addon’s functionality (e.g. Nuke addon) is different from testing core functionalities and API calls. as the integration addon is supposed to be run within the host (e.g. Nuke) it self.
Being able to import all code from different addons doesn’t mean you have a working AYON dev environment setup because there are important things that happens on initialization (e.g. setting tool groups for your current context). This is reason why I only used these paths for code completion without caring much about running it.
Ask AYON to run a script. which I think is equivalent to the previous suggestion). You can do it via terminal.
ayon_console run /path/to/pythonscript.py
Run AYON in interactively (Python like) console.
ayon_console interactive
There some internal discussion about using Jupyter but currently there is some conflicts in the dependencies on my side. and there is no request for supporting Jupyter atm.
Open Terminal with your app environment initialized. I think it can be a middle ground for running scripts while expecting all env to be set like AYON_PROJECT_NAME.
@mustafa_jafar@BigRoy Thanks for the replies. First off, yes I am aware of dev mode. If you notice in my last post, I am setting AYON_BUNDLE_NAME=DEV
I was not aware of the CLI functionality on Core, that’s actually good to know. I was aware of the terminal launcher. While I find it useful for certain circumstances, I wouldn’t use that in my main dev workflow.
VS Code is what I use as my main dev platform. I try to do as much in there as I can. In my test bed I setup entry points for the project in my pyproject.toml:
So in my terminal in VS Code, which has my virtual env activated, I can call test2 and that function will run. To me this is essentially the same as running ayon_console run /path/to/pythonscript.py but much more convenient.
This might not be a test system that covers every possible scenario. But so far it’s working for me.