From 6630497f0bc671be22167012d46a82be1385b816 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:34:04 +0100 Subject: [PATCH] use server name to get job info --- client/ayon_deadline/addon.py | 25 +++++++++++++ .../validate_expected_and_rendered_files.py | 35 ++++++------------- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/client/ayon_deadline/addon.py b/client/ayon_deadline/addon.py index 7e9d9a0e98..1938d2db37 100644 --- a/client/ayon_deadline/addon.py +++ b/client/ayon_deadline/addon.py @@ -90,6 +90,31 @@ def get_server_info_by_name(self, server_name: str) -> DeadlineServerInfo: return server_info + def get_job_info( + self, server_name: str, job_id: str + ) -> Optional[Dict[str, Any]]: + """Get job info from Deadline. + + Args: + server_name (str): Deadline Server name from project Settings. + job_id (str): Deadline job id. + + Returns: + Optional[Dict[str, Any]]: Job info from Deadline. + + """ + server_url, auth, verify = self._get_deadline_con_info(server_name) + response = requests.get( + f"{server_url}/api/jobs?JobID={job_id}", + auth=auth, + verify=verify + ) + response.raise_for_status() + data = response.json() + if data: + return data.pop(0) + return None + def submit_job( self, server_name: str, diff --git a/client/ayon_deadline/plugins/publish/global/validate_expected_and_rendered_files.py b/client/ayon_deadline/plugins/publish/global/validate_expected_and_rendered_files.py index ec6bd7fd13..476e6853e7 100644 --- a/client/ayon_deadline/plugins/publish/global/validate_expected_and_rendered_files.py +++ b/client/ayon_deadline/plugins/publish/global/validate_expected_and_rendered_files.py @@ -5,6 +5,7 @@ import pyblish.api import clique +from ayon_core.pipeline import PublishValidationError from ayon_deadline.abstract_submit_deadline import requests_get @@ -200,31 +201,15 @@ def _get_job_info(self, instance, job_id): (dict): Job info from Deadline """ - deadline_url = instance.data["deadline"]["url"] - assert deadline_url, "Requires Deadline Webservice URL" - - url = "{}/api/jobs?JobID={}".format(deadline_url, job_id) - try: - kwargs = {} - auth = instance.data["deadline"]["auth"] - if auth: - kwargs["auth"] = auth - response = requests_get(url, **kwargs) - except requests.exceptions.ConnectionError: - self.log.error("Deadline is not accessible at " - "{}".format(deadline_url)) - return {} - - if not response.ok: - self.log.error("Submission failed!") - self.log.error(response.status_code) - self.log.error(response.content) - raise RuntimeError(response.text) - - json_content = response.json() - if json_content: - return json_content.pop() - return {} + server_name = instance.data["deadline"]["serverName"] + if not server_name: + raise PublishValidationError( + "Deadline server name is not filled." + ) + + addons_manager = instance.context.data["ayonAddonsManager"] + deadline_addon = addons_manager["deadline"] + return deadline_addon.get_job_info(server_name, job_id) def _get_existing_files(self, staging_dir): """Returns set of existing file names from 'staging_dir'"""