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

Hey guys,
This guide inspired me to use vscode tasks more.

you can find my vscode setup here :wink:

My old setup

I’m using the following task to create and upload addon zips to my server.
upload feature is not built into default create_package.py therefore I had to implement upload_addon.py

anyways, these tasks simply

  • run create_package.py
  • run upload_addon.py
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Create addon",
            "type": "shell",
            "command": "python",
            "args": [
                "${cwd}/create_package.py",
            ],
            "problemMatcher": []
        },
        {
            "label": "Upload addon",
            "type": "shell",
            "command": "python",
            "args": [
                "E:/Ynput/ayon-helper-scripts/upload_addon.py",  // find upload_addon.py in https://gist.github.com/MustafaJafar/be7989dbee17b1bfb574612f978c77d1
                "--addon-dir",
                "${cwd}/package",
                "--addon-version",
                "${input:addon_version}"
            ],
            "problemMatcher": []
        }
    ],
    "inputs": [

        {
            "id": "addon_version",
            "description": "",
            "default": "ayon_third_party-1.1.2-dev.1",
            "type": "promptString"
        }
    ]
}

and, I’m using it on daily basis in every addon clone on my disk.
I’ve also tweaked it a little to use it in ayon core

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Create core addon",
            "type": "shell",
            "command": "python",
            "args": [
                "${cwd}/create_package.py",
            ],
            "problemMatcher": []
        },
        {
            "label": "Upload core addon",
            "type": "shell",
            "command": "python",
            "args": [
                "E:/Ynput/ayon-helper-scripts/upload_addon.py",  // find upload_addon.py in https://gist.github.com/MustafaJafar/be7989dbee17b1bfb574612f978c77d1
                "--addon-dir",
                "${cwd}/package",
                "--addon-version",
                "${input:core_addon}"
            ],
            "problemMatcher": []
        },
        {
            "label": "Create other addon",
            "type": "shell",
            "command": "python",
            "args": [
                "${cwd}/server_addon/create_ayon_addons.py",
                "--addon",
                "${input:addon}"
            ],
            "problemMatcher": []
        },
        {
            "label": "Upload other addon",
            "type": "shell",
            "command": "python",
            "args": [
                "E:/Ynput/ayon-helper-scripts/upload_addon.py",  // find upload_addon.py in https://gist.github.com/MustafaJafar/be7989dbee17b1bfb574612f978c77d1
                "--addon-dir",
                "${cwd}/server_addon/packages",
                "--addon-version",
                "${input:other_addon}"
            ],
            "problemMatcher": []
        }
    ],
    "inputs": [
        {
            "id": "core_addon",
            "description": "",
            "default": "core-0.3.3-dev.1",
            "type": "promptString"
        },
        {
            "id": "other_addon",
            "description": "",
            "default": "houdini-0.3.1",
            "type": "promptString"
        },
        {
            "id": "addon",
            "description": "",
            "default": "houdini",
            "type": "promptString"
        },
    ]
}
1 Like