Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/support_de…
Browse files Browse the repository at this point in the history
…adline_in_unreal
  • Loading branch information
kalisp committed Jul 23, 2024
2 parents 42be0b7 + dbc1298 commit f747671
Show file tree
Hide file tree
Showing 27 changed files with 47 additions and 64 deletions.
52 changes: 2 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,2 @@
# Addon template
This is a boilerplate git repository for creating new ayon addons.

## Folder structure
All addons must have server code which is located in `server` subfolder. Server side addon definition is entrypoint for each addon. Can define settings, frontend, custom endpoints, etc. Root by default contains `create_package.py` which is a helper script that prepares package structure for server. The script may be modified or expanded by needs of addon (e.g. when frontend needs to be build first). File with `version.py` is kept at the root and is copied to server and client code with script -> The reason is to make sure both parts contain same version.

### Server content
Default base of server addon is `__init__.py` file in root of repository which define addon for server. Most of addons have settings that's why `settings.py` is by default in the structure. Settings can be changed to folder/module when more than one file is needed.

### Server frontend
Addons may have their frontend. By default, server looks into `/frontend/dist` for `index.html` and addon have to have specified scopes where the frontend should be showed (check documentation of `frontend_scopes` on server addon implementation for more information).

### Private server files
Root of addon may contain subfolder `private` where can be added files that are accessible via ayon server. Url schema is `{server url}/addons/{addon name}/{addon_version}/private/*`. By default it is place where client zip file is created (during package creation). The endpoint requires authorized user.

### Public server files
Public files works the same as private files but does not require authorized user. Subfolder name is `public`. Url schema is `{server url}/addons/{addon name}/{addon_version}/public/*`. Endpoint is helpful for images/icons or other static content.

### Client content
Addons that have code for desktop client application should create subfolder `client` where a client content is located. It is expected the directory has only one file or folder in it which is named the way how should be imported on a client side (e.g. `ayon_core`).


### Example strucutre
```
├─ server
│ ├─ __init__.py
│ └─ settings.py
├─ frontend
│ └─ dist
│ └─ index.html
├─ public
│ └─ my_icon.png
├─ private
│ └─ kittens.png
├─ client
│ ├─ ayon_core
│ │ ├─ pipeline
│ │ ├─ lib
│ │ └─ ...
│ └─ pyproject.toml
├─ create_package.py
├─ LICENSE
├─ package.py
└─ README.md
```
# Deadline addon
Deadline integration for AYON.
19 changes: 15 additions & 4 deletions client/ayon_deadline/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from .version import __version__


DEADLINE_ADDON_ROOT = os.path.dirname(os.path.abspath(__file__))


