diff --git a/client/ayon_core/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py b/client/ayon_core/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py index 96f131b922..81aab00b93 100644 --- a/client/ayon_core/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py +++ b/client/ayon_core/modules/deadline/repository/custom/plugins/GlobalJobPreLoad.py @@ -323,7 +323,7 @@ def inject_openpype_environment(deadlinePlugin): # tempfile.TemporaryFile cannot be used because of locking temp_file_name = "{}_{}.json".format( - datetime.utcnow().strftime('%Y%m%d%H%M%S%f'), + datetime.utcnow().strftime("%Y%m%d%H%M%S%f"), str(uuid.uuid1()) ) export_url = os.path.join(tempfile.gettempdir(), temp_file_name) @@ -343,7 +343,7 @@ def inject_openpype_environment(deadlinePlugin): "envgroup": "farm" } - if job.GetJobEnvironmentKeyValue('IS_TEST'): + if job.GetJobEnvironmentKeyValue("IS_TEST"): args.append("--automatic-tests") if all(add_kwargs.values()): @@ -412,13 +412,13 @@ def inject_openpype_environment(deadlinePlugin): def inject_ayon_environment(deadlinePlugin): - """ Pull env vars from Ayon and push them to rendering process. + """ Pull env vars from AYON and push them to rendering process. - Used for correct paths, configuration from OpenPype etc. + Used for correct paths, configuration from AYON etc. """ job = deadlinePlugin.GetJob() - print(">>> Injecting Ayon environments ...") + print(">>> Injecting AYON environments ...") try: exe_list = get_ayon_executable() exe = FileUtils.SearchFileList(exe_list) @@ -435,17 +435,18 @@ def inject_ayon_environment(deadlinePlugin): ayon_bundle_name = job.GetJobEnvironmentKeyValue("AYON_BUNDLE_NAME") if not ayon_bundle_name: - raise RuntimeError("Missing env var in job properties " - "AYON_BUNDLE_NAME") + raise RuntimeError( + "Missing env var in job properties AYON_BUNDLE_NAME" + ) config = RepositoryUtils.GetPluginConfig("Ayon") ayon_server_url = ( - job.GetJobEnvironmentKeyValue("AYON_SERVER_URL") or - config.GetConfigEntryWithDefault("AyonServerUrl", "") + job.GetJobEnvironmentKeyValue("AYON_SERVER_URL") or + config.GetConfigEntryWithDefault("AyonServerUrl", "") ) ayon_api_key = ( - job.GetJobEnvironmentKeyValue("AYON_API_KEY") or - config.GetConfigEntryWithDefault("AyonApiKey", "") + job.GetJobEnvironmentKeyValue("AYON_API_KEY") or + config.GetConfigEntryWithDefault("AyonApiKey", "") ) if not all([ayon_server_url, ayon_api_key]): @@ -457,7 +458,7 @@ def inject_ayon_environment(deadlinePlugin): # tempfile.TemporaryFile cannot be used because of locking temp_file_name = "{}_{}.json".format( - datetime.utcnow().strftime('%Y%m%d%H%M%S%f'), + datetime.utcnow().strftime("%Y%m%d%H%M%S%f"), str(uuid.uuid1()) ) export_url = os.path.join(tempfile.gettempdir(), temp_file_name) @@ -477,7 +478,7 @@ def inject_ayon_environment(deadlinePlugin): "envgroup": "farm", } - if job.GetJobEnvironmentKeyValue('IS_TEST'): + if job.GetJobEnvironmentKeyValue("IS_TEST"): args.append("--automatic-tests") if all(add_kwargs.values()): @@ -545,19 +546,23 @@ def inject_ayon_environment(deadlinePlugin): def get_ayon_executable(): - """Return OpenPype Executable from Event Plug-in Settings + """Return AYON Executable from Event Plug-in Settings Returns: - (list) of paths + list[str]: AYON executable paths. + Raises: - (RuntimeError) if no path configured at all + RuntimeError: When no path configured at all. + """ config = RepositoryUtils.GetPluginConfig("Ayon") exe_list = config.GetConfigEntryWithDefault("AyonExecutable", "") if not exe_list: - raise RuntimeError("Path to Ayon executable not configured." - "Please set it in Ayon Deadline Plugin.") + raise RuntimeError( + "Path to AYON executable not configured." + "Please set it in Ayon Deadline Plugin." + ) # clean '\ ' for MacOS pasting if platform.system().lower() == "darwin": @@ -581,8 +586,9 @@ def inject_render_job_id(deadlinePlugin): print(">>> Dependency IDs: {}".format(dependency_ids)) render_job_ids = ",".join(dependency_ids) - deadlinePlugin.SetProcessEnvironmentVariable("RENDER_JOB_IDS", - render_job_ids) + deadlinePlugin.SetProcessEnvironmentVariable( + "RENDER_JOB_IDS", render_job_ids + ) print(">>> Injection end.") @@ -591,34 +597,33 @@ def __main__(deadlinePlugin): print(">>> Getting job ...") job = deadlinePlugin.GetJob() - openpype_render_job = \ - job.GetJobEnvironmentKeyValue('OPENPYPE_RENDER_JOB') or '0' - openpype_publish_job = \ - job.GetJobEnvironmentKeyValue('OPENPYPE_PUBLISH_JOB') or '0' - openpype_remote_job = \ - job.GetJobEnvironmentKeyValue('OPENPYPE_REMOTE_PUBLISH') or '0' + openpype_render_job = job.GetJobEnvironmentKeyValue( + "OPENPYPE_RENDER_JOB") + openpype_publish_job = job.GetJobEnvironmentKeyValue( + "OPENPYPE_PUBLISH_JOB") + openpype_remote_job = job.GetJobEnvironmentKeyValue( + "OPENPYPE_REMOTE_PUBLISH") - if openpype_publish_job == '1' and openpype_render_job == '1': - raise RuntimeError("Misconfiguration. Job couldn't be both " + - "render and publish.") + if openpype_publish_job == "1" and openpype_render_job == "1": + raise RuntimeError( + "Misconfiguration. Job couldn't be both render and publish." + ) - if openpype_publish_job == '1': + if openpype_publish_job == "1": inject_render_job_id(deadlinePlugin) - if openpype_render_job == '1' or openpype_remote_job == '1': + if openpype_render_job == "1" or openpype_remote_job == "1": inject_openpype_environment(deadlinePlugin) - ayon_render_job = \ - job.GetJobEnvironmentKeyValue('AYON_RENDER_JOB') or '0' - ayon_publish_job = \ - job.GetJobEnvironmentKeyValue('AYON_PUBLISH_JOB') or '0' - ayon_remote_job = \ - job.GetJobEnvironmentKeyValue('AYON_REMOTE_PUBLISH') or '0' + ayon_render_job = job.GetJobEnvironmentKeyValue("AYON_RENDER_JOB") + ayon_publish_job = job.GetJobEnvironmentKeyValue("AYON_PUBLISH_JOB") + ayon_remote_job = job.GetJobEnvironmentKeyValue("AYON_REMOTE_PUBLISH") - if ayon_publish_job == '1' and ayon_render_job == '1': - raise RuntimeError("Misconfiguration. Job couldn't be both " + - "render and publish.") + if ayon_publish_job == "1" and ayon_render_job == "1": + raise RuntimeError( + "Misconfiguration. Job couldn't be both render and publish." + ) - if ayon_publish_job == '1': + if ayon_publish_job == "1": inject_render_job_id(deadlinePlugin) - if ayon_render_job == '1' or ayon_remote_job == '1': + if ayon_render_job == "1" or ayon_remote_job == "1": inject_ayon_environment(deadlinePlugin)