Automate project folder structure creation on creating project on Ayon

What better suits this description is: AYON Service with your studio storage mounted (so that it can access your file system and create folders).

Alternatively,

  • use a web action to create folders.
  • OR use a web action to run piece of code that keep looping e.g. every 10 minutes check the project hierarchy on server and create them on disk.
  • OR add a tray button to the launcher that create one time or keep looping.
  • OR add a custom tray code that on initialization maybe inside tray_init see example, where you can open a thread and keep looping. this is inspired by this (but it needs to to be limited, e.g. make it work with one user only, as you only need it once).

I’m not making recommendations. I’m just writing ideas that came to my mind

Let’s move to the next part, you want to create the work directories.
It’s worth mentioning that AYON provides a flexible settings for work directories: work templates + work template profiles + extra work folders. These configurations are very context aware (project, folder, task, application)
So typically, you should do something along these lines.

from ayon_core.pipeline.workfile import (
    get_workdir,
    create_workdir_extra_folders,
)
from ayon_core.pipeline.context_tools import (
    get_current_project_entity,
    get_current_folder_entity,
    get_current_task_entity,
    get_current_host_name
)

# Get Current host name
host_name = get_current_host_name()

# Get Entities
project_entity = get_current_project_entity()
folder_entity = get_current_folder_entity()
task_entity = get_current_task_entity()

#  we already have a function to retrieve resolved work dir
work_dir = get_workdir(
    project_entity, folder_entity, task_entity, host_name
)

if not os.path.exists(workdir):
    os.makedirs(workdir, exist_ok=True)

# Create extra folders
 create_workdir_extra_folders(
    workdir,
    host_name,
    task_entity["taskType"],
    task_entity["name"],
    project_entity["name"]
)

Also, you may need to care a lot about caching.

I’m aware you can simplify this code a ton by hardcoding many parts which will mostly for your studio specific configurations.

Tbh, everyone wants to stay aways from that. This is most likely because the lack of documentation about it and there are not examples that made for the purpose of learning how services are developed. And, production examples can be overwhelming if you are not familiar with them. you can take this post as an example How do I develop services? there isn’t much info there :smile:
Maybe this can be a topic for AYON workshops on Ynput Summit 26.