class DeadlineWebserviceError(Exception):
"""
Exception to throw when connection to Deadline server fails.
Expand Down Expand Up @@ -37,10 +40,18 @@ def initialize(self, studio_settings):

def get_plugin_paths(self):
"""Deadline plugin paths."""
current_dir = os.path.dirname(os.path.abspath(__file__))
return {
"publish": [os.path.join(current_dir, "plugins", "publish")]
}
# Note: We are not returning `publish` key because we have overridden
# `get_publish_plugin_paths` to return paths host-specific. However,
# `get_plugin_paths` still needs to be implemented because it's
# abstract on the parent class
return {}

def get_publish_plugin_paths(self, host_name=None):
publish_dir = os.path.join(DEADLINE_ADDON_ROOT, "plugins", "publish")
paths = [os.path.join(publish_dir, "global")]
if host_name:
paths.append(os.path.join(publish_dir, host_name))
return paths

@staticmethod
def get_deadline_pools(webservice, auth=None, log=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AfterEffectsSubmitDeadline(
families = ["render.farm"] # cannot be "render' as that is integrated
use_published = True
targets = ["local"]
settings_category = "deadline"

priority = 50
chunk_size = 1000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ValidateExpectedFiles(pyblish.api.InstancePlugin):
order = pyblish.api.ValidatorOrder
families = ["render"]
targets = ["deadline"]
settings_category = "deadline"

# check if actual frame range on render job wasn't different
# case when artists wants to render only subset of frames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ def get_job_info(self):
"FTRACK_API_USER",
"FTRACK_SERVER",
"OPENPYPE_SG_USER",
"AYON_BUNDLE_NAME",
"AYON_DEFAULT_SETTINGS_VARIANT",
"AYON_PROJECT_NAME",
"AYON_FOLDER_PATH",
"AYON_TASK_NAME",
"AYON_WORKDIR",
"AYON_APP_NAME",
"AYON_LOG_NO_COLORS",
"AYON_IN_TESTS"
]

environment = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,19 @@ def get_job_info(self, dependency_job_ids=None):
job_info.ChunkSize = attribute_values.get(
"export_chunk", self.export_chunk_size
)
job_info.Group = self.export_group
job_info.Group = attribute_values.get(
"export_group", self.export_group
)
else:
job_info.Priority = attribute_values.get(
"priority", self.priority
)
job_info.ChunkSize = attribute_values.get(
"chunk", self.chunk_size
)
job_info.Group = self.group
job_info.Group = attribute_values.get(
"group", self.group
)

# Apply render globals, like e.g. data from collect machine list
render_globals = instance.data.get("renderGlobals", {})
Expand All @@ -248,12 +252,15 @@ def get_job_info(self, dependency_job_ids=None):
"FTRACK_API_USER",
"FTRACK_SERVER",
"OPENPYPE_SG_USER",
"AYON_BUNDLE_NAME",
"AYON_DEFAULT_SETTINGS_VARIANT",
"AYON_PROJECT_NAME",
"AYON_FOLDER_PATH",
"AYON_TASK_NAME",
"AYON_WORKDIR",
"AYON_APP_NAME",
"AYON_LOG_NO_COLORS",
"AYON_IN_TESTS"
]

environment = {
Expand Down Expand Up @@ -396,8 +403,10 @@ def _get_husk_standalone_plugin_info(self, instance, hou_major_minor):


class HoudiniSubmitDeadlineUsdRender(HoudiniSubmitDeadline):
label = "Submit Render to Deadline (USD)"
families = ["usdrender"]

# Do not use published workfile paths for USD Render ROP because the
# Export Job doesn't seem to occur using the published path either, so
# output paths then do not match the actual rendered paths
use_published = False
families = ["usdrender"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
FileUtils,
DirectoryUtils,
)
__version__ = "1.1.1"
__version__ = "1.1.2"
VERSION_REGEX = re.compile(
r"(?P<major>0|[1-9]\d*)"
r"\.(?P<minor>0|[1-9]\d*)"
Expand Down Expand Up @@ -496,6 +496,13 @@ def inject_ayon_environment(deadlinePlugin):
"extractenvironments",
export_url
]

# staging requires passing argument
# TODO could be switched to env var after https://github.com/ynput/ayon-launcher/issues/123
settings_variant = job.GetJobEnvironmentKeyValue("AYON_DEFAULT_SETTINGS_VARIANT") # noqa
if settings_variant == "staging":
args.append("--use-staging")

# Backwards compatibility for older versions
legacy_args = [
"--headless",
Expand Down
2 changes: 1 addition & 1 deletion client/ayon_deadline/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
"""Package declaring AYON addon 'deadline' version."""
__version__ = "0.2.4-dev.1"
__version__ = "0.2.5-dev.1"
7 changes: 3 additions & 4 deletions create_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ def safe_copy_file(src_path: str, dst_path: str):
return

dst_dir: str = os.path.dirname(dst_path)
try:
os.makedirs(dst_dir)
except Exception:
pass
os.makedirs(dst_dir, exist_ok=True)

shutil.copy2(src_path, dst_path)

Expand Down Expand Up @@ -355,6 +352,8 @@ def copy_addon_package(
# Copy server content
for src_file, dst_subpath in files_mapping:
dst_path: str = os.path.join(addon_output_dir, dst_subpath)
dst_dir: str = os.path.dirname(dst_path)
os.makedirs(dst_dir, exist_ok=True)
if isinstance(src_file, io.BytesIO):
with open(dst_path, "wb") as stream:
stream.write(src_file.getvalue())
Expand Down
2 changes: 1 addition & 1 deletion package.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "deadline"
title = "Deadline"
version = "0.2.4-dev.1"
version = "0.2.5-dev.1"

client_dir = "ayon_deadline"

Expand Down

0 comments on commit f747671

Please sign in to comment.