Skip to content

Commit

Permalink
feat!: update to the 2023-09 job template schema
Browse files Browse the repository at this point in the history
The job template schema is being updated for service release. With it,
the implementation library is being updated in a breaking way and so
this code needs to be updated to that revision. This includes a rename
of the job template's specification name from the codename openjobio
to Open Job Description.

Signed-off-by: Daniel Neilson <neilsd@amazon.com>
  • Loading branch information
ddneilson committed Sep 6, 2023
1 parent af15904 commit 42da746
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 217 deletions.
8 changes: 4 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ farm that uses a service-managed fleet. You'll need to perform the following ste
your build of the adaptor for the one in the service.

1. Use the development location from the Submitter Development Workflow.
You will need to also check out `openjobio` from git if you do
You will need to also check out `openjd` from git if you do
not already have it. Make sure you're running Nuke with `set DEADLINE_ENABLE_DEVELOPER_OPTIONS=true`
enabled.
2. Build wheels for `openjobio`, `deadline` and `deadline-nuke`.
2. Build wheels for `openjd`, `deadline` and `deadline-nuke`.
```
# If you don't have the build package installed already
$ pip install build
...
$ mkdir wheels; \
rm wheels/*; \
for dir in ../openjobio ../deadline ../deadline-nuke; \
for dir in ../openjd ../deadline ../deadline-nuke; \
do python -m build --wheel --outdir ./wheels --skip-dependency-check $dir; \
done
...
$ ls ./wheels
openjobio-<version>-py3-none-any.whl
openjd-<version>-py3-none-any.whl
deadline_cloud_for_nuke-<version>-py3-none-any.whl deadline-<version>-py3-none-any.whl
```
3. Open the Nuke integrated submitter, and in the Job-Specific Settings tab, enable the option 'Include Adaptor Wheels'. This
Expand Down
4 changes: 2 additions & 2 deletions depsBundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def _get_dependencies(pyproject_dict: dict[str, Any]) -> list[str]:
raise Exception("pyproject.toml is missing dependencies section")

dependencies = pyproject_dict["project"]["dependencies"]
deps_noopenjobio = filter(lambda dep: not dep.startswith("openjobio"), dependencies)
return list(map(lambda dep: dep.replace(" ", ""), deps_noopenjobio))
deps_noopenjd = filter(lambda dep: not dep.startswith("openjd"), dependencies)
return list(map(lambda dep: dep.replace(" ", ""), deps_noopenjd))


def _get_package_version_regex(package: str) -> re.Pattern:
Expand Down
47 changes: 47 additions & 0 deletions hatch_custom_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
import os
import shutil

from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from typing import Any


class HatchCustomBuildHook(BuildHookInterface):
"""
This class implements Hatch's [custom build hook] (https://hatch.pypa.io/1.6/plugins/build-hook/custom/)
for a copy_version_py operation that copies the _version.py file generated by the hatch-vcs build hook into
specified destination directories. See the `[[tool.hatch.build.hooks.custom]]` section in `pyproject.toml`.
"""

def _validate_config(self):
if sorted(self.config) != ["copy_version_py", "path"] or list(
self.config["copy_version_py"]
) != ["destinations"]:
raise RuntimeError(
"Configuration of the custom build hook must be like { 'copy_version_py': {'destinations': ['path1', ...]}}."
+ f" Received:\n{self.config}"
)

def initialize(self, version: str, build_data: dict[str, Any]) -> None:
self._validate_config()

for destination in self.config["copy_version_py"]["destinations"]:
print(f"Copying _version.py to {destination}")
shutil.copy(
os.path.join(self.root, "_version.py"),
os.path.join(self.root, destination),
)

def clean(self, versions: list[str]) -> None:
self._validate_config()

cleaned_count = 0
for destination in self.config["copy_version_py"]["destinations"]:
print(f"Cleaning _version.py from {destination}")
clean_path = os.path.join(self.root, destination, "_version.py")
try:
os.remove(clean_path)
cleaned_count += 1
except FileNotFoundError:
pass
print(f"Cleaned {cleaned_count} items")
160 changes: 0 additions & 160 deletions hatch_version_hook.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
specificationVersion: '2022-09-01'
specificationVersion: 'jobtemplate-2023-09'
name: multi-load-save.nk
parameters:
parameterDefinitions:
- name: NukeScriptFile
type: PATH
objectType: FILE
Expand Down Expand Up @@ -74,7 +74,7 @@ parameters:
label: Rez Packages
description: A space-separated list of Rez packages to install
default: nuke-13 deadline_cloud_for_nuke
environments:
jobEnvironments:
- name: Rez
description: Initializes and destroys the Rez environment for the job.
script:
Expand Down Expand Up @@ -159,17 +159,17 @@ environments:
for k, v in put.items():
print(f"updating {k}={v}")
print(f"openjobio_env: {k}={v}")
print(f"openjd_env: {k}={v}")
for k in delete:
print(f"openjobio_unset_env: {k}")
print(f"openjd_unset_env: {k}")
steps:
- name: Render
parameterSpace:
parameters:
taskParameterDefinitions:
- name: Frame
type: INT
range: '{{Param.Frames}}'
environments:
stepEnvironments:
- name: Nuke
description: Runs Nuke in the background with a script file loaded.
script:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
specificationVersion: '2022-09-01'
specificationVersion: 'jobtemplate-2023-09'
name: noise-saver.nk
parameters:
parameterDefinitions:
- name: NukeScriptFile
type: PATH
objectType: FILE
Expand Down Expand Up @@ -72,7 +72,7 @@ parameters:
label: Rez Packages
description: A space-separated list of Rez packages to install
default: nuke-13 deadline_cloud_for_nuke
environments:
jobEnvironments:
- name: Rez
description: Initializes and destroys the Rez environment for the job.
script:
Expand Down Expand Up @@ -157,17 +157,17 @@ environments:
for k, v in put.items():
print(f"updating {k}={v}")
print(f"openjobio_env: {k}={v}")
print(f"openjd_env: {k}={v}")
for k in delete:
print(f"openjobio_unset_env: {k}")
print(f"openjd_unset_env: {k}")
steps:
- name: Render
parameterSpace:
parameters:
taskParameterDefinitions:
- name: Frame
type: INT
range: '{{Param.Frames}}'
environments:
stepEnvironments:
- name: Nuke
description: Runs Nuke in the background with a script file loaded.
script:
Expand Down
11 changes: 4 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ license = ""
requires-python = ">=3.7"

dependencies = [
"deadline == 0.19.*",
"openjobio == 0.8.*",
"deadline == 0.20.*",
"openjd == 0.10.*",
]

[project.scripts]
Expand All @@ -36,12 +36,9 @@ version_scheme = "post-release"
version-file = "_version.py"

[tool.hatch.build.hooks.custom]
path = "hatch_version_hook.py"
path = "hatch_custom_hook.py"

[[tool.hatch.build.hooks.custom.copy_map]]
sources = [
"_version.py",
]
[tool.hatch.build.hooks.custom.copy_version_py]
destinations = [
"src/deadline/nuke_adaptor",
"src/deadline/nuke_submitter",
Expand Down
2 changes: 1 addition & 1 deletion src/deadline/nuke_adaptor/NukeAdaptor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging as _logging
import sys as _sys

from openjobio.adaptor_runtime import EntryPoint as _EntryPoint
from openjd.adaptor_runtime import EntryPoint as _EntryPoint

from .adaptor import NukeAdaptor

Expand Down
Loading

0 comments on commit 42da746

Please sign in to comment.