Merge branch 'develop' into enhancement/rename_maya_openpype_tools

This commit is contained in:
Kayla Man 2023-12-05 20:10:17 +08:00 committed by GitHub
commit d700e4eb43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 146 additions and 51 deletions

View file

@ -80,8 +80,8 @@ def _get_subsets(
for subset in con.get_products(
project_name,
subset_ids,
subset_names,
product_ids=subset_ids,
product_names=subset_names,
folder_ids=folder_ids,
names_by_folder_ids=names_by_folder_ids,
active=active,
@ -113,23 +113,23 @@ def _get_versions(
queried_versions = con.get_versions(
project_name,
version_ids,
subset_ids,
versions,
hero,
standard,
latest,
version_ids=version_ids,
product_ids=subset_ids,
versions=versions,
hero=hero,
standard=standard,
latest=latest,
active=active,
fields=fields
)
versions = []
version_entities = []
hero_versions = []
for version in queried_versions:
if version["version"] < 0:
hero_versions.append(version)
else:
versions.append(convert_v4_version_to_v3(version))
version_entities.append(convert_v4_version_to_v3(version))
if hero_versions:
subset_ids = set()
@ -159,9 +159,9 @@ def _get_versions(
break
conv_hero = convert_v4_version_to_v3(hero_version)
conv_hero["version_id"] = version_id
versions.append(conv_hero)
version_entities.append(conv_hero)
return versions
return version_entities
def get_asset_by_id(project_name, asset_id, fields=None):
@ -539,11 +539,11 @@ def get_representations(
representations = con.get_representations(
project_name,
representation_ids,
representation_names,
version_ids,
names_by_version_ids,
active,
representation_ids=representation_ids,
representation_names=representation_names,
version_ids=version_ids,
names_by_version_ids=names_by_version_ids,
active=active,
fields=fields
)
for representation in representations:

View file

@ -27,6 +27,7 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
"tvpaint",
"substancepainter",
"aftereffects",
"wrap"
}
launch_types = {LaunchTypes.local}

View file

@ -19,7 +19,8 @@ class CopyTemplateWorkfile(PreLaunchHook):
# Before `AddLastWorkfileToLaunchArgs`
order = 0
app_groups = {"blender", "photoshop", "tvpaint", "aftereffects"}
app_groups = {"blender", "photoshop", "tvpaint", "aftereffects",
"wrap"}
launch_types = {LaunchTypes.local}
def execute(self):

View file

@ -1,23 +1,28 @@
# -*- coding: utf-8 -*-
"""Submitting render job to RoyalRender."""
import os
import re
import json
import platform
import re
import tempfile
import uuid
from datetime import datetime
import pyblish.api
from openpype.tests.lib import is_in_tests
from openpype.pipeline.publish.lib import get_published_workfile_instance
from openpype.pipeline.publish import KnownPublishError
from openpype.lib import BoolDef, NumberDef, is_running_from_build
from openpype.lib.execute import run_openpype_process
from openpype.modules.royalrender.api import Api as rrApi
from openpype.modules.royalrender.rr_job import (
RRJob, CustomAttribute, get_rr_platform)
from openpype.lib import (
is_running_from_build,
BoolDef,
NumberDef,
CustomAttribute,
RRJob,
RREnvList,
get_rr_platform,
)
from openpype.pipeline import OpenPypePyblishPluginMixin
from openpype.pipeline.publish import KnownPublishError
from openpype.pipeline.publish.lib import get_published_workfile_instance
from openpype.tests.lib import is_in_tests
class BaseCreateRoyalRenderJob(pyblish.api.InstancePlugin,
@ -302,3 +307,68 @@ class BaseCreateRoyalRenderJob(pyblish.api.InstancePlugin,
path = path.replace(first_frame, "#" * padding)
return path
def inject_environment(self, instance, job):
# type: (pyblish.api.Instance, RRJob) -> RRJob
"""Inject environment variables for RR submission.
This function mimics the behaviour of the Deadline
integration. It is just temporary solution until proper
runtime environment injection is implemented in RR.
Args:
instance (pyblish.api.Instance): Publishing instance
job (RRJob): RRJob instance to be injected.
Returns:
RRJob: Injected RRJob instance.
Throws:
RuntimeError: If any of the required env vars is missing.
"""
temp_file_name = "{}_{}.json".format(
datetime.utcnow().strftime('%Y%m%d%H%M%S%f'),
str(uuid.uuid1())
)
export_url = os.path.join(tempfile.gettempdir(), temp_file_name)
print(">>> Temporary path: {}".format(export_url))
args = [
"--headless",
"extractenvironments",
export_url
]
anatomy_data = instance.context.data["anatomyData"]
add_kwargs = {
"project": anatomy_data["project"]["name"],
"asset": instance.context.data["asset"],
"task": anatomy_data["task"]["name"],
"app": instance.context.data.get("appName"),
"envgroup": "farm"
}
if os.getenv('IS_TEST'):
args.append("--automatic-tests")
if not all(add_kwargs.values()):
raise RuntimeError((
"Missing required env vars: AVALON_PROJECT, AVALON_ASSET,"
" AVALON_TASK, AVALON_APP_NAME"
))
for key, value in add_kwargs.items():
args.extend([f"--{key}", value])
self.log.debug("Executing: {}".format(" ".join(args)))
run_openpype_process(*args, logger=self.log)
self.log.debug("Loading file ...")
with open(export_url) as fp:
contents = json.load(fp)
job.rrEnvList = RREnvList(contents).serialize()
return job

View file

@ -2,7 +2,7 @@
"""Submitting render job to RoyalRender."""
import os
from maya.OpenMaya import MGlobal
from maya.OpenMaya import MGlobal # noqa: F401
from openpype.modules.royalrender import lib
from openpype.pipeline.farm.tools import iter_expected_files
@ -38,5 +38,6 @@ class CreateMayaRoyalRenderJob(lib.BaseCreateRoyalRenderJob):
job = self.get_job(instance, self.scene_path, first_file_path,
layer_name)
job = self.update_job_with_host_specific(instance, job)
job = self.inject_environment(instance, job)
instance.data["rrJobs"].append(job)

View file

@ -25,6 +25,7 @@ class CreateNukeRoyalRenderJob(lib.BaseCreateRoyalRenderJob):
jobs = self.create_jobs(instance)
for job in jobs:
job = self.update_job_with_host_specific(instance, job)
job = self.inject_environment(instance, job)
instance.data["rrJobs"].append(job)

View file

@ -205,6 +205,9 @@ class CreatePublishRoyalRenderJob(pyblish.api.InstancePlugin,
jobs_pre_ids = []
for job in instance.data["rrJobs"]: # type: RRJob
if job.rrEnvList:
if len(job.rrEnvList) > 2000:
self.log.warning(("Job environment is too long "
f"{len(job.rrEnvList)} > 2000"))
job_environ.update(
dict(RREnvList.parse(job.rrEnvList))
)

View file

@ -32,7 +32,7 @@ class RREnvList(dict):
"""Parse rrEnvList string and return it as RREnvList object."""
out = RREnvList()
for var in data.split("~~~"):
k, v = var.split("=")
k, v = var.split("=", maxsplit=1)
out[k] = v
return out
@ -172,7 +172,7 @@ class RRJob(object):
# Environment
# only used in RR 8.3 and newer
rrEnvList = attr.ib(default=None) # type: str
rrEnvList = attr.ib(default=None, type=str) # type: str
class SubmitterParameter:

View file

@ -186,6 +186,7 @@ class PypeCommands:
app,
env_group=env_group,
launch_type=LaunchTypes.farm_render,
env={}
)
else:
env = os.environ.copy()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1158,6 +1158,32 @@
}
]
},
"wrap": {
"enabled": true,
"label": "Wrap",
"icon": "{}/app_icons/wrap.png",
"host_name": "wrap",
"environment": "{\n \n}",
"variants": [
{
"name": "2023",
"use_python_2": false,
"executables": {
"windows": [
"c:\\Program Files\\Faceform\\Wrap 2023.10.2\\Wrap.exe"
],
"darwin": [],
"linux": []
},
"arguments": {
"windows": [],
"darwin": [],
"linux": []
},
"environment": "{\n \n}"
}
]
},
"additional_apps": []
}
}

View file

@ -168,6 +168,8 @@ class ApplicationsSettings(BaseSettingsModel):
default_factory=AppGroupWithPython, title="Substance Painter")
unreal: AppGroup = Field(
default_factory=AppGroupWithPython, title="Unreal Editor")
wrap: AppGroup = Field(
default_factory=AppGroupWithPython, title="Wrap")
additional_apps: list[AdditionalAppGroup] = Field(
default_factory=list, title="Additional Applications")

View file

@ -1,31 +1,18 @@
from pydantic import Field
from pathlib import Path
from ayon_server.settings import BaseSettingsModel
class PathsTemplate(BaseSettingsModel):
windows: Path = Field(
'',
title="Windows"
)
darwin: Path = Field(
'',
title="MacOS"
)
linux: Path = Field(
'',
title="Linux"
)
from ayon_server.settings import BaseSettingsModel, MultiplatformPathModel
class CustomBuilderTemplate(BaseSettingsModel):
_layout = "expanded"
task_types: list[str] = Field(
default_factory=list,
title="Task types",
)
template_path: PathsTemplate = Field(
default_factory=PathsTemplate
path: MultiplatformPathModel = Field(
default_factory=MultiplatformPathModel,
title="Template path"
)
@ -37,5 +24,6 @@ class WorkfileBuilderPlugin(BaseSettingsModel):
)
custom_templates: list[CustomBuilderTemplate] = Field(
default_factory=CustomBuilderTemplate
default_factory=CustomBuilderTemplate,
title="Template profiles"
)

View file

@ -21,7 +21,7 @@ class TestDeadlinePublishInMaya(MayaDeadlinePublishTestClass):
{OPENPYPE_ROOT}/.venv/Scripts/python.exe {OPENPYPE_ROOT}/start.py runtests ../tests/integration/hosts/maya # noqa: E501
"""
PERSIST = True
PERSIST = False
TEST_FILES = [
("test_deadline_publish_in_maya", "", "")

View file

@ -236,6 +236,7 @@ createNode polyDisc -n "polyDisc1";
rename -uid "9ED8A7BD-4FFD-6107-4322-35ACD1D3AC42";
createNode aiOptions -s -n "defaultArnoldRenderOptions";
rename -uid "31A81965-48A6-B90D-503D-2FA162B7C982";
setAttr ".skip_license_check" yes;
createNode aiAOVFilter -s -n "defaultArnoldFilter";
rename -uid "77A2BCB1-4613-905E-080E-B997FD5E1C6F";
setAttr ".ai_translator" -type "string" "gaussian";