convert deadline from ENV var to settings

This commit is contained in:
Milan Kolar 2020-12-04 15:40:26 +01:00
parent 3e60512150
commit 852823dcf9
14 changed files with 88 additions and 51 deletions

View file

@ -373,8 +373,12 @@ class AbstractSubmitDeadline(pyblish.api.InstancePlugin):
"""Plugin entry point."""
self._instance = instance
context = instance.context
self._deadline_url = os.environ.get(
"DEADLINE_REST_URL", "http://localhost:8082")
self._deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
assert self._deadline_url, "Requires DEADLINE_REST_URL"
file_path = None

View file

@ -11,7 +11,7 @@ class ExtractCelactionDeadline(pyblish.api.InstancePlugin):
"""Submit CelAction2D scene to Deadline
Renders are submitted to a Deadline Web Service as
supplied via the environment variable DEADLINE_REST_URL
supplied via settings key "DEADLINE_REST_URL".
"""
@ -37,10 +37,15 @@ class ExtractCelactionDeadline(pyblish.api.InstancePlugin):
instance.data["toBeRenderedOn"] = "deadline"
context = instance.context
DEADLINE_REST_URL = os.environ.get("DEADLINE_REST_URL")
assert DEADLINE_REST_URL, "Requires DEADLINE_REST_URL"
deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
assert deadline_url, "Requires DEADLINE_REST_URL"
self.deadline_url = "{}/api/jobs".format(DEADLINE_REST_URL)
self.deadline_url = "{}/api/jobs".format(deadline_url)
self._comment = context.data.get("comment", "")
self._deadline_user = context.data.get(
"deadlineUser", getpass.getuser())

View file

@ -12,7 +12,7 @@ class FusionSubmitDeadline(pyblish.api.InstancePlugin):
"""Submit current Comp to Deadline
Renders are submitted to a Deadline Web Service as
supplied via the environment variable DEADLINE_REST_URL
supplied via settings key "DEADLINE_REST_URL".
"""
@ -32,9 +32,13 @@ class FusionSubmitDeadline(pyblish.api.InstancePlugin):
from avalon.fusion.lib import get_frame_path
DEADLINE_REST_URL = api.Session.get("DEADLINE_REST_URL",
"http://localhost:8082")
assert DEADLINE_REST_URL, "Requires DEADLINE_REST_URL"
deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
assert deadline_url, "Requires DEADLINE_REST_URL"
# Collect all saver instances in context that are to be rendered
saver_instances = []

View file

@ -0,0 +1,13 @@
from pyblish import api
from pype.api import get_current_project_settings, get_system_settings
class CollectSettings(api.ContextPlugin):
"""Collect Settings and store in the context."""
order = api.CollectorOrder - 0.491
label = "Collect Settings"
def process(self, context):
context.data["project_settings"] = get_current_project_settings()
context.data["system_settings"] = get_system_settings()

View file

@ -305,7 +305,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
self.log.info("Submitting Deadline job ...")
url = "{}/api/jobs".format(self.DEADLINE_REST_URL)
url = "{}/api/jobs".format(self.deadline_url)
response = requests.post(url, json=payload, timeout=10)
if not response.ok:
raise Exception(response.text)
@ -924,10 +924,13 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
}
if submission_type == "deadline":
self.DEADLINE_REST_URL = os.environ.get(
"DEADLINE_REST_URL", "http://localhost:8082"
self.deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
assert self.DEADLINE_REST_URL, "Requires DEADLINE_REST_URL"
assert self.deadline_url, "Requires DEADLINE_REST_URL"
self._submit_deadline_post_job(instance, render_job, instances)

View file

@ -9,6 +9,7 @@ from maya import cmds
import maya.app.renderSetup.model.renderSetup as renderSetup
from pype.hosts.maya import lib
from pype.api import get_system_settings
import avalon.maya
@ -124,8 +125,11 @@ class CreateRender(avalon.maya.Creator):
# get pools
pools = []
deadline_url = os.environ.get("DEADLINE_REST_URL", None)
muster_url = os.environ.get("MUSTER_REST_URL", None)
system_settings = get_system_settings()["modules"]
deadline_url = system_settings["deadline"]["DEADLINE_REST_URL"]
muster_url = system_settings["muster"]["MUSTER_REST_URL"]
if deadline_url and muster_url:
self.log.error(
"Both Deadline and Muster are enabled. " "Cannot support both."

View file

@ -238,11 +238,7 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin):
"""Submit available render layers to Deadline.
Renders are submitted to a Deadline Web Service as
supplied via the environment variable ``DEADLINE_REST_URL``.
Note:
If Deadline configuration is not detected, this plugin will
be disabled.
supplied via settings key "DEADLINE_REST_URL".
Attributes:
use_published (bool): Use published scene to render instead of the
@ -254,11 +250,6 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin):
order = pyblish.api.IntegratorOrder + 0.1
hosts = ["maya"]
families = ["renderlayer"]
if not os.environ.get("DEADLINE_REST_URL"):
optional = False
active = False
else:
optional = True
use_published = True
tile_assembler_plugin = "PypeTileAssembler"
@ -267,9 +258,16 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin):
def process(self, instance):
"""Plugin entry point."""
instance.data["toBeRenderedOn"] = "deadline"
context = instance.context
self._instance = instance
self._deadline_url = os.environ.get(
"DEADLINE_REST_URL", "http://localhost:8082")
self._deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
assert self._deadline_url, "Requires DEADLINE_REST_URL"
context = instance.context

View file

@ -12,8 +12,6 @@ class ValidateDeadlineConnection(pyblish.api.ContextPlugin):
order = pyblish.api.ValidatorOrder
hosts = ["maya"]
families = ["renderlayer"]
if not os.environ.get("DEADLINE_REST_URL"):
active = False
def process(self, context):
@ -21,14 +19,15 @@ class ValidateDeadlineConnection(pyblish.api.ContextPlugin):
if not contextplugin_should_run(self, context):
return
try:
DEADLINE_REST_URL = os.environ["DEADLINE_REST_URL"]
except KeyError:
self.log.error("Deadline REST API url not found.")
raise ValueError("Deadline REST API url not found.")
deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
# Check response
response = self._requests_get(DEADLINE_REST_URL)
response = self._requests_get(deadline_url)
assert response.ok, "Response must be ok"
assert response.text.startswith("Deadline Web Service "), (
"Web service did not respond with 'Deadline Web Service'"

View file

@ -12,7 +12,7 @@ class NukeSubmitDeadline(pyblish.api.InstancePlugin):
"""Submit write to Deadline
Renders are submitted to a Deadline Web Service as
supplied via the environment variable DEADLINE_REST_URL
supplied via settings key "DEADLINE_REST_URL".
"""
@ -34,11 +34,15 @@ class NukeSubmitDeadline(pyblish.api.InstancePlugin):
node = instance[0]
context = instance.context
DEADLINE_REST_URL = os.environ.get("DEADLINE_REST_URL",
"http://localhost:8082")
assert DEADLINE_REST_URL, "Requires DEADLINE_REST_URL"
deadline_url = (
context.data["system_settings"]
["modules"]
["deadline"]
["DEADLINE_REST_URL"]
)
assert deadline_url, "Requires DEADLINE_REST_URL"
self.deadline_url = "{}/api/jobs".format(DEADLINE_REST_URL)
self.deadline_url = "{}/api/jobs".format(deadline_url)
self._comment = context.data.get("comment", "")
self._ver = re.search(r"\d+\.\d+", context.data.get("hostVersion"))
self._deadline_user = context.data.get(

View file

@ -109,7 +109,7 @@
},
"publish": {
"CollectMayaRender": {
"sync_workfile_version": true
"sync_workfile_version": false
},
"ValidateCameraAttributes": {
"enabled": true,
@ -134,6 +134,9 @@
"ValidateMeshHasOverlappingUVs": {
"enabled": false
},
"ValidateAttributes": {
"enabled": false
},
"ExtractCameraAlembic": {
"enabled": true,
"optional": true,
@ -316,4 +319,4 @@
"ValidateNoAnimation": false
}
}
}
}

View file

@ -123,4 +123,4 @@
"help": "Script exported from matchmoving application"
}
}
}
}

View file

@ -169,11 +169,11 @@
"enabled": false,
"workspace_name": "studio name"
},
"Deadline": {
"deadline": {
"enabled": true,
"DEADLINE_REST_URL": "http://localhost:8082"
},
"Muster": {
"muster": {
"enabled": false,
"MUSTER_REST_URL": "http://127.0.0.1:9890",
"templates_mapping": {

View file

@ -344,12 +344,12 @@
"label": "Deadline Group"
},
{
"type": "text",
"type": "number",
"key": "deadline_chunk_size",
"label": "Deadline Chunk Size"
},
{
"type": "text",
"type": "number",
"key": "deadline_priority",
"label": "Deadline Priotity"
},

View file

@ -100,7 +100,7 @@
]
}, {
"type": "dict",
"key": "Deadline",
"key": "deadline",
"label": "Deadline",
"collapsable": true,
"checkbox_key": "enabled",
@ -115,7 +115,7 @@
}]
}, {
"type": "dict",
"key": "Muster",
"key": "muster",
"label": "Muster",
"collapsable": true,
"checkbox_key": "enabled",
@ -126,7 +126,7 @@
}, {
"type": "text",
"key": "MUSTER_REST_URL",
"label": "Muster Resl URL"
"label": "Muster Rest URL"
}, {
"type": "dict-modifiable",
"object_type": {