Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadline: webservice password #200

Merged
merged 57 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3b70243
AY-745 - added Deadline credentials to Settings
kalisp Mar 19, 2024
3137d8e
AY-745 - added collector for DL user credentials
kalisp Mar 19, 2024
20d47e5
AY-745 - updated validator for DL connection
kalisp Mar 19, 2024
5ad0d4a
AY-745 - updated validator for DL pools
kalisp Mar 19, 2024
615e6ae
AY-745 - updated validator for expected files
kalisp Mar 19, 2024
28e5834
AY-745 - added authentication credentials to all calls to DL
kalisp Mar 19, 2024
0a9b88a
AY-745 - fix validation
kalisp Mar 19, 2024
56a5f42
Update client/ayon_core/modules/deadline/plugins/publish/help/validat…
kalisp Mar 19, 2024
543ffa9
Update client/ayon_core/modules/deadline/plugins/publish/collect_user…
kalisp Mar 19, 2024
6c6f123
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Mar 19, 2024
0693d80
Merge remote-tracking branch 'origin/feature/AY-745_Deadline-webservi…
kalisp Mar 19, 2024
209cad6
AY-745 - remove logging
kalisp Mar 19, 2024
7fae6d1
AY-745 - added new system wide Site settings
kalisp Mar 25, 2024
6b0568a
AY-745 - added version to client side
kalisp Mar 26, 2024
12d49cb
AY-745 - added field to carry over deadline info
kalisp Mar 26, 2024
6347e65
AY-745 - explicit cast to tuple
kalisp Mar 26, 2024
5c9fc4a
AY-745 - changed structure
kalisp Mar 26, 2024
68be4d7
AY-745 - changed aproach to get DL to use
kalisp Mar 26, 2024
eca34a9
AY-745 - update to Harmony collector
kalisp Mar 26, 2024
abfcd8b
AY-745 - explicit carry over of DL meta for AbstractCollectRender
kalisp Mar 26, 2024
50ade43
AY-745 - add user credentials to instance
kalisp Mar 26, 2024
7cf416d
AY-745 - refactored class variable
kalisp Mar 26, 2024
6faa5ac
AY-745 - refactored format of credentials
kalisp Mar 26, 2024
2ed1d0f
AY-745 - refactored format of credentials
kalisp Mar 26, 2024
2dac53a
AY-745 - added protection for older DL
kalisp Mar 26, 2024
e604c28
AY-745 - added version for client side
kalisp Mar 26, 2024
569d119
AY-745 - add local filtering
kalisp Mar 26, 2024
b4d5c02
AY-745 - fix retrieval of deadline url
kalisp Mar 26, 2024
1023497
AY-745 - merge develop
kalisp Mar 26, 2024
77c939b
AY-745 - remove unnecessary comment
kalisp Mar 26, 2024
466f940
AY-745 - added todo
kalisp Mar 26, 2024
6bbb956
AY-745 - renamed class
kalisp Mar 26, 2024
2dc3eec
AY-745 - renamed class
kalisp Mar 26, 2024
bef6855
AY-745 - fix passing DL credentials to metadata file
kalisp Mar 26, 2024
ab74098
AY-745 - provide default values for new Settings field
kalisp Apr 3, 2024
50127b9
Refactor name to denote multiple servers
kalisp Apr 4, 2024
766cbd9
Refactor change docstring
kalisp Apr 4, 2024
c4c56f8
AY-747- refactor name of variable
kalisp Apr 5, 2024
26a11a5
AY-747- refactor query default
kalisp Apr 5, 2024
cba1dae
Update client/ayon_core/modules/deadline/plugins/publish/help/validat…
kalisp Apr 5, 2024
4332c50
AY-747- refactor passing of auth
kalisp Apr 5, 2024
5b2a545
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Apr 5, 2024
f5e24b6
AY-747- update todo
kalisp Apr 5, 2024
70fe7ef
Merge remote-tracking branch 'origin/feature/AY-745_Deadline-webservi…
kalisp Apr 5, 2024
497ce6d
Update client/ayon_core/modules/deadline/plugins/publish/submit_celac…
kalisp Apr 16, 2024
f43fbc2
Use collected host name
kalisp Apr 16, 2024
48a1dc8
Add todo
kalisp Apr 16, 2024
ff2296d
Removed unneeded import
kalisp Apr 16, 2024
4bc5395
Refactor - updated names for default deadline url
kalisp Apr 18, 2024
1525443
Merge branch 'develop' of https://github.com/ynput/ayon-core into fea…
kalisp Apr 18, 2024
e8c48ce
Merge remote-tracking branch 'origin/feature/AY-745_Deadline-webservi…
kalisp Apr 18, 2024
090304a
Refactor - move deadline plugins later
kalisp Apr 18, 2024
fbc0ee6
Fix - get source_instance directly from instance
kalisp Apr 18, 2024
12f56ee
Merge develop
kalisp Apr 30, 2024
5fed3d7
AY-745 - added missed blender for credential collection
kalisp May 3, 2024
22d1837
AY-745 - fixe for cache submissions
kalisp May 3, 2024
004a4fe
Fix order of collect render
kalisp May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions client/ayon_core/modules/deadline/abstract_submit_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,9 @@ def process(self, instance):
self.plugin_info = self.get_plugin_info()
self.aux_files = self.get_aux_files()

job_id = self.process_submission()
auth = context.data.get("deadline_auth")
self.log.info(f"auth::{auth}")
kalisp marked this conversation as resolved.
Show resolved Hide resolved
job_id = self.process_submission(auth)
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 @@ -473,10 +475,10 @@ def process(self, instance):
job_info=render_job_info,
plugin_info=render_plugin_info
)
render_job_id = self.submit(payload)
render_job_id = self.submit(payload, auth)
self.log.info("Render job id: %s", render_job_id)

def process_submission(self):
def process_submission(self, auth=None):
"""Process data for submission.

This takes Deadline JobInfo, PluginInfo, AuxFile, creates payload
Expand All @@ -487,7 +489,7 @@ def process_submission(self):

"""
payload = self.assemble_payload()
return self.submit(payload)
return self.submit(payload, auth)

@abstractmethod
def get_job_info(self):
Expand Down Expand Up @@ -577,14 +579,15 @@ def assemble_payload(
"AuxFiles": aux_files or self.aux_files
}

def submit(self, payload):
def submit(self, payload, auth):
"""Submit payload to Deadline API end-point.

This takes payload in the form of JSON file and POST it to
Deadline jobs end-point.

Args:
payload (dict): dict to become json in deadline submission.
auth (tuple): (username, password)

Returns:
str: resulting Deadline job id.
Expand All @@ -594,7 +597,11 @@ def submit(self, payload):

"""
url = "{}/api/jobs".format(self._deadline_url)
response = requests_post(url, json=payload)
kwargs = {}
if auth:
kwargs["auth"] = auth
kalisp marked this conversation as resolved.
Show resolved Hide resolved
response = requests_post(url, json=payload,
**kwargs)
if not response.ok:
self.log.error("Submission failed!")
self.log.error(response.status_code)
Expand Down
7 changes: 5 additions & 2 deletions client/ayon_core/modules/deadline/deadline_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_plugin_paths(self):
}

@staticmethod
def get_deadline_pools(webservice, log=None):
def get_deadline_pools(webservice, auth=None, log=None):
# type: (str) -> list
kalisp marked this conversation as resolved.
Show resolved Hide resolved
"""Get pools from Deadline.
Args:
Expand All @@ -64,7 +64,10 @@ def get_deadline_pools(webservice, log=None):

argument = "{}/api/pools?NamesOnly=true".format(webservice)
try:
response = requests_get(argument)
kwargs = {}
if auth:
kwargs["auth"] = auth
response = requests_get(argument, **kwargs)
except requests.exceptions.ConnectionError as exc:
msg = 'Cannot connect to DL web service {}'.format(webservice)
log.error(msg)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""Collect user credentials

Requires:
context -> project_settings

Provides:
context -> deadline_require_authentication (bool)
context -> deadline_auth (tuple (str, str)) - (username, password) or None
"""
import pyblish.api


class CollectUserCredentials(pyblish.api.ContextPlugin):
kalisp marked this conversation as resolved.
Show resolved Hide resolved
"""Collects user name and password for artist if DL requires authentication
"""

# Run before collect_deadline_server_instance.
kalisp marked this conversation as resolved.
Show resolved Hide resolved
order = pyblish.api.CollectorOrder
label = "Collect Deadline User Credentials"

def process(self, context):
deadline_settings = context.data["project_settings"]["deadline"]

context.data["deadline_require_authentication"] = (
deadline_settings)["require_authentication"]
context.data["deadline_auth"] = None

if not context.data["deadline_require_authentication"]:
return

kalisp marked this conversation as resolved.
Show resolved Hide resolved
local_settings = deadline_settings["local_settings"]
context.data["deadline_auth"] = (local_settings["username"],
local_settings["password"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Deadline Authentication</title>
<description>
## Deadline authenticatin is required
kalisp marked this conversation as resolved.
Show resolved Hide resolved

This project has set in Settings that Deadline requires authentication.

### How to repair?

Please go to Ayon Server Site settings and provide your Deadline username and
most likely password too. (Deadline could run in configuration that empty passwords are allowed. Ask your administrator for details.)
kalisp marked this conversation as resolved.
Show resolved Hide resolved

</description>
</error>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import re
import json
import getpass
import requests
import pyblish.api

from openpype_modules.deadline.abstract_submit_deadline import requests_post


class CelactionSubmitDeadline(pyblish.api.InstancePlugin):
"""Submit CelAction2D scene to Deadline
Expand Down Expand Up @@ -193,7 +194,10 @@ def payload_submit(self,
self.log.debug("__ expectedFiles: `{}`".format(
instance.data["expectedFiles"]))

response = requests.post(self.deadline_url, json=payload)
kwargs = {}
if instance.context.data["deadline_auth"]:
kwargs["auth"] = instance.context.data["deadline_auth"]
kalisp marked this conversation as resolved.
Show resolved Hide resolved
response = requests_post(self.deadline_url, json=payload, **kwargs)

if not response.ok:
self.log.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import json
import getpass

import requests

import pyblish.api

from openpype_modules.deadline.abstract_submit_deadline import requests_post
from ayon_core.pipeline.publish import (
AYONPyblishPluginMixin
)
Expand Down Expand Up @@ -251,7 +250,10 @@ def process(self, instance):

# E.g. http://192.168.0.1:8082/api/jobs
url = "{}/api/jobs".format(deadline_url)
response = requests.post(url, json=payload)
kwargs = {}
if instance.context.data["deadline_auth"]:
kwargs["auth"] = instance.context.data["deadline_auth"]
response = requests_post(url, json=payload, **kwargs)
if not response.ok:
raise Exception(response.text)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def get_plugin_info(self):

return plugin_payload

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

Expand Down Expand Up @@ -330,7 +330,8 @@ def process_submission(self):
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)
export_job = self.submit(vray_export_payload,
instance.context.data["deadline_auth"])

payload = self._get_vray_render_payload(payload_data)

Expand All @@ -349,7 +350,8 @@ def process_submission(self):
else:
# Submit main render job
job_info, plugin_info = payload
self.submit(self.assemble_payload(job_info, plugin_info))
self.submit(self.assemble_payload(job_info, plugin_info),
instance.context.data["deadline_auth"])

def _tile_render(self, payload):
"""Submit as tile render per frame with dependent assembly jobs."""
Expand Down Expand Up @@ -449,7 +451,8 @@ def _tile_render(self, payload):
# Submit frame tile jobs
frame_tile_job_id = {}
for frame, tile_job_payload in frame_payloads.items():
job_id = self.submit(tile_job_payload)
job_id = self.submit(tile_job_payload,
instance.context.data["deadline_auth"])
frame_tile_job_id[frame] = job_id

# Define assembly payloads
Expand Down Expand Up @@ -557,7 +560,8 @@ def _tile_render(self, payload):
"submitting assembly job {} of {}".format(i + 1,
num_assemblies)
)
assembly_job_id = self.submit(payload)
assembly_job_id = self.submit(payload,
instance.context.data["deadline_auth"])
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 @@ -4,9 +4,9 @@
import getpass
from datetime import datetime

import requests
import pyblish.api

from openpype_modules.deadline.abstract_submit_deadline import requests_post
from ayon_core.pipeline.publish import (
AYONPyblishPluginMixin
)
Expand Down Expand Up @@ -434,7 +434,11 @@ def payload_submit(

self.log.debug("__ expectedFiles: `{}`".format(
instance.data["expectedFiles"]))
response = requests.post(self.deadline_url, json=payload, timeout=10)
kwargs = {}
if instance.context.data["deadline_auth"]:
kwargs["auth"] = instance.context.data["deadline_auth"]
response = requests_post(self.deadline_url, json=payload, timeout=10,
**kwargs)

if not response.ok:
raise Exception(response.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import re
from copy import deepcopy

import requests
import ayon_api
import pyblish.api

from openpype_modules.deadline.abstract_submit_deadline import requests_post
from ayon_core.pipeline import publish
from ayon_core.lib import EnumDef, is_in_tests
from ayon_core.pipeline.version_start import get_versioning_start
Expand Down Expand Up @@ -209,7 +209,11 @@ def _submit_deadline_post_job(self, instance, job):
self.log.debug("Submitting Deadline publish job ...")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import re
from copy import deepcopy

import requests
import clique
import ayon_api
import pyblish.api

from openpype_modules.deadline.abstract_submit_deadline import requests_post
from ayon_core.pipeline import publish
from ayon_core.lib import EnumDef, is_in_tests
from ayon_core.pipeline.version_start import get_versioning_start
Expand Down Expand Up @@ -303,7 +303,11 @@ def _submit_deadline_post_job(self, instance, job, instances):
self.log.debug("Submitting Deadline publish job ...")

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pyblish.api

from ayon_core.pipeline import PublishXmlValidationError

from openpype_modules.deadline.abstract_submit_deadline import requests_get


Expand All @@ -15,8 +17,9 @@ class ValidateDeadlineConnection(pyblish.api.InstancePlugin):
responses = {}

def process(self, instance):
context = instance.context
# get default deadline webservice url from deadline module
deadline_url = instance.context.data["defaultDeadline"]
deadline_url = context.data["defaultDeadline"]
# if custom one is set in instance, use that
if instance.data.get("deadlineUrl"):
deadline_url = instance.data.get("deadlineUrl")
Expand All @@ -25,10 +28,27 @@ def process(self, instance):
)
assert deadline_url, "Requires Deadline Webservice URL"

kwargs = {}
if context.data["deadline_require_authentication"]:
kwargs["auth"] = context.data["deadline_auth"]

if not context.data["deadline_auth"][0]:
raise PublishXmlValidationError(
self,
"Deadline requires authentication. "
"At least username is required to be set in "
"Site Settings.")

if deadline_url not in self.responses:
self.responses[deadline_url] = requests_get(deadline_url)
self.responses[deadline_url] = requests_get(deadline_url, **kwargs)

response = self.responses[deadline_url]
if response.status_code == 401:
raise PublishXmlValidationError(
self,
"Deadline requires authentication. "
"Provided credentials are not working. "
"Please change them in Site Settings")
assert response.ok, "Response must be ok"
assert response.text.startswith("Deadline Web Service "), (
"Web service did not respond with 'Deadline Web Service'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def process(self, instance):
return

deadline_url = self.get_deadline_url(instance)
pools = self.get_pools(deadline_url)
pools = self.get_pools(deadline_url,
instance.context.data["deadline_auth"])

invalid_pools = {}
primary_pool = instance.data.get("primaryPool")
Expand Down Expand Up @@ -69,13 +70,14 @@ def get_deadline_url(self, instance):
deadline_url = instance.data.get("deadlineUrl")
return deadline_url

def get_pools(self, deadline_url):
def get_pools(self, deadline_url, auth):
if deadline_url not in self.pools_per_url:
self.log.debug(
"Querying available pools for Deadline url: {}".format(
deadline_url)
)
pools = DeadlineModule.get_deadline_pools(deadline_url,
auth=auth,
log=self.log)
self.log.info("Available pools: {}".format(pools))
self.pools_per_url[deadline_url] = pools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ def _get_job_info(self, instance, job_id):

url = "{}/api/jobs?JobID={}".format(deadline_url, job_id)
try:
response = requests_get(url)
kwargs = {}
if instance.context.data["deadline_auth"]:
kwargs["auth"] = instance.context.data["deadline_auth"]
response = requests_get(url, **kwargs)
except requests.exceptions.ConnectionError:
self.log.error("Deadline is not accessible at "
"{}".format(deadline_url))
Expand Down
Loading
Loading