Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/AY-5419_Validate-Content-plug…
Browse files Browse the repository at this point in the history
…in-settings
  • Loading branch information
iLLiCiTiT committed May 20, 2024
2 parents daf35ec + befeeae commit 1782928
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 57 deletions.
16 changes: 10 additions & 6 deletions client/ayon_core/hosts/unreal/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@ def get_engine_versions(env=None):
def get_editor_exe_path(engine_path: Path, engine_version: str) -> Path:
"""Get UE Editor executable path."""
ue_path = engine_path / "Engine/Binaries"

ue_name = "UnrealEditor"

# handle older versions of Unreal Engine
if engine_version.split(".")[0] == "4":
ue_name = "UE4Editor"

if platform.system().lower() == "windows":
if engine_version.split(".")[0] == "4":
ue_path /= "Win64/UE4Editor.exe"
elif engine_version.split(".")[0] == "5":
ue_path /= "Win64/UnrealEditor.exe"
ue_path /= f"Win64/{ue_name}.exe"

elif platform.system().lower() == "linux":
ue_path /= "Linux/UE4Editor"
ue_path /= f"Linux/{ue_name}"

elif platform.system().lower() == "darwin":
ue_path /= "Mac/UE4Editor"
ue_path /= f"Mac/{ue_name}"

return ue_path

Expand Down
35 changes: 13 additions & 22 deletions client/ayon_core/modules/deadline/abstract_submit_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@
JSONDecodeError = getattr(json.decoder, "JSONDecodeError", ValueError)


# TODO both 'requests_post' and 'requests_get' should not set 'verify' based
# on environment variable. This should be done in a more controlled way,
# e.g. each deadline url could have checkbox to enabled/disable
# ssl verification.
def requests_post(*args, **kwargs):
"""Wrap request post method.
Disabling SSL certificate validation if ``DONT_VERIFY_SSL`` environment
variable is found. This is useful when Deadline server is
Disabling SSL certificate validation if ``verify`` kwarg is set to False.
This is useful when Deadline server is
running with self-signed certificates and its certificate is not
added to trusted certificates on client machines.
Expand All @@ -46,10 +42,6 @@ def requests_post(*args, **kwargs):
of defense SSL is providing, and it is not recommended.
"""
if 'verify' not in kwargs:
kwargs['verify'] = False if os.getenv("OPENPYPE_DONT_VERIFY_SSL",
True) else True # noqa

auth = kwargs.get("auth")
if auth:
kwargs["auth"] = tuple(auth) # explicit cast to tuple
Expand All @@ -61,8 +53,8 @@ def requests_post(*args, **kwargs):
def requests_get(*args, **kwargs):
"""Wrap request get method.
Disabling SSL certificate validation if ``DONT_VERIFY_SSL`` environment
variable is found. This is useful when Deadline server is
Disabling SSL certificate validation if ``verify`` kwarg is set to False.
This is useful when Deadline server is
running with self-signed certificates and its certificate is not
added to trusted certificates on client machines.
Expand All @@ -71,9 +63,6 @@ def requests_get(*args, **kwargs):
of defense SSL is providing, and it is not recommended.
"""
if 'verify' not in kwargs:
kwargs['verify'] = False if os.getenv("OPENPYPE_DONT_VERIFY_SSL",
True) else True # noqa
auth = kwargs.get("auth")
if auth:
kwargs["auth"] = tuple(auth)
Expand Down Expand Up @@ -466,7 +455,8 @@ def process(self, instance):
self.aux_files = self.get_aux_files()

auth = instance.data["deadline"]["auth"]
job_id = self.process_submission(auth)
verify = instance.data["deadline"]["verify"]
job_id = self.process_submission(auth, verify)
self.log.info("Submitted job to Deadline: {}.".format(job_id))

# TODO: Find a way that's more generic and not render type specific
Expand All @@ -479,10 +469,10 @@ def process(self, instance):
job_info=render_job_info,
plugin_info=render_plugin_info
)
render_job_id = self.submit(payload, auth)
render_job_id = self.submit(payload, auth, verify)
self.log.info("Render job id: %s", render_job_id)

def process_submission(self, auth=None):
def process_submission(self, auth=None, verify=True):
"""Process data for submission.
This takes Deadline JobInfo, PluginInfo, AuxFile, creates payload
Expand All @@ -493,7 +483,7 @@ def process_submission(self, auth=None):
"""
payload = self.assemble_payload()
return self.submit(payload, auth)
return self.submit(payload, auth, verify)

