Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Deadline: Simplify GlobalJobPreLoad logic #2605

Merged
merged 9 commits into from
Feb 18, 2022
37 changes: 0 additions & 37 deletions vendor/deadline/custom/events/OpenPype/OpenPype.param

This file was deleted.

191 changes: 0 additions & 191 deletions vendor/deadline/custom/events/OpenPype/OpenPype.py

This file was deleted.

11 changes: 7 additions & 4 deletions vendor/deadline/custom/plugins/GlobalJobPreLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@
from Deadline.Scripting import RepositoryUtils, FileUtils


def get_openpype_executable():
"""Return OpenPype Executable from Event Plug-in Settings"""
config = RepositoryUtils.GetPluginConfig("OpenPype")
return config.GetConfigEntryWithDefault("OpenPypeExecutable", "")


def inject_openpype_environment(deadlinePlugin):
""" Pull env vars from OpenPype and push them to rendering process.

Used for correct paths, configuration from OpenPype etc.
"""
job = deadlinePlugin.GetJob()
job = RepositoryUtils.GetJob(job.JobId, True) # invalidates cache

print(">>> Injecting OpenPype environments ...")
try:
print(">>> Getting OpenPype executable ...")
exe_list = job.GetJobExtraInfoKeyValue("openpype_executables")
exe_list = get_openpype_executable()
openpype_app = FileUtils.SearchFileList(exe_list)
if openpype_app == "":
raise RuntimeError(
Expand Down Expand Up @@ -96,7 +101,6 @@ def inject_render_job_id(deadlinePlugin):
"""Inject dependency ids to publish process as env var for validation."""
print(">>> Injecting render job id ...")
job = deadlinePlugin.GetJob()
job = RepositoryUtils.GetJob(job.JobId, True) # invalidates cache

dependency_ids = job.JobDependencyIDs
print(">>> Dependency IDs: {}".format(dependency_ids))
Expand Down Expand Up @@ -183,7 +187,6 @@ def __main__(deadlinePlugin):
print("*** GlobalJobPreload start ...")
print(">>> Getting job ...")
job = deadlinePlugin.GetJob()
job = RepositoryUtils.GetJob(job.JobId, True) # invalidates cache

openpype_render_job = \
job.GetJobEnvironmentKeyValue('OPENPYPE_RENDER_JOB') or '0'
Expand Down
39 changes: 18 additions & 21 deletions vendor/deadline/readme.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
## OpenPype Deadline repository overlay

This directory is overlay for Deadline repository.
It means that you can copy whole hierarchy to Deadline repository and it should work.
This directory is an overlay for Deadline repository.
It means that you can copy the whole hierarchy to Deadline repository and it
should work.

Logic:
-----
Event
-----
For each rendering job OpenPype event is triggered, it stores path to OpenPype
executable (needs to be configured on `Deadline's Configure Events > OpenPype`)
job's extra key 'openpype_executables'.

This value is used by `GlobalJobPreLoad` to call that executable to pull
environment's variables which are needed to add to ALL plugins process environments.
These env. vars are injected into rendering process.

Event is necessary here as a middle man to allow configuring location of executable
which is ONLY then used by `GlobalJobPreLoad` (which doesnt have any user facing
configuration at all).
GlobalJobPreLoad
-----

`GlobalJobPreLoad` is triggered before each job, it contains backward compatible
logic to not modify old Pype2 or not OpenPype triggered jobs.
The `GlobalJobPreLoad` will retrieve the OpenPype executable path from the
`OpenPype` Deadline Plug-in's settings. Then it will call the executable to
retrieve the environment variables needed for the Deadline Job.
These environment variables are injected into rendering process.

Deadline triggers the `GlobalJobPreLoad.py` for each Worker as it starts the
Job.

*Note*: It also contains backward compatible logic to preserve functionality
for old Pype2 and non-OpenPype triggered jobs.

Plugin
------
For each publishing job `OpenPypeDeadlinePlugin` is called, which calls
configured location of OpenPype executable (needs to be configured in
`Deadline's Configure Plugins > OpenPype`)
and triggers command.
For each render and publishing job the `OpenPype` Deadline Plug-in is checked
for the configured location of the OpenPype executable (needs to be configured
in `Deadline's Configure Plugins > OpenPype`) through `GlobalJobPreLoad`.


Binary file removed website/docs/assets/deadline_configure_event.png
Binary file not shown.
36 changes: 15 additions & 21 deletions website/docs/module_deadline.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,39 @@ import TabItem from '@theme/TabItem';

For [AWS Thinkbox Deadline](https://www.awsthinkbox.com/deadline) support you need to set a few things up in both OpenPype and Deadline itself

1. Deploy OpenPype executable to all nodes of Deadline farm. See [Install & Run](admin_use)
1. Deploy OpenPype executable to all nodes of Deadline farm. See [Install & Run](admin_use).

2. Enable Deadline module it in the [settings](admin_settings_system.md#deadline)
2. Enable Deadline Module in the [OpenPype Admin Settings](admin_settings_system.md#deadline).

3. Set up *Deadline Web API service*. For more details on how to do it, see [here](https://docs.thinkboxsoftware.com/products/deadline/10.0/1_User%20Manual/manual/web-service.html).

4. Point OpenPype to your deadline webservice URL in the [settings](admin_settings_system.md#deadline)
4. Point OpenPype to your deadline webservice URL in the [OpenPype Admin Settings](admin_settings_system.md#deadline).

5. Install our custom plugin, event plugin and scripts to your deadline repository. It should be as simple as copying content of `openPype/vendor/deadline/custom` to `path/to/your/deadline/repository/custom`
5. Install our custom plugin and scripts to your deadline repository. It should be as simple as copying content of `openPype/vendor/deadline/custom` to `path/to/your/deadline/repository/custom`.


## Configuration

OpenPype integration with Deadline consists of two parts, event listener which gets triggered for each job and
handles populating rendering jobs with proper environment variables and
OpenPype plugin which handles publishing itself.
OpenPype integration for Deadline consists of two parts:

Both need to be configured by pointing DL to OpenPype executables. These executables need to be installed to
- The `OpenPype` Deadline Plug-in
- A `GlobalJobPreLoad` Deadline Script (this gets triggered for each deadline job)

The `GlobalJobPreLoad` handles populating render and publish jobs with proper environment variables using settings from the `OpenPype` Deadline Plug-in.

The `OpenPype` Deadline Plug-in must be configured to point to a valid OpenPype executable location. The executable need to be installed to
destinations accessible by DL process. Check permissions (must be executable and accessible by Deadline process)

- Enable `Tools > Super User Mode` in Deadline Monitor

- Go to `Tools > Configure plugins`, find `OpenPype` in the list on the left side, find location of OpenPype
- Go to `Tools > Configure Plugins...`, find `OpenPype` in the list on the left side, find location of OpenPype
executable. It is recommended to use the `openpype_console` executable as it provides a bit more logging.

- In case of multi OS farms, provide multiple locations, each node goes through a list and tries to find accessible
locations for itself.
- In case of multi OS farms, provide multiple locations, each Deadline Worker goes through the list and tries to find the first accessible
location for itself.

![Configure plugin](assets/deadline_configure_plugin.png)

- Go to `Tools > Configure events`, find `OpenPype` in the list on the left side, find location of OpenPype
executable. It is recommended to use the `openpype_console` executable as it provides a bit more logging.

- State is expected to be set to `Global Enabled`

![Configure event](assets/deadline_configure_event.png)

Path to executables needs to be configured on both, plugin and event level!

## Troubleshooting

#### Publishing jobs fail directly in DCCs
Expand All @@ -67,7 +61,7 @@ Each publishing from OpenPype consists of 2 jobs, first one is rendering, second

- Jobs are failing with `OpenPype executable was not found` error

Check if OpenPype is installed on a node handling this job, plugin and events are properly [configured](#configuration)
Check if OpenPype is installed on the Worker handling this job and ensure `OpenPype` Deadline Plug-in is properly [configured](#configuration)


- Publishing job is failing with `ffmpeg not installed` error
Expand Down