From 78a92588bb91a4a70bca912c526a15d04870f211 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 24 Jun 2021 16:06:42 +0200 Subject: [PATCH 1/3] deadline: nuke adding settings attributes - allowed environment keys - search replace in environment values --- .../plugins/publish/submit_nuke_deadline.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py b/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py index 7faa3393e54..879c92490b6 100644 --- a/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py @@ -32,6 +32,8 @@ class NukeSubmitDeadline(pyblish.api.InstancePlugin): department = "" limit_groups = {} use_gpu = False + env_allowed_keys = [] + env_search_replace_values = {} def process(self, instance): instance.data["toBeRenderedOn"] = "deadline" @@ -242,18 +244,18 @@ def payload_submit(self, "PYBLISHPLUGINPATH", "NUKE_PATH", "TOOL_ENV", - "OPENPYPE_DEV", "FOUNDRY_LICENSE" ] + # add allowed keys from preset if any + if self.env_allowed_keys: + keys += self.env_allowed_keys + environment = dict({key: os.environ[key] for key in keys if key in os.environ}, **api.Session) # self.log.debug("enviro: {}".format(pprint(environment))) + for path in os.environ: - if path.lower().startswith('pype_'): - environment[path] = os.environ[path] - if path.lower().startswith('nuke_'): - environment[path] = os.environ[path] - if 'license' in path.lower(): + if path.lower().startswith('openpype_'): environment[path] = os.environ[path] clean_environment = {} @@ -285,6 +287,13 @@ def payload_submit(self, environment = clean_environment # to recognize job from PYPE for turning Event On/Off environment["OPENPYPE_RENDER_JOB"] = "1" + + # finally search replace in values of any key + if self.env_search_replace_values: + for key, value in environment.items(): + for _k, _v in self.env_search_replace_values.items(): + environment[key] = value.replace(_k, _v) + payload["JobInfo"].update({ "EnvironmentKeyValue%d" % index: "{key}={value}".format( key=key, From 248912f9fa3b0d3611ccf898343e45e43faf4da3 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 24 Jun 2021 16:15:23 +0200 Subject: [PATCH 2/3] settings: deadline nuke submission arguments --- .../defaults/project_settings/deadline.json | 2 ++ .../projects_schema/schema_project_deadline.json | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/openpype/settings/defaults/project_settings/deadline.json b/openpype/settings/defaults/project_settings/deadline.json index 2cc345d5ade..5861015f2cb 100644 --- a/openpype/settings/defaults/project_settings/deadline.json +++ b/openpype/settings/defaults/project_settings/deadline.json @@ -29,6 +29,8 @@ "group": "", "department": "", "use_gpu": true, + "env_allowed_keys": [], + "env_search_replace_values": {}, "limit_groups": {} }, "HarmonySubmitDeadline": { diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_deadline.json b/openpype/settings/entities/schemas/projects_schema/schema_project_deadline.json index f6a81279514..3281c9ce4dd 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_deadline.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_deadline.json @@ -173,6 +173,20 @@ "key": "use_gpu", "label": "Use GPU" }, + { + "type": "list", + "key": "env_allowed_keys", + "object_type": "text", + "label": "Allowed environment keys" + }, + { + "type": "dict-modifiable", + "key": "env_search_replace_values", + "label": "Search & replace in environment values", + "object_type": { + "type": "text" + } + }, { "type": "dict-modifiable", "key": "limit_groups", From 29ef07aada6ff9ee20f5b04ca25e99bcbb5b68c4 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 1 Jul 2021 16:28:05 +0200 Subject: [PATCH 3/3] pr suggestion https://github.com/pypeclub/OpenPype/pull/1756#discussion_r660710802 --- .../deadline/plugins/publish/submit_nuke_deadline.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py b/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py index 879c92490b6..fed98d8a08a 100644 --- a/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py +++ b/openpype/modules/deadline/plugins/publish/submit_nuke_deadline.py @@ -254,9 +254,9 @@ def payload_submit(self, if key in os.environ}, **api.Session) # self.log.debug("enviro: {}".format(pprint(environment))) - for path in os.environ: - if path.lower().startswith('openpype_'): - environment[path] = os.environ[path] + for _path in os.environ: + if _path.lower().startswith('openpype_'): + environment[_path] = os.environ[_path] clean_environment = {} for key, value in environment.items():