Skip to content

Commit

Permalink
use server name to get job info
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT committed Jan 8, 2025
1 parent 61cd578 commit 6630497
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
25 changes: 25 additions & 0 deletions client/ayon_deadline/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pyblish.api
import clique

from ayon_core.pipeline import PublishValidationError
from ayon_deadline.abstract_submit_deadline import requests_get


Expand Down Expand Up @@ -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'"""
Expand Down

0 comments on commit 6630497

Please sign in to comment.