@abstractmethod
def get_job_info(self):
Expand Down Expand Up @@ -583,7 +573,7 @@ def assemble_payload(
"AuxFiles": aux_files or self.aux_files
}

def submit(self, payload, auth):
def submit(self, payload, auth, verify):
"""Submit payload to Deadline API end-point.
This takes payload in the form of JSON file and POST it to
Expand All @@ -592,6 +582,7 @@ def submit(self, payload, auth):
Args:
payload (dict): dict to become json in deadline submission.
auth (tuple): (username, password)
verify (bool): verify SSL certificate if present
Returns:
str: resulting Deadline job id.
Expand All @@ -601,8 +592,8 @@ def submit(self, payload, auth):
"""
url = "{}/api/jobs".format(self._deadline_url)
response = requests_post(url, json=payload,
auth=auth)
response = requests_post(
url, json=payload, auth=auth, verify=verify)
if not response.ok:
self.log.error("Submission failed!")
self.log.error(response.status_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def process(self, instance):
)
instance.data["deadline"]["auth"] = None

instance.data["deadline"]["verify"] = (
not deadline_info["not_verify_ssl"])

if not deadline_info["require_authentication"]:
return
# TODO import 'get_addon_site_settings' when available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ def process_submission(self):
instance.data["toBeRenderedOn"] = "deadline"

payload = self.assemble_payload()
return self.submit(payload,
auth=instance.data["deadline"]["auth"])
auth = instance.data["deadline"]["auth"]
verify = instance.data["deadline"]["verify"]
return self.submit(payload, auth=auth, verify=verify)

def from_published_scene(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ def payload_submit(self,
self.expected_files(instance, render_path)
self.log.debug("__ expectedFiles: `{}`".format(
instance.data["expectedFiles"]))

auth = instance.data["deadline"]["auth"]
verify = instance.data["deadline"]["verify"]
response = requests_post(self.deadline_url, json=payload,
auth=instance.data["deadline"]["require_authentication"])
auth=auth,
verify=verify)

if not response.ok:
self.log.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ def process(self, instance):
# E.g. http://192.168.0.1:8082/api/jobs
url = "{}/api/jobs".format(deadline_url)
auth = instance.data["deadline"]["auth"]
response = requests_post(url, json=payload, auth=auth)
verify = instance.data["deadline"]["verify"]
response = requests_post(url, json=payload, auth=auth, verify=verify)
if not response.ok:
raise Exception(response.text)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,27 @@ def process_submission(self):

self.log.debug("Submitting 3dsMax render..")
project_settings = instance.context.data["project_settings"]
auth = instance.data["deadline"]["auth"]
verify = instance.data["deadline"]["verify"]
if instance.data.get("multiCamera"):
self.log.debug("Submitting jobs for multiple cameras..")
payload = self._use_published_name_for_multiples(
payload_data, project_settings)
job_infos, plugin_infos = payload
for job_info, plugin_info in zip(job_infos, plugin_infos):
self.submit(self.assemble_payload(job_info, plugin_info),
instance.data["deadline"]["auth"])
self.submit(
self.assemble_payload(job_info, plugin_info),
auth=auth,
verify=verify
)
else:
payload = self._use_published_name(payload_data, project_settings)
job_info, plugin_info = payload
self.submit(self.assemble_payload(job_info, plugin_info),
instance.data["deadline"]["auth"])
self.submit(
self.assemble_payload(job_info, plugin_info),
auth=auth,
verify=verify
)

def _use_published_name(self, data, project_settings):
# Not all hosts can import these modules.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def get_plugin_info(self):

return plugin_payload

def process_submission(self, auth=None):
def process_submission(self, auth=None, verify=True):
from maya import cmds
instance = self._instance

Expand Down Expand Up @@ -332,8 +332,10 @@ def process_submission(self, auth=None):
if "vrayscene" in instance.data["families"]:
self.log.debug("Submitting V-Ray scene render..")
vray_export_payload = self._get_vray_export_payload(payload_data)

export_job = self.submit(vray_export_payload,
instance.data["deadline"]["auth"])
auth=auth,
verify=verify)

payload = self._get_vray_render_payload(payload_data)

Expand All @@ -353,7 +355,8 @@ def process_submission(self, auth=None):
# Submit main render job
job_info, plugin_info = payload
self.submit(self.assemble_payload(job_info, plugin_info),
instance.data["deadline"]["auth"])
auth=auth,
verify=verify)

def _tile_render(self, payload):
"""Submit as tile render per frame with dependent assembly jobs."""
Expand Down Expand Up @@ -557,13 +560,18 @@ def _tile_render(self, payload):
# Submit assembly jobs
assembly_job_ids = []
num_assemblies = len(assembly_payloads)
auth = instance.data["deadline"]["auth"]
verify = instance.data["deadline"]["verify"]
for i, payload in enumerate(assembly_payloads):
self.log.debug(
"submitting assembly job {} of {}".format(i + 1,
num_assemblies)
)
assembly_job_id = self.submit(payload,
instance.data["deadline"]["auth"])
assembly_job_id = self.submit(
payload,
auth=auth,
verify=verify
)
assembly_job_ids.append(assembly_job_id)

instance.data["assemblySubmissionJobs"] = assembly_job_ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,12 @@ def payload_submit(
self.log.debug("__ expectedFiles: `{}`".format(
instance.data["expectedFiles"]))
auth = instance.data["deadline"]["auth"]
response = requests_post(self.deadline_url, json=payload, timeout=10,
auth=auth)
verify = instance.data["deadline"]["verify"]
response = requests_post(self.deadline_url,
json=payload,
timeout=10,
auth=auth,
verify=verify)

if not response.ok:
raise Exception(response.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def _submit_deadline_post_job(self, instance, job):

url = "{}/api/jobs".format(self.deadline_url)
auth = instance.data["deadline"]["auth"]
response = requests_post(url, json=payload, timeout=10,
auth=auth)
verify = instance.data["deadline"]["verify"]
response = requests_post(
url, json=payload, timeout=10, auth=auth, verify=verify)
if not response.ok:
raise Exception(response.text)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ def _submit_deadline_post_job(self, instance, job, instances):

url = "{}/api/jobs".format(self.deadline_url)
auth = instance.data["deadline"]["auth"]
response = requests_post(url, json=payload, timeout=10,
auth=auth)
verify = instance.data["deadline"]["verify"]
response = requests_post(
url, json=payload, timeout=10, auth=auth, verify=verify)
if not response.ok:
raise Exception(response.text)

Expand Down
2 changes: 1 addition & 1 deletion client/ayon_core/pipeline/colorspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def get_imageio_config_preset(
project_entity = None
if anatomy is None:
project_entity = ayon_api.get_project(project_name)
anatomy = Anatomy(project_name, project_entity)
anatomy = Anatomy(project_name, project_entity=project_entity)

if env is None:
env = dict(os.environ.items())
Expand Down
3 changes: 1 addition & 2 deletions client/ayon_core/tools/push_to_project/models/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ def _fill_or_create_destination_folder(self):
dst_project_name = self._item.dst_project_name
dst_folder_id = self._item.dst_folder_id
dst_task_name = self._item.dst_task_name
dst_task_name_low = dst_task_name.lower()
new_folder_name = self._item.new_folder_name
if not dst_folder_id and not new_folder_name:
self._status.set_failed(
Expand Down Expand Up @@ -765,7 +764,7 @@ def _fill_or_create_destination_folder(self):
dst_project_name, folder_ids=[folder_entity["id"]]
)
}
task_info = folder_tasks.get(dst_task_name_low)
task_info = folder_tasks.get(dst_task_name.lower())
if not task_info:
self._status.set_failed(
f"Could find task with name \"{dst_task_name}\""
Expand Down
2 changes: 1 addition & 1 deletion server_addon/deadline/package.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "deadline"
title = "Deadline"
version = "0.1.11"
version = "0.1.12"
9 changes: 4 additions & 5 deletions server_addon/deadline/server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ class ServerItemSubmodel(BaseSettingsModel):
name: str = SettingsField(title="Name")
value: str = SettingsField(title="Url")
require_authentication: bool = SettingsField(
False,
title="Require authentication")
ssl: bool = SettingsField(False,
title="SSL")
False, title="Require authentication")
not_verify_ssl: bool = SettingsField(
False, title="Don't verify SSL")


class DeadlineSettings(BaseSettingsModel):
Expand Down Expand Up @@ -78,7 +77,7 @@ def validate_unique_names(cls, value):
"name": "default",
"value": "http://127.0.0.1:8082",
"require_authentication": False,
"ssl": False
"not_verify_ssl": False
}
],
"deadline_server": "default",
Expand Down

0 comments on commit 1782928

Please sign in to comment.