ayon-backend
ayon-backend copied to clipboard
Replace Addon's Library logic with Rez
Replace addons logic with Rez
This Pull Request, modifies the backend in order to leverage Rez to manage AYON addons (they should now include a package.py with the attribute plugin_for="ayon_server".
A loose explantation of the process is:
- When we spin the server, we make sure a (meta) package named
ayon_serverexists in our repo, as of now/addons; and it matches the currentayon-backendversion, otherwise we create one, and request a restart, this package has the attributehas_plugins=True - We try to find plug-ins for our
ayon_server. - We, as before, attempt to initialize the add-ons defined in the bundles; we can now list all installed packages without actually initializing them, and keep a list of initialized and broken ones.
- When installing an addon, we have a
rezbuild.pythat we fall back for simple addons; there's a bug in rez that makes it mandatory for thepackage.pyto contain thebuild_commandattribute set (tried to add it programmatically, but it won't install the package, due this bug).
All the rest should work as it does now, I really haven't tested the migration of settings between bundles, so that might not be working at the minute.
Reviewing
I tired to keep it tidy and compartemantilized, so there are 4 commits:
- Implement the RezRepo class
- Refactor AddonLibrary to make use of the RezRepo
- Modify all instance of the AddonLibrary in the
apifolder, to adapt to any required changes - Modify all instances of the AddonLibrary in the
ayon_serverfolder, to adapt to any required changes, this one has some bits that have changed more than simple method renames.
TODO
- Adapt AYON addons to rez packages (simply add a
package.pyat the root). - Refactor the
BaseServerAddonand move some of the attributes to thepackage.pythen, read the info from there.
Testing note
I would suggest making a copy of the docker-compose.yml in the ayon-docker backend and build a new image called ayon-rez that build the new rez dependency; so it does not interfere with your existing deploys; also map the /addons folder to a different one than the one you are currently using.
version: "3.7"
services:
postgres:
image: postgres:15
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ayon"]
interval: 5s
timeout: 5s
retries: 5
expose: [5432]
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "db:/var/lib/postgresql/data"
environment:
- "POSTGRES_USER=ayon"
- "POSTGRES_PASSWORD=ayon"
- "POSTGRES_DB=ayon"
redis:
image: redis:alpine
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
interval: 5s
timeout: 5s
retries: 5
expose: [6379]
server:
image: localhost/ayon-rez:latest
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/api/info"]
interval: 10s
timeout: 2s
retries: 3
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
# uncomment for older versions of Docker (>4.0.0) and comment out above "depends on" section.
#depends_on:
#- postgres
#- redis
expose: [5000]
ports: ["5000:5000"]
volumes:
- "./rezrepo:/addons:Z"
- "./storage:/storage:Z"
# comment out the following line on Windows
- "/etc/localtime:/etc/localtime:ro"
# uncomment the following line if you need to work on the backend code
- "/home/minkiu/Projects/ynput/ayon-backend:/backend:Z"
volumes:
db: {}
You can use this PR to generate rez packages out of the OpenPype ones: https://github.com/ynput/OpenPype/pull/6169
Marking as draft so we can have a conversation about this.
Thanks for drafting a prototype! I haven't been involved much with the Ayon backend but just wanted to say that any work on this front in combination with Rez is greatly appreciated.
This PR's Rez integration is solely regarding the addons and modules in the backend, not the running of the actual DCC application and tools, right? So it's not for those that might have a huge ready-to-go Rez repository already with many applications and tools and allow them to launch those through OpenPype for certain hosts. Or am I mistaken?
This PR's Rez integration is solely regarding the addons and modules in the backend, not the running of the actual DCC application and tools, right? So it's not for those that might have a huge ready-to-go Rez repository already with many applications and tools and allow them to launch those through OpenPype for certain hosts. Or am I mistaken?
For that we will need to implement alternative to applications addon that will use rez and also we will need to create rez package from ayon-launcher (that will be the new entry point as Igniter in OP is)
For that we will need to implement alternative to applications addon that will use rez and also we will need to create rez package from ayon-launcher (that will be the new entry point as Igniter in OP is)
Great. Just to confirm, so this particular PR is not intended to do that. Right?
You are right, this is not the PR for that.
And there are other changes happening on the same parts, that I'll need to rebase later, so this won't be merge in the near future I'd say.
Is with this PR possible to manually add/remove addon to/from server?
No, this PR doesn't implement the adding/removing side of thing, will wait till the bundle changes settle to rebase and piggyback on current implementation to install /remove and hook there Rez
I am finally satisfied with the commit history, and managed to catch some bugs, it is now ready to be reviewed, will update the PR to reflect changes.