VSCode tasks. Run services and upload addons

Hi all! While working on the Kitsu Addon I needed a way to quickly run the updated service code and upload any updated server code to my Ayon instance.
With this I made these tasks in VSCode:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build and upload addon",
            "type": "shell",
            "command": "",
            "args": [
                "${workspaceFolder}/.venv/Scripts/Activate.ps1;",
                "python",
                "ayon-kitsu/create_package.py",
                "--upload",
                "--output",
                "dist/packages"
            ],
            "problemMatcher": []
        },
        {
            "label": "Run Processor Service",
            "type": "shell",
            "command": "",
            "args": [
                "${workspaceFolder}/.venv/Scripts/Activate.ps1;",
                "cd",
                "${workspaceFolder}/ayon-kitsu/services/;",
                "make",
                "SERVICE=processor",
                "run"
            ],
            "presentation": {
                "group": "kitsu_leecher"
            },
            "problemMatcher": []
        },
        {
            "label": "Run Leecher Service",
            "type": "shell",
            "command": "",
            "args": [
                "${workspaceFolder}/.venv/Scripts/Activate.ps1;",
                "cd",
                "${workspaceFolder}/ayon-kitsu/services/;",
                "make",
                "SERVICE=leecher",
                "run"
            ],
            "presentation": {
                "group": "kitsu_leecher"
            }
        },
        {
            "label": "Run Both Services",
            "dependsOn": [
                "Run Leecher Service",
                "Run Processor Service"
            ],
            "command": "echo",
            "args": [
                "Both services completed"
            ],
            "problemMatcher": []
        }
    ]
}

Place this text in .vscode/tasks.json in your vscode workspace. You execute the tasks using ctrl+p, Tasks: Run task and then select what task to run.
I also included a second service and a task to run both of them at the same time.

This was made for Window and my workspace structure. You will need to modify the tasks to execute the correct files in the correct locations but with these tasks I sped up my development a lot.

I hope it will help others also :slight_smile:

4 Likes

Thanks this I was able to create task for my ayon-core repository workspace! Thank you @Danell

Here is my file structure:
launcher: [MY CODE ROOT DIR]/ayon-launcher
core: [MY CODE ROOT DIR]/ayon-core
docker: [MY CODE ROOT DIR]/ayon-docker

This task will only work with following code changes in ayon-core Chore: stop removing addons via create package py by jakubjezek001 · Pull Request #102 · ynput/ayon-core · GitHub

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build and upload Core + Hosts addons",
            "type": "shell",
            "command": "",
            "args": [
                "${workspaceFolder}/../ayon-launcher/.venv/Scripts/Activate.ps1;",
                "python",
                "${workspaceFolder}/create_package.py",
                "--skip-zip",
                "--output",
                "${workspaceFolder}/../ayon-docker/addons;",
                "python",
                "${workspaceFolder}/server_addon/create_ayon_addons.py",
                "--skip-zip",
                "--output",
                "${workspaceFolder}/../ayon-docker/addons;",
            ],
            "problemMatcher": []
        }
    ]
}
1 Like

Just wanted to add that to upload correctly you need to pip install python-dotenv in your environment and also create a .env file in the ayon-kitsu root that should contain:

AYON_API_KEY={An api key for one of your users. Can be a service user}
AYON_SERVER_URL={The url to your Ayon server}
2 Likes