Cleaned up how to get RR path once again

This commit is contained in:
Petr Kalis 2024-02-23 12:48:00 +01:00
parent ff9db0ffa1
commit d110f60e78
3 changed files with 37 additions and 26 deletions

View file

@ -108,7 +108,7 @@ class BaseCreateRoyalRenderJob(pyblish.api.InstancePlugin,
context = instance.context
self._rr_root = instance.data.get("rrPathName")
self._rr_root = instance.data.get("rr_root")
if not self._rr_root:
raise KnownPublishError(
("Missing RoyalRender root. "

View file

@ -1,41 +1,52 @@
# -*- coding: utf-8 -*-
"""
Requires:
instance.context.data["project_settings"]
Provides:
instance.data["rr_root"] (str) - root folder of RoyalRender server
"""
import os.path
import pyblish.api
from ayon_core.modules.royalrender.rr_job import get_rr_platform
class CollectRRPathFromInstance(pyblish.api.InstancePlugin):
"""Collect RR Path from instance."""
"""Collect RR Path from instance.
All RoyalRender server roots are set in `Studio Settings`, each project
uses only key pointing to that part to limit typos inside of Project
settings.
Eventually could be possible to add dropdown with these keys to the
Creators to allow artists to select which RR server they would like to use.
"""
order = pyblish.api.CollectorOrder
label = "Collect Royal Render path name from the Instance"
families = ["render", "prerender", "renderlayer"]
def process(self, instance):
instance.data["rrPathName"] = self._collect_rr_path_name(instance)
instance.data["rr_root"] = self._collect_root(instance)
self.log.info(
"Using '{}' for submission.".format(instance.data["rrPathName"]))
"Using '{}' for submission.".format(instance.data["rr_root"]))
@staticmethod
def _collect_rr_path_name(instance):
def _collect_root(self, instance):
# type: (pyblish.api.Instance) -> str
"""Get Royal Render pat name from render instance."""
# TODO there are no "rrPaths" on instance, if Publisher should expose
# this (eg. artist could select specific server) it must be added
# to publisher
instance_rr_paths = instance.data.get("rrPaths")
if instance_rr_paths is None:
return "default"
"""Get Royal Render pat name from render instance.
If artist should be able to select specific RR server it must be added
to creator. It is not there yet.
"""
rr_settings = instance.context.data["project_settings"]["royalrender"]
rr_paths = rr_settings["rr_paths"]
selected_paths = rr_settings["selected_rr_paths"]
selected_keys = rr_settings["selected_rr_paths"]
rr_servers = {
path_key
for path_key in selected_paths
if path_key in rr_paths
platform = get_rr_platform()
key_to_path = {
item["name"]: item["value"][platform]
for item in rr_paths
}
for instance_rr_path in instance_rr_paths:
if instance_rr_path in rr_servers:
return instance_rr_path
return "default"
for selected_key in selected_keys:
rr_root = key_to_path[selected_key]
if os.path.exists(rr_root):
return rr_root

View file

@ -37,8 +37,8 @@ class SubmitJobsToRoyalRender(pyblish.api.ContextPlugin):
isinstance(job, RRJob)
for job in instance.data.get("rrJobs")):
jobs += instance.data.get("rrJobs")
if instance.data.get("rrPathName"):
instance_rr_path = instance.data["rrPathName"]
if instance.data.get("rr_root"):
instance_rr_path = instance.data["rr_root"]
if jobs:
self._rr_root = instance_rr_path