diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 7a98e75..14fc369 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -53,7 +53,7 @@ WARNING: This workflow installs additional Python packages into your Nuke's pyth 2. Switch to your Nuke directory, like `cd "C:\Program Files\Nuke15.0v2"`. 3. Run `.\python -m pip install -e C:\Users\\deadline-clients\deadline-cloud` to install the AWS Deadline Cloud Client Library in edit mode. 4. Run `.\python -m pip install -e C:\Users\\deadline-clients\deadline-cloud-for-nuke` to install the Nuke Submitter in edit mode. -5. Run `set NUKE_PATH=C:\Users\\deadline-clients\deadline-cloud-for-nuke\src` to put the `menu.py` file in the path Nuke searches for menu extensions. +5. Run `set NUKE_PATH=C:\Users\\deadline-clients\deadline-cloud-for-nuke\src\deadline\nuke_submitter` to put the `menu.py` file in the path Nuke searches for menu extensions. 6. Run `set DEADLINE_ENABLE_DEVELOPER_OPTIONS=true` to enable the job bundle debugging support. This enables a menu item you can use to run the tests from the `job_bundle_output_tests` directory. 7. Run `.\Nuke.exe` to run Nuke. The Nuke submitter should be available in the AWS Deadline menu. diff --git a/README.md b/README.md index d50e39a..c1770c5 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,28 @@ This library requires: This package provides a Nuke plugin that creates jobs for AWS Deadline Cloud using the [AWS Deadline Cloud client library][deadline-cloud-client]. Based on the loaded comp it determines the files required, allows the user to specify render options, and builds an [OpenJD template][openjd] that defines the workflow. +### Getting Started + +To install the submitter manually, you can use pip. + +```sh +$ pip install deadline-cloud-for-nuke -t target-directory +``` + +For Windows, +```sh +$ set NUKE_PATH=%NUKE_PATH%;/deadline/nuke_submitter +``` + +For Linux and MacOS: +```sh +$ export NUKE_PATH=${NUKE_PATH}:/deadline/nuke_submitter +``` + +After installation and within the same terminal, run `Nuke` executable. The Nuke submitter should now be available in the AWS Deadline menu. + +NOTE: If you want the submitter available outside of this shell, consider using `NUKE_PATH` as an environment variable rather than a shell variable. + ## Adaptor The Nuke Adaptor implements the [OpenJD][openjd-adaptor-runtime] interface that allows render workloads to launch Nuke and feed it commands. This gives the following benefits: diff --git a/install_builder/deadline-cloud-for-nuke.xml b/install_builder/deadline-cloud-for-nuke.xml index 2017b65..fd7ed4a 100644 --- a/install_builder/deadline-cloud-for-nuke.xml +++ b/install_builder/deadline-cloud-for-nuke.xml @@ -18,7 +18,6 @@ - @@ -77,7 +76,7 @@ Setting NUKE_PATH NUKE_PATH - ${nuke_installdir} + ${nuke_installdir}/deadline/nuke_submitter ${installscope} end diff --git a/src/deadline/nuke_submitter/menu.py b/src/deadline/nuke_submitter/menu.py new file mode 100644 index 0000000..c7c642f --- /dev/null +++ b/src/deadline/nuke_submitter/menu.py @@ -0,0 +1,42 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + +""" +DO NOT CHANGE THIS FILE's NAME + +Nuke loads this "init.py" or "menu.py" when looking in its plugin folder. + +You can inform nuke to look in additional locations by setting via the +NUKE_PATH environment variable. +""" + +import sys +import traceback +import nuke +import os + +from deadline.nuke_submitter import ( + show_nuke_render_submitter_noargs, + run_render_submitter_job_bundle_output_test, +) + + +def add_deadline_menu() -> None: + try: + menu_bar = nuke.menu("Nuke") + aws_deadline_menu = menu_bar.addMenu("&AWS Deadline") + aws_deadline_menu.addCommand( + "Submit to Deadline Cloud", show_nuke_render_submitter_noargs, "" + ) + # Set the environment variable DEADLINE_ENABLE_DEVELOPER_OPTIONS to "true" to get this menu. + if os.environ.get("DEADLINE_ENABLE_DEVELOPER_OPTIONS", "").upper() == "TRUE": + aws_deadline_menu.addCommand( + "Run Nuke Submitter Job Bundle Output Tests...", + run_render_submitter_job_bundle_output_test, + "", + ) + except Exception: + print("Failed to load deadline.nuke_submitter. Reason:", file=sys.stderr) + print(traceback.format_exc(), file=sys.stderr) + + +add_deadline_menu() diff --git a/src/menu.py b/src/menu.py deleted file mode 100644 index c359027..0000000 --- a/src/menu.py +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - -""" -DO NOT CHANGE THIS FILE's NAME - -Nuke loads this "init.py" or "menu.py" when looking in its plugin folder. - -You can inform nuke to look in additional locations by setting via the -NUKE_PATH environment variable. -""" - -try: - import nuke - import os - - from deadline.nuke_submitter import ( - show_nuke_render_submitter_noargs, - run_render_submitter_job_bundle_output_test, - ) - - menu_bar = nuke.menu("Nuke") - aws_deadline_menu = menu_bar.addMenu("&AWS Deadline") - aws_deadline_menu.addCommand("Submit to Deadline Cloud", show_nuke_render_submitter_noargs, "") - # Set the environment variable DEADLINE_ENABLE_DEVELOPER_OPTIONS to "true" to get this menu. - if os.environ.get("DEADLINE_ENABLE_DEVELOPER_OPTIONS", "").upper() == "TRUE": - aws_deadline_menu.addCommand( - "Run Nuke Submitter Job Bundle Output Tests...", - run_render_submitter_job_bundle_output_test, - "", - ) - -except BaseException: - import sys - import traceback - - print("Failed to load deadline.nuke_submitter. Reason:", file=sys.stderr) - print(traceback.format_exc(), file=sys.stderr) diff --git a/test/unit/deadline_submitter_for_nuke/test_menu.py b/test/unit/deadline_submitter_for_nuke/test_menu.py new file mode 100644 index 0000000..60ac3e8 --- /dev/null +++ b/test/unit/deadline_submitter_for_nuke/test_menu.py @@ -0,0 +1,32 @@ +import os +import nuke +from unittest.mock import ANY +from deadline.nuke_submitter.menu import add_deadline_menu + + +def test_add_deadline_menu_env_var_true() -> None: + # GIVEN + os.environ["DEADLINE_ENABLE_DEVELOPER_OPTIONS"] = "true" + + # WHEN + add_deadline_menu() + + # THEN + nuke.menu("Nuke").addMenu.assert_called_with("&AWS Deadline") + nuke.menu("Nuke").addMenu("&AWS Deadline").addCommand.assert_called_with( + "Run Nuke Submitter Job Bundle Output Tests...", ANY, ANY + ) + + +def test_add_deadline_menu_env_var_false() -> None: + # GIVEN + os.environ["DEADLINE_ENABLE_DEVELOPER_OPTIONS"] = "false" + + # WHEN + add_deadline_menu() + + # THEN + nuke.menu("Nuke").addMenu.assert_called_with("&AWS Deadline") + nuke.menu("Nuke").addMenu("&AWS Deadline").addCommand.assert_called_with( + "Submit to Deadline Cloud", ANY, ANY + )