OP-4845 - created new AYON_* env var to differentiate Deadline jobs

OP and Ayon will live together for a while so jobs sent to DL need to be differentiated by new env vars.
This commit is contained in:
Petr Kalis 2023-07-17 17:19:51 +02:00
parent afa1d3cb03
commit 3e5aa1033b
10 changed files with 40 additions and 17 deletions

View file

@ -394,6 +394,15 @@ class DeadlineJobInfo(object):
for key, value in data.items():
setattr(self, key, value)
def add_render_job_env_var(self):
"""Check if in OP or AYON mode and use appropriate env var."""
render_job = (
"AYON_RENDER_JOB" if os.environ.get("USE_AYON_SERVER") == '1'
else "OPENPYPE_RENDER_JOB")
self.EnvironmentKeyValue[render_job] = "1"
@six.add_metaclass(AbstractMetaInstancePlugin)
class AbstractSubmitDeadline(pyblish.api.InstancePlugin,

View file

@ -106,8 +106,8 @@ class AfterEffectsSubmitDeadline(
if value:
dln_job_info.EnvironmentKeyValue[key] = value
# to recognize job from PYPE for turning Event On/Off
dln_job_info.EnvironmentKeyValue["OPENPYPE_RENDER_JOB"] = "1"
# to recognize render jobs
dln_job_info.add_render_job_env_var()
return dln_job_info

View file

@ -299,8 +299,8 @@ class HarmonySubmitDeadline(
if value:
job_info.EnvironmentKeyValue[key] = value
# to recognize job from PYPE for turning Event On/Off
job_info.EnvironmentKeyValue["OPENPYPE_RENDER_JOB"] = "1"
# to recognize render jobs
job_info.add_render_job_env_var()
return job_info

View file

@ -105,8 +105,8 @@ class HoudiniSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
if value:
job_info.EnvironmentKeyValue[key] = value
# to recognize job from PYPE for turning Event On/Off
job_info.EnvironmentKeyValue["OPENPYPE_RENDER_JOB"] = "1"
# to recognize render jobs
job_info.add_render_job_env_var(job_info)
for i, filepath in enumerate(instance.data["files"]):
dirname = os.path.dirname(filepath)

View file

@ -131,8 +131,8 @@ class MaxSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline,
continue
job_info.EnvironmentKeyValue[key] = value
# to recognize job from PYPE for turning Event On/Off
job_info.EnvironmentKeyValue["OPENPYPE_RENDER_JOB"] = "1"
# to recognize render jobs
job_info.add_render_job_env_var(job_info)
job_info.EnvironmentKeyValue["OPENPYPE_LOG_NO_COLORS"] = "1"
# Add list of expected files to job

View file

@ -225,8 +225,8 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline,
continue
job_info.EnvironmentKeyValue[key] = value
# to recognize job from PYPE for turning Event On/Off
job_info.EnvironmentKeyValue["OPENPYPE_RENDER_JOB"] = "1"
# to recognize render jobs
job_info.add_render_job_env_var()
job_info.EnvironmentKeyValue["OPENPYPE_LOG_NO_COLORS"] = "1"
# Adding file dependencies.

View file

@ -114,11 +114,16 @@ class MayaSubmitRemotePublishDeadline(
environment["AVALON_TASK"] = instance.context.data["task"]
environment["AVALON_APP_NAME"] = os.environ.get("AVALON_APP_NAME")
environment["OPENPYPE_LOG_NO_COLORS"] = "1"
environment["OPENPYPE_REMOTE_JOB"] = "1"
environment["OPENPYPE_USERNAME"] = instance.context.data["user"]
environment["OPENPYPE_PUBLISH_SUBSET"] = instance.data["subset"]
environment["OPENPYPE_REMOTE_PUBLISH"] = "1"
if os.environ.get("USE_AYON_SERVER") == '1':
environment["AYON_REMOTE_PUBLISH"] = "1"
else:
environment["OPENPYPE_REMOTE_PUBLISH"] = "1"
for key, value in environment.items():
job_info.EnvironmentKeyValue[key] = value

View file

@ -337,8 +337,11 @@ class NukeSubmitDeadline(pyblish.api.InstancePlugin,
if _path.lower().startswith('openpype_'):
environment[_path] = os.environ[_path]
# to recognize job from PYPE for turning Event On/Off
environment["OPENPYPE_RENDER_JOB"] = "1"
# to recognize render jobs
render_job_label = (
"AYON_RENDER_JOB" if os.environ.get("USE_AYON_SERVER") == '1'
else "OPENPYPE_RENDER_JOB")
environment[render_job_label] = "1"
# finally search replace in values of any key
if self.env_search_replace_values:

View file

@ -255,13 +255,19 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin,
"AVALON_ASSET": instance.context.data["asset"],
"AVALON_TASK": instance.context.data["task"],
"OPENPYPE_USERNAME": instance.context.data["user"],
"OPENPYPE_PUBLISH_JOB": "1",
"OPENPYPE_RENDER_JOB": "0",
"OPENPYPE_REMOTE_JOB": "0",
"OPENPYPE_LOG_NO_COLORS": "1",
"IS_TEST": str(int(is_in_tests()))
}
if os.environ.get("USE_AYON_SERVER") == '1':
environment["AYON_PUBLISH_JOB"] = "1"
environment["AYON_RENDER_JOB"] = "0"
environment["AYON_REMOTE_PUBLISH"] = "0"
else:
environment["OPENPYPE_PUBLISH_JOB"] = "1"
environment["OPENPYPE_RENDER_JOB"] = "0"
environment["OPENPYPE_REMOTE_PUBLISH"] = "0"
# add environments from self.environ_keys
for env_key in self.environ_keys:
if os.getenv(env_key):

View file

@ -422,7 +422,7 @@ def __main__(deadlinePlugin):
openpype_publish_job = \
job.GetJobEnvironmentKeyValue('OPENPYPE_PUBLISH_JOB') or '0'
openpype_remote_job = \
job.GetJobEnvironmentKeyValue('OPENPYPE_REMOTE_JOB') or '0'
job.GetJobEnvironmentKeyValue('OPENPYPE_REMOTE_PUBLISH') or '0'
print("--- Job type - render {}".format(openpype_render_job))
print("--- Job type - publish {}".format(openpype_publish_job))