From 0bf351c55596adc2e69359d65036f5269c244690 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 22 Dec 2020 19:14:24 +0100 Subject: [PATCH 01/44] remove get_colorspace_preset --- pype/hosts/nuke/lib.py | 5 ++--- pype/hosts/nuke/presets.py | 9 ++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pype/hosts/nuke/lib.py b/pype/hosts/nuke/lib.py index 50b9697d8e..ce504e19de 100644 --- a/pype/hosts/nuke/lib.py +++ b/pype/hosts/nuke/lib.py @@ -12,7 +12,6 @@ import nuke from .presets import ( - get_colorspace_preset, get_node_dataflow_preset, get_node_colorspace_preset, get_anatomy @@ -734,7 +733,7 @@ class WorkfileSettings(object): continue # load nuke presets for Read's colorspace - read_clrs_presets = get_colorspace_preset().get( + read_clrs_presets = config.get_init_presets()["colorspace"].get( "nuke", {}).get("read", {}) # check if any colorspace presets for read is mathing @@ -775,7 +774,7 @@ class WorkfileSettings(object): def set_colorspace(self): ''' Setting colorpace following presets ''' - nuke_colorspace = get_colorspace_preset().get("nuke", None) + nuke_colorspace = config.get_init_presets()["colorspace"].get("nuke", None) try: self.set_root_colorspace(nuke_colorspace["root"]) diff --git a/pype/hosts/nuke/presets.py b/pype/hosts/nuke/presets.py index 2a296afc88..8015f8db64 100644 --- a/pype/hosts/nuke/presets.py +++ b/pype/hosts/nuke/presets.py @@ -11,12 +11,7 @@ def get_anatomy(**kwarg): def get_dataflow_preset(): presets = config.get_init_presets() return presets["dataflow"] - - -def get_colorspace_preset(): - presets = config.get_init_presets() - return presets["colorspace"] - + def get_node_dataflow_preset(**kwarg): ''' Get preset data for dataflow (fileType, compression, bitDepth) @@ -60,7 +55,7 @@ def get_node_colorspace_preset(**kwarg): log.error(msg) nuke.message(msg) - nuke_colorspace = get_colorspace_preset().get(str(host), None) + nuke_colorspace = config.get_init_presets()["colorspace"].get(str(host), None) nuke_colorspace_node = nuke_colorspace.get(str(cls), None) if preset: # omit < 2.0.0v From 4b1699f334f8d097aaceb598f58043df936615c8 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 22 Dec 2020 19:14:53 +0100 Subject: [PATCH 02/44] get anatomy directly in the nuke.lib --- pype/hosts/nuke/lib.py | 16 +++++++++++----- pype/hosts/nuke/presets.py | 4 ---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pype/hosts/nuke/lib.py b/pype/hosts/nuke/lib.py index ce504e19de..920141bf37 100644 --- a/pype/hosts/nuke/lib.py +++ b/pype/hosts/nuke/lib.py @@ -6,20 +6,26 @@ from collections import OrderedDict from avalon import api, io, lib import avalon.nuke from avalon.nuke import lib as anlib -import pype.api as pype +from pype.api import ( + Logger, + get_version_from_path, + get_hierarchy, + get_asset, + Anatomy, + config +) import nuke from .presets import ( get_node_dataflow_preset, - get_node_colorspace_preset, - get_anatomy + get_node_colorspace_preset ) from .utils import set_context_favorites -log = pype.Logger().get_logger(__name__, "nuke") +log = pype.api.Logger().get_logger(__name__, "nuke") self = sys.modules[__name__] self._project = None @@ -170,7 +176,7 @@ def format_anatomy(data): ''' # TODO: perhaps should be nonPublic - anatomy = get_anatomy() + anatomy = Anatomy() log.debug("__ anatomy.templates: {}".format(anatomy.templates)) try: diff --git a/pype/hosts/nuke/presets.py b/pype/hosts/nuke/presets.py index 8015f8db64..dd780ff99e 100644 --- a/pype/hosts/nuke/presets.py +++ b/pype/hosts/nuke/presets.py @@ -4,10 +4,6 @@ import nuke log = Logger().get_logger(__name__, "nuke") -def get_anatomy(**kwarg): - return Anatomy() - - def get_dataflow_preset(): presets = config.get_init_presets() return presets["dataflow"] From 502833ccbe55dfda768d68e2c38af08d174ff2c6 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 22 Dec 2020 19:16:48 +0100 Subject: [PATCH 03/44] import explicitly from pype.api into nuke.lib --- pype/hosts/nuke/lib.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pype/hosts/nuke/lib.py b/pype/hosts/nuke/lib.py index 920141bf37..63cbd038d4 100644 --- a/pype/hosts/nuke/lib.py +++ b/pype/hosts/nuke/lib.py @@ -25,7 +25,7 @@ from .presets import ( from .utils import set_context_favorites -log = pype.api.Logger().get_logger(__name__, "nuke") +log = Logger().get_logger(__name__, "nuke") self = sys.modules[__name__] self._project = None @@ -93,7 +93,7 @@ def writes_version_sync(): ''' Callback synchronizing version of publishable write nodes ''' try: - rootVersion = pype.get_version_from_path(nuke.root().name()) + rootVersion = get_version_from_path(nuke.root().name()) padding = len(rootVersion) new_version = "v" + str("{" + ":0>{}".format(padding) + "}").format( int(rootVersion) @@ -118,7 +118,7 @@ def writes_version_sync(): node_file = each['file'].value() - node_version = "v" + pype.get_version_from_path(node_file) + node_version = "v" + get_version_from_path(node_file) log.debug("node_version: {}".format(node_version)) node_new_file = node_file.replace(node_version, new_version) @@ -199,7 +199,7 @@ def format_anatomy(data): version = data.get("version", None) if not version: file = script_name() - data["version"] = pype.get_version_from_path(file) + data["version"] = get_version_from_path(file) project_document = io.find_one({"type": "project"}) data.update({ "subset": data["avalon"]["subset"], @@ -210,7 +210,7 @@ def format_anatomy(data): "code": project_document["data"].get("code", '')}, "representation": data["nuke_dataflow_writes"]["file_type"], "app": data["application"]["application_dir"], - "hierarchy": pype.get_hierarchy(), + "hierarchy": get_hierarchy(), "frame": "#" * padding, }) return anatomy.format(data) @@ -547,7 +547,7 @@ class WorkfileSettings(object): self._project = kwargs.get( "project") or io.find_one({"type": "project"}) self._asset = kwargs.get("asset_name") or api.Session["AVALON_ASSET"] - self._asset_entity = pype.get_asset(self._asset) + self._asset_entity = get_asset(self._asset) self._root_node = root_node or nuke.root() self._nodes = self.get_nodes(nodes=nodes) @@ -980,7 +980,7 @@ class WorkfileSettings(object): # replace reset resolution from avalon core to pype's self.reset_frame_range_handles() # add colorspace menu item - self.set_colorspace() + # self.set_colorspace() def set_favorites(self): work_dir = os.getenv("AVALON_WORKDIR") From edc55874fb5a4414ea95f88bfd3e44b5c58cae78 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 22 Dec 2020 19:17:59 +0100 Subject: [PATCH 04/44] remove get_dataflow_preset --- pype/hosts/nuke/presets.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pype/hosts/nuke/presets.py b/pype/hosts/nuke/presets.py index dd780ff99e..a836327496 100644 --- a/pype/hosts/nuke/presets.py +++ b/pype/hosts/nuke/presets.py @@ -4,11 +4,6 @@ import nuke log = Logger().get_logger(__name__, "nuke") -def get_dataflow_preset(): - presets = config.get_init_presets() - return presets["dataflow"] - - def get_node_dataflow_preset(**kwarg): ''' Get preset data for dataflow (fileType, compression, bitDepth) ''' @@ -21,7 +16,7 @@ def get_node_dataflow_preset(**kwarg): assert any([host, cls]), nuke.message( "`{}`: Missing mandatory kwargs `host`, `cls`".format(__file__)) - nuke_dataflow = get_dataflow_preset().get(str(host), None) + nuke_dataflow = config.get_init_presets()["dataflow"].get(str(host), None) nuke_dataflow_nodes = nuke_dataflow.get('nodes', None) nuke_dataflow_node = nuke_dataflow_nodes.get(str(cls), None) From c89964d8bd6e69273ffdd24ece194c839455d42f Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Tue, 22 Dec 2020 19:38:55 +0100 Subject: [PATCH 05/44] remove presets.py and unify data and colour into imageio --- pype/hosts/nuke/lib.py | 59 ++++++++++++++++++++---------------- pype/hosts/nuke/presets.py | 61 -------------------------------------- 2 files changed, 33 insertions(+), 87 deletions(-) delete mode 100644 pype/hosts/nuke/presets.py diff --git a/pype/hosts/nuke/lib.py b/pype/hosts/nuke/lib.py index 63cbd038d4..e915ba0df9 100644 --- a/pype/hosts/nuke/lib.py +++ b/pype/hosts/nuke/lib.py @@ -9,6 +9,7 @@ from avalon.nuke import lib as anlib from pype.api import ( Logger, get_version_from_path, + get_anatomy_settings, get_hierarchy, get_asset, Anatomy, @@ -17,12 +18,6 @@ from pype.api import ( import nuke - -from .presets import ( - get_node_dataflow_preset, - get_node_colorspace_preset -) - from .utils import set_context_favorites log = Logger().get_logger(__name__, "nuke") @@ -31,6 +26,30 @@ self = sys.modules[__name__] self._project = None +def get_node_imageio_setting(**kwarg): + ''' Get preset data for dataflow (fileType, compression, bitDepth) + ''' + log.info(kwarg) + host = kwarg.get("host", "nuke") + class_name = kwarg.get("class", None) + families = kwarg.get("families", []) + project_name = os.getenv("AVALON_PROJECT") + + assert any([host, class_name]), nuke.message( + "`{}`: Missing mandatory kwargs `host`, `cls`".format(__file__)) + + nuke_imageio = get_anatomy_settings(project_name)["imageio"].get(str(host), None) + nuke_imageio_nodes = nuke_imageio.get('nodes', None) + nuke_imageio_node = nuke_imageio_nodes.get(str(class_name), None) + + if families: + for family in families: + nuke_imageio_node = nuke_imageio_node.get(str(family), None) + + log.info("Dataflow: {}".format(nuke_imageio_node)) + return nuke_imageio_node + + def on_script_load(): ''' Callback for ffmpeg support ''' @@ -151,14 +170,12 @@ def get_render_path(node): "preset": data['avalon']['families'] } - nuke_dataflow_writes = get_node_dataflow_preset(**data_preset) - nuke_colorspace_writes = get_node_colorspace_preset(**data_preset) + nuke_imageio_writes = get_node_imageio_setting(**data_preset) application = lib.get_application(os.environ["AVALON_APP_NAME"]) data.update({ "application": application, - "nuke_dataflow_writes": nuke_dataflow_writes, - "nuke_colorspace_writes": nuke_colorspace_writes + "nuke_imageio_writes": nuke_imageio_writes }) anatomy_filled = format_anatomy(data) @@ -261,15 +278,13 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): node (obj): group node with avalon data as Knobs ''' - nuke_dataflow_writes = get_node_dataflow_preset(**data) - nuke_colorspace_writes = get_node_colorspace_preset(**data) + nuke_imageio_writes = get_node_imageio_setting(**data) application = lib.get_application(os.environ["AVALON_APP_NAME"]) try: data.update({ "application": application, - "nuke_dataflow_writes": nuke_dataflow_writes, - "nuke_colorspace_writes": nuke_colorspace_writes + "nuke_imageio_writes": nuke_imageio_writes }) anatomy_filled = format_anatomy(data) @@ -283,7 +298,7 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): fpath = data["fpath_template"].format( work=fpath, version=data["version"], subset=data["subset"], frame=data["frame"], - ext=data["nuke_dataflow_writes"]["file_type"] + ext=data["nuke_imageio_writes"]["file_type"] ) # create directory @@ -301,10 +316,6 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): for k, v in nuke_dataflow_writes.items() if k not in ["_id", "_previous"]} - # adding colorspace template - log.debug("nuke_colorspace_writes: `{}`".format(nuke_colorspace_writes)) - {_data.update({k: v}) - for k, v in nuke_colorspace_writes.items()} _data = avalon.nuke.lib.fix_data_for_node_create(_data) @@ -1049,22 +1060,18 @@ def get_write_node_template_attr(node): } # get template data - nuke_dataflow_writes = get_node_dataflow_preset(**data_preset) - nuke_colorspace_writes = get_node_colorspace_preset(**data_preset) + nuke_imageio_writes = get_node_imageio_setting(**data_preset) # collecting correct data correct_data = OrderedDict({ "file": get_render_path(node) }) - # adding dataflow template + # adding imageio template {correct_data.update({k: v}) - for k, v in nuke_dataflow_writes.items() + for k, v in nuke_imageio_writes.items() if k not in ["_id", "_previous"]} - # adding colorspace template - {correct_data.update({k: v}) - for k, v in nuke_colorspace_writes.items()} # fix badly encoded data return avalon.nuke.lib.fix_data_for_node_create(correct_data) diff --git a/pype/hosts/nuke/presets.py b/pype/hosts/nuke/presets.py deleted file mode 100644 index a836327496..0000000000 --- a/pype/hosts/nuke/presets.py +++ /dev/null @@ -1,61 +0,0 @@ -from pype.api import Anatomy, config, Logger -import nuke - -log = Logger().get_logger(__name__, "nuke") - - -def get_node_dataflow_preset(**kwarg): - ''' Get preset data for dataflow (fileType, compression, bitDepth) - ''' - log.info(kwarg) - host = kwarg.get("host", "nuke") - cls = kwarg.get("class", None) - families = kwarg.get("families", []) - preset = kwarg.get("preset", None) # omit < 2.0.0v - - assert any([host, cls]), nuke.message( - "`{}`: Missing mandatory kwargs `host`, `cls`".format(__file__)) - - nuke_dataflow = config.get_init_presets()["dataflow"].get(str(host), None) - nuke_dataflow_nodes = nuke_dataflow.get('nodes', None) - nuke_dataflow_node = nuke_dataflow_nodes.get(str(cls), None) - - if preset: # omit < 2.0.0v - nuke_dataflow_node = nuke_dataflow_node.get(str(preset), None) - # omit < 2.0.0v - - if families: - for family in families: - nuke_dataflow_node = nuke_dataflow_node.get(str(family), None) - - log.info("Dataflow: {}".format(nuke_dataflow_node)) - return nuke_dataflow_node - - -def get_node_colorspace_preset(**kwarg): - ''' Get preset data for colorspace - ''' - log.info(kwarg) - host = kwarg.get("host", "nuke") - cls = kwarg.get("class", None) - families = kwarg.get("families", []) - preset = kwarg.get("preset", None) # omit < 2.0.0v - - if not any([host, cls]): - msg = "`{}`: Missing mandatory kwargs `host`, `cls`".format(__file__) - log.error(msg) - nuke.message(msg) - - nuke_colorspace = config.get_init_presets()["colorspace"].get(str(host), None) - nuke_colorspace_node = nuke_colorspace.get(str(cls), None) - - if preset: # omit < 2.0.0v - nuke_colorspace_node = nuke_colorspace_node.get(str(preset), None) - # omit < 2.0.0v - - if families: - for family in families: - nuke_colorspace_node = nuke_colorspace_node.get(str(family), None) - - log.info("Colorspace: {}".format(nuke_colorspace_node)) - return nuke_colorspace_node From 1f0b9ac2f0241f996105c037eee44ab38e64cc65 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:41:29 +0100 Subject: [PATCH 06/44] pass creator name to create data --- .../plugins/nuke/create/create_write_prerender.py | 15 +++++++++------ pype/plugins/nuke/create/create_write_render.py | 13 +++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pype/plugins/nuke/create/create_write_prerender.py b/pype/plugins/nuke/create/create_write_prerender.py index 2243ba8b5c..44b01f4bcd 100644 --- a/pype/plugins/nuke/create/create_write_prerender.py +++ b/pype/plugins/nuke/create/create_write_prerender.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from pype.hosts.nuke import ( +from pype.hosts.nuke.api import ( plugin, - lib as pnlib) + lib) import nuke @@ -10,7 +10,7 @@ class CreateWritePrerender(plugin.PypeCreator): name = "WritePrerender" label = "Create Write Prerender" hosts = ["nuke"] - n_class = "write" + n_class = "Write" family = "prerender" icon = "sign-out" defaults = ["Key01", "Bg01", "Fg01", "Branch01", "Part01"] @@ -75,9 +75,10 @@ class CreateWritePrerender(plugin.PypeCreator): # recreate new write_data = { - "class": self.n_class, + "nodeclass": self.n_class, "families": [self.family], - "avalon": self.data + "avalon": self.data, + "creator": self.__class__.__name__ } if self.presets.get('fpath_template'): @@ -90,8 +91,10 @@ class CreateWritePrerender(plugin.PypeCreator): write_data.update({ "fpath_template": ("{work}/prerenders/nuke/{subset}" "/{subset}.{frame}.{ext}")}) + + self.log.info("write_data: {}".format(write_data)) - write_node = pnlib.create_write_node( + write_node = lib.create_write_node( self.data["subset"], write_data, input=selected_node, diff --git a/pype/plugins/nuke/create/create_write_render.py b/pype/plugins/nuke/create/create_write_render.py index 5a6bf57197..3876ba5806 100644 --- a/pype/plugins/nuke/create/create_write_render.py +++ b/pype/plugins/nuke/create/create_write_render.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from pype.hosts.nuke import ( +from pype.hosts.nuke.api import ( plugin, - lib as pnlib) + lib) import nuke @@ -10,7 +10,7 @@ class CreateWriteRender(plugin.PypeCreator): name = "WriteRender" label = "Create Write Render" hosts = ["nuke"] - n_class = "write" + n_class = "Write" family = "render" icon = "sign-out" defaults = ["Main", "Mask"] @@ -76,9 +76,10 @@ class CreateWriteRender(plugin.PypeCreator): # recreate new write_data = { - "class": self.n_class, + "nodeclass": self.n_class, "families": [self.family], - "avalon": self.data + "avalon": self.data, + "creator": self.__class__.__name__ } if self.presets.get('fpath_template'): @@ -92,7 +93,7 @@ class CreateWriteRender(plugin.PypeCreator): "fpath_template": ("{work}/renders/nuke/{subset}" "/{subset}.{frame}.{ext}")}) - write_node = pnlib.create_write_node( + write_node = lib.create_write_node( self.data["subset"], write_data, input=selected_node) From 22dece8e0be6c17af770ff9d2d79bf7c21dc1c77 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:42:00 +0100 Subject: [PATCH 07/44] fix read node creator --- pype/plugins/nuke/create/create_read.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pype/plugins/nuke/create/create_read.py b/pype/plugins/nuke/create/create_read.py index 70db580a7e..072d234b32 100644 --- a/pype/plugins/nuke/create/create_read.py +++ b/pype/plugins/nuke/create/create_read.py @@ -44,7 +44,8 @@ class CrateRead(avalon.nuke.Creator): continue avalon_data = self.data avalon_data['subset'] = "{}".format(self.name) - self.change_read_node(self.data["subset"], node, avalon_data) + avalon.nuke.lib.imprint(node, avalon_data) + node['tile_color'].setValue(16744935) count_reads += 1 if count_reads < 1: @@ -52,7 +53,3 @@ class CrateRead(avalon.nuke.Creator): self.log.error(msg) nuke.message(msg) return - - def change_read_node(self, name, node, data): - node = avalon.nuke.lib.imprint(node, data) - node['tile_color'].setValue(16744935) From 9a31f38e36ef3fe6f77bcbec011d4a1cda9fff7f Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:42:40 +0100 Subject: [PATCH 08/44] move nuke to hosts.nuke.api --- pype/api.py | 12 ++- pype/hosts/nuke/api/__init__.py | 142 ++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 pype/hosts/nuke/api/__init__.py diff --git a/pype/api.py b/pype/api.py index a2b4f22e72..e0cc8d4ab5 100644 --- a/pype/api.py +++ b/pype/api.py @@ -9,7 +9,7 @@ from .lib import ( PypeLogger, Anatomy, config, - execute + execute, ) from .lib.mongo import ( @@ -18,6 +18,14 @@ from .lib.mongo import ( get_default_components ) +from .lib.applications import ( + ApplicationManager +) + +from .lib.avalon_context import ( + BuildWorkfile +) + from . import resources from .plugin import ( @@ -68,6 +76,8 @@ __all__ = [ "decompose_url", "compose_url", "get_default_components", + "ApplicationManager", + "BuildWorkfile", # Resources "resources", diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py new file mode 100644 index 0000000000..87c3e190e2 --- /dev/null +++ b/pype/hosts/nuke/api/__init__.py @@ -0,0 +1,142 @@ +import os +import sys +import logging + +import nuke + +from avalon import api as avalon +from avalon.tools import workfiles +from pyblish import api as pyblish +from pype.api import Logger +from pype import PLUGINS_DIR +from . import lib, menu + + +self = sys.modules[__name__] +self.workfiles_launched = False +log = Logger().get_logger(__name__, "nuke") + +AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") + +PUBLISH_PATH = os.path.join(PLUGINS_DIR, "nuke", "publish") +LOAD_PATH = os.path.join(PLUGINS_DIR, "nuke", "load") +CREATE_PATH = os.path.join(PLUGINS_DIR, "nuke", "create") +INVENTORY_PATH = os.path.join(PLUGINS_DIR, "nuke", "inventory") + + +# registering pyblish gui regarding settings in presets +if os.getenv("PYBLISH_GUI", None): + pyblish.register_gui(os.getenv("PYBLISH_GUI", None)) + + +def reload_config(): + """Attempt to reload pipeline at run-time. + + CAUTION: This is primarily for development and debugging purposes. + + """ + + import importlib + + for module in ( + "{}.api".format(AVALON_CONFIG), + "{}.hosts.nuke.actions".format(AVALON_CONFIG), + "{}.hosts.nuke.menu".format(AVALON_CONFIG), + "{}.hosts.nuke.plugin".format(AVALON_CONFIG), + "{}.hosts.nuke.lib".format(AVALON_CONFIG), + ): + log.info("Reloading module: {}...".format(module)) + + module = importlib.import_module(module) + + try: + importlib.reload(module) + except AttributeError as e: + log.warning("Cannot reload module: {}".format(e)) + reload(module) + + +def install(): + ''' Installing all requarements for Nuke host + ''' + + log.info("Registering Nuke plug-ins..") + pyblish.register_plugin_path(PUBLISH_PATH) + avalon.register_plugin_path(avalon.Loader, LOAD_PATH) + avalon.register_plugin_path(avalon.Creator, CREATE_PATH) + avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH) + + # Register Avalon event for workfiles loading. + # avalon.on("workio.open_file", lib.check_inventory_versions) + + # pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) + workfile_settings = lib.WorkfileSettings() + # Disable all families except for the ones we explicitly want to see + family_states = [ + "write", + "review", + "nukenodes" + "gizmo" + ] + + avalon.data["familiesStateDefault"] = False + avalon.data["familiesStateToggled"] = family_states + + # Workfiles. + launch_workfiles = os.environ.get("WORKFILES_STARTUP") + + if launch_workfiles: + nuke.addOnCreate(launch_workfiles_app, nodeClass="Root") + + # Set context settings. + # nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root") + # nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root") + + menu.install() + + +def launch_workfiles_app(): + '''Function letting start workfiles after start of host + ''' + if not self.workfiles_launched: + self.workfiles_launched = True + workfiles.show(os.environ["AVALON_WORKDIR"]) + + +def uninstall(): + '''Uninstalling host's integration + ''' + log.info("Deregistering Nuke plug-ins..") + pyblish.deregister_plugin_path(PUBLISH_PATH) + avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH) + avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH) + + pyblish.deregister_callback("instanceToggled", on_pyblish_instance_toggled) + + + reload_config() + menu.uninstall() + + +def on_pyblish_instance_toggled(instance, old_value, new_value): + """Toggle node passthrough states on instance toggles.""" + + log.info("instance toggle: {}, old_value: {}, new_value:{} ".format( + instance, old_value, new_value)) + + from avalon.nuke import ( + viewer_update_and_undo_stop, + add_publish_knob + ) + + # Whether instances should be passthrough based on new value + + with viewer_update_and_undo_stop(): + n = instance[0] + try: + n["publish"].value() + except ValueError: + n = add_publish_knob(n) + log.info(" `Publish` knob was added to write node..") + + n["publish"].setValue(new_value) From a18aab0dd166100e3dabdb111849850becaab454 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:42:54 +0100 Subject: [PATCH 09/44] make nuke into module --- pype/hosts/nuke/__init__.py | 144 ------------------------------------ 1 file changed, 144 deletions(-) diff --git a/pype/hosts/nuke/__init__.py b/pype/hosts/nuke/__init__.py index 787f69f635..e69de29bb2 100644 --- a/pype/hosts/nuke/__init__.py +++ b/pype/hosts/nuke/__init__.py @@ -1,144 +0,0 @@ -import os -import sys -import logging - -import nuke - -from avalon import api as avalon -from avalon.tools import workfiles -from pyblish import api as pyblish -from pype.hosts.nuke import menu -from pype.api import Logger -from pype import PLUGINS_DIR -from . import lib - - -self = sys.modules[__name__] -self.workfiles_launched = False -log = Logger().get_logger(__name__, "nuke") - -AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") - -PUBLISH_PATH = os.path.join(PLUGINS_DIR, "nuke", "publish") -LOAD_PATH = os.path.join(PLUGINS_DIR, "nuke", "load") -CREATE_PATH = os.path.join(PLUGINS_DIR, "nuke", "create") -INVENTORY_PATH = os.path.join(PLUGINS_DIR, "nuke", "inventory") - - -# registering pyblish gui regarding settings in presets -if os.getenv("PYBLISH_GUI", None): - pyblish.register_gui(os.getenv("PYBLISH_GUI", None)) - - -def reload_config(): - """Attempt to reload pipeline at run-time. - - CAUTION: This is primarily for development and debugging purposes. - - """ - - import importlib - - for module in ( - "{}.api".format(AVALON_CONFIG), - "{}.hosts.nuke.actions".format(AVALON_CONFIG), - "{}.hosts.nuke.presets".format(AVALON_CONFIG), - "{}.hosts.nuke.menu".format(AVALON_CONFIG), - "{}.hosts.nuke.plugin".format(AVALON_CONFIG), - "{}.hosts.nuke.lib".format(AVALON_CONFIG), - ): - log.info("Reloading module: {}...".format(module)) - - module = importlib.import_module(module) - - try: - importlib.reload(module) - except AttributeError as e: - log.warning("Cannot reload module: {}".format(e)) - reload(module) - - -def install(): - ''' Installing all requarements for Nuke host - ''' - - log.info("Registering Nuke plug-ins..") - pyblish.register_plugin_path(PUBLISH_PATH) - avalon.register_plugin_path(avalon.Loader, LOAD_PATH) - avalon.register_plugin_path(avalon.Creator, CREATE_PATH) - avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH) - - # Register Avalon event for workfiles loading. - avalon.on("workio.open_file", lib.check_inventory_versions) - - pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) - workfile_settings = lib.WorkfileSettings() - # Disable all families except for the ones we explicitly want to see - family_states = [ - "write", - "review", - "nukenodes" - "gizmo" - ] - - avalon.data["familiesStateDefault"] = False - avalon.data["familiesStateToggled"] = family_states - - # Workfiles. - launch_workfiles = os.environ.get("WORKFILES_STARTUP") - - if launch_workfiles: - nuke.addOnCreate(launch_workfiles_app, nodeClass="Root") - - # Set context settings. - nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root") - nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root") - - menu.install() - - -def launch_workfiles_app(): - '''Function letting start workfiles after start of host - ''' - if not self.workfiles_launched: - self.workfiles_launched = True - workfiles.show(os.environ["AVALON_WORKDIR"]) - - -def uninstall(): - '''Uninstalling host's integration - ''' - log.info("Deregistering Nuke plug-ins..") - pyblish.deregister_plugin_path(PUBLISH_PATH) - avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH) - avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH) - - pyblish.deregister_callback("instanceToggled", on_pyblish_instance_toggled) - - - reload_config() - menu.uninstall() - - -def on_pyblish_instance_toggled(instance, old_value, new_value): - """Toggle node passthrough states on instance toggles.""" - - log.info("instance toggle: {}, old_value: {}, new_value:{} ".format( - instance, old_value, new_value)) - - from avalon.nuke import ( - viewer_update_and_undo_stop, - add_publish_knob - ) - - # Whether instances should be passthrough based on new value - - with viewer_update_and_undo_stop(): - n = instance[0] - try: - n["publish"].value() - except ValueError: - n = add_publish_knob(n) - log.info(" `Publish` knob was added to write node..") - - n["publish"].setValue(new_value) From 97171eba213c3ab05524043cbb87a28ec50277cc Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:44:58 +0100 Subject: [PATCH 10/44] create writes with new avalon core --- pype/hosts/nuke/{ => api}/lib.py | 99 +++++++++++++++++++++----------- pype/hosts/nuke/api/plugin.py | 27 +++++++++ pype/hosts/nuke/plugin.py | 13 ----- 3 files changed, 91 insertions(+), 48 deletions(-) rename pype/hosts/nuke/{ => api}/lib.py (95%) create mode 100644 pype/hosts/nuke/api/plugin.py delete mode 100644 pype/hosts/nuke/plugin.py diff --git a/pype/hosts/nuke/lib.py b/pype/hosts/nuke/api/lib.py similarity index 95% rename from pype/hosts/nuke/lib.py rename to pype/hosts/nuke/api/lib.py index e915ba0df9..a42f27226e 100644 --- a/pype/hosts/nuke/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -5,17 +5,19 @@ from collections import OrderedDict from avalon import api, io, lib import avalon.nuke +import acre from avalon.nuke import lib as anlib from pype.api import ( Logger, + Anatomy, get_version_from_path, get_anatomy_settings, get_hierarchy, get_asset, - Anatomy, - config + config, + ApplicationManager ) - + import nuke from .utils import set_context_favorites @@ -30,24 +32,29 @@ def get_node_imageio_setting(**kwarg): ''' Get preset data for dataflow (fileType, compression, bitDepth) ''' log.info(kwarg) - host = kwarg.get("host", "nuke") - class_name = kwarg.get("class", None) - families = kwarg.get("families", []) + host = str(kwarg.get("host", "nuke")) + nodeclass = kwarg.get("nodeclass", None) + creator = kwarg.get("creator", None) project_name = os.getenv("AVALON_PROJECT") - assert any([host, class_name]), nuke.message( + assert any([host, nodeclass]), nuke.message( "`{}`: Missing mandatory kwargs `host`, `cls`".format(__file__)) - nuke_imageio = get_anatomy_settings(project_name)["imageio"].get(str(host), None) - nuke_imageio_nodes = nuke_imageio.get('nodes', None) - nuke_imageio_node = nuke_imageio_nodes.get(str(class_name), None) + imageio_nodes = (get_anatomy_settings(project_name) + ["imageio"] + .get(host, None) + ["nodes"] + ["requiredNodes"] + ) - if families: - for family in families: - nuke_imageio_node = nuke_imageio_node.get(str(family), None) + for node in imageio_nodes: + log.info(node) + if node["nukeNodeClass"] == nodeclass: + if creator in node["plugins"]: + imageio_node = node - log.info("Dataflow: {}".format(nuke_imageio_node)) - return nuke_imageio_node + log.info("ImageIO node: {}".format(imageio_node)) + return imageio_node def on_script_load(): @@ -77,7 +84,7 @@ def check_inventory_versions(): if container: node = container["_node"] - avalon_knob_data = avalon.nuke.get_avalon_knob_data( + avalon_knob_data = avalon.nuke.read( node, ['avalon:', 'ak:']) # get representation from io @@ -127,7 +134,7 @@ def writes_version_sync(): if "AvalonTab" not in each.knobs(): continue - avalon_knob_data = avalon.nuke.get_avalon_knob_data( + avalon_knob_data = avalon.nuke.read( each, ['avalon:', 'ak:']) try: @@ -158,11 +165,27 @@ def version_up_script(): nukescripts.script_and_write_nodes_version_up() +def check_subsetname_exists(nodes, subset_name): + """ + Checking if node is not already created to secure there is no duplicity + + Arguments: + nodes (list): list of nuke.Node objects + subset_name (str): name we try to find + + Returns: + bool: True of False + """ + result = next((True for n in nodes + if subset_name in avalon.nuke.read(n).get("subset", "")), False) + return result + + def get_render_path(node): ''' Generate Render path from presets regarding avalon knob data ''' data = dict() - data['avalon'] = avalon.nuke.get_avalon_knob_data( + data['avalon'] = avalon.nuke.read( node, ['avalon:', 'ak:']) data_preset = { @@ -212,7 +235,7 @@ def format_anatomy(data): log.error(msg) nuke.message(msg) - + version = data.get("version", None) if not version: file = script_name() @@ -221,12 +244,10 @@ def format_anatomy(data): data.update({ "subset": data["avalon"]["subset"], "asset": data["avalon"]["asset"], - "task": api.Session["AVALON_TASK"], + "task": os.environ["AVALON_TASK"], "family": data["avalon"]["family"], "project": {"name": project_document["name"], "code": project_document["data"].get("code", '')}, - "representation": data["nuke_dataflow_writes"]["file_type"], - "app": data["application"]["application_dir"], "hierarchy": get_hierarchy(), "frame": "#" * padding, }) @@ -278,18 +299,26 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): node (obj): group node with avalon data as Knobs ''' - nuke_imageio_writes = get_node_imageio_setting(**data) - application = lib.get_application(os.environ["AVALON_APP_NAME"]) + imageio_writes = get_node_imageio_setting(**data) + app_manager = ApplicationManager() + app_name = os.environ.get("AVALON_APP_NAME") + if app_name: + app = app_manager.applications.get(app_name) + + for knob in imageio_writes["knobs"]: + if knob["name"] == "file_type": + representation = knob["value"] try: data.update({ - "application": application, - "nuke_imageio_writes": nuke_imageio_writes + "app": app.host_name, + "imageio_writes": imageio_writes, + "representation": representation, }) anatomy_filled = format_anatomy(data) except Exception as e: - msg = "problem with resolving anatomy tepmlate: {}".format(e) + msg = "problem with resolving anatomy template: {}".format(e) log.error(msg) nuke.message(msg) @@ -298,7 +327,7 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): fpath = data["fpath_template"].format( work=fpath, version=data["version"], subset=data["subset"], frame=data["frame"], - ext=data["nuke_imageio_writes"]["file_type"] + ext=representation ) # create directory @@ -311,10 +340,10 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): }) # adding dataflow template - log.debug("nuke_dataflow_writes: `{}`".format(nuke_dataflow_writes)) - {_data.update({k: v}) - for k, v in nuke_dataflow_writes.items() - if k not in ["_id", "_previous"]} + log.debug("imageio_writes: `{}`".format(imageio_writes)) + for knob in imageio_writes["knobs"]: + if knob["name"] not in ["_id", "_previous"]: + _data.update({knob["name"]: knob["value"]}) _data = avalon.nuke.lib.fix_data_for_node_create(_data) @@ -694,7 +723,7 @@ class WorkfileSettings(object): log.error(msg) return - from avalon.nuke import get_avalon_knob_data + from avalon.nuke import read for node in nuke.allNodes(): @@ -702,7 +731,7 @@ class WorkfileSettings(object): continue # get data from avalon knob - avalon_knob_data = get_avalon_knob_data(node, ["avalon:", "ak:"]) + avalon_knob_data = read(node, ["avalon:", "ak:"]) if not avalon_knob_data: continue @@ -1051,7 +1080,7 @@ def get_write_node_template_attr(node): ''' # get avalon data from node data = dict() - data['avalon'] = avalon.nuke.get_avalon_knob_data( + data['avalon'] = avalon.nuke.read( node, ['avalon:', 'ak:']) data_preset = { "class": data['avalon']['family'], diff --git a/pype/hosts/nuke/api/plugin.py b/pype/hosts/nuke/api/plugin.py new file mode 100644 index 0000000000..1d8d137156 --- /dev/null +++ b/pype/hosts/nuke/api/plugin.py @@ -0,0 +1,27 @@ +import re +import avalon.api +import avalon.nuke +from pype.api import get_current_project_settings +from .lib import check_subsetname_exists + +import nuke + +class PypeCreator(avalon.nuke.pipeline.Creator): + """Pype Nuke Creator class wrapper + """ + def __init__(self, *args, **kwargs): + super(PypeCreator, self).__init__(*args, **kwargs) + self.presets = get_current_project_settings()["nuke"]["create"].get( + self.__class__.__name__, {} + ) + if check_subsetname_exists( + nuke.allNodes(), + self.data["subset"]): + msg = "The subset name `{0}` is already used on a node in" \ + "this workfile.".format(self.data["subset"]) + self.log.error(msg + '\n\nPlease use other subset name!') + raise NameError("`{0}: {1}".format(__name__, msg)) + return + + + diff --git a/pype/hosts/nuke/plugin.py b/pype/hosts/nuke/plugin.py deleted file mode 100644 index 5d00b19ec5..0000000000 --- a/pype/hosts/nuke/plugin.py +++ /dev/null @@ -1,13 +0,0 @@ -import re -import avalon.api -import avalon.nuke -from pype.api import get_current_project_settings - -class PypeCreator(avalon.nuke.pipeline.Creator): - """Pype Nuke Creator class wrapper - """ - def __init__(self, *args, **kwargs): - super(PypeCreator, self).__init__(*args, **kwargs) - self.presets = get_current_project_settings()["nuke"]["create"].get( - self.__class__.__name__, {} - ) From 8ae983d06aad7e204f1bbb6705689431e01e6a40 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:45:28 +0100 Subject: [PATCH 11/44] move nuke to nuke.api --- pype/hosts/nuke/{ => api}/actions.py | 2 +- pype/hosts/nuke/{ => api}/menu.py | 14 ++++++-------- pype/hosts/nuke/{ => api}/utils.py | 0 3 files changed, 7 insertions(+), 9 deletions(-) rename pype/hosts/nuke/{ => api}/actions.py (96%) rename pype/hosts/nuke/{ => api}/menu.py (83%) rename pype/hosts/nuke/{ => api}/utils.py (100%) diff --git a/pype/hosts/nuke/actions.py b/pype/hosts/nuke/api/actions.py similarity index 96% rename from pype/hosts/nuke/actions.py rename to pype/hosts/nuke/api/actions.py index 23242262c8..f5d5ffb143 100644 --- a/pype/hosts/nuke/actions.py +++ b/pype/hosts/nuke/api/actions.py @@ -5,7 +5,7 @@ from avalon.nuke.lib import ( select_nodes ) -from ...action import get_errored_instances_from_context +from pype.api import get_errored_instances_from_context class SelectInvalidAction(pyblish.api.Action): diff --git a/pype/hosts/nuke/menu.py b/pype/hosts/nuke/api/menu.py similarity index 83% rename from pype/hosts/nuke/menu.py rename to pype/hosts/nuke/api/menu.py index b1ef7f47c4..7bebbeeefc 100644 --- a/pype/hosts/nuke/menu.py +++ b/pype/hosts/nuke/api/menu.py @@ -1,9 +1,8 @@ import nuke from avalon.api import Session -from pype.hosts.nuke import lib -from ...lib import BuildWorkfile -from pype.api import Logger +from .lib import WorkfileSettings +from pype.api import Logger, BuildWorkfile log = Logger().get_logger(__name__, "nuke") @@ -11,7 +10,6 @@ log = Logger().get_logger(__name__, "nuke") def install(): menubar = nuke.menu("Nuke") menu = menubar.findItem(Session["AVALON_LABEL"]) - workfile_settings = lib.WorkfileSettings # replace reset resolution from avalon core to pype's name = "Reset Resolution" new_name = "Set Resolution" @@ -24,7 +22,7 @@ def install(): menu.removeItem(rm_item[1].name()) menu.addCommand( new_name, - lambda: workfile_settings().reset_resolution(), + lambda: WorkfileSettings().reset_resolution(), index=(rm_item[0]) ) @@ -39,14 +37,14 @@ def install(): menu.removeItem(rm_item[1].name()) menu.addCommand( new_name, - lambda: workfile_settings().reset_frame_range_handles(), + lambda: WorkfileSettings().reset_frame_range_handles(), index=(rm_item[0]) ) # add colorspace menu item name = "Set Colorspace" menu.addCommand( - name, lambda: workfile_settings().set_colorspace(), + name, lambda: WorkfileSettings().set_colorspace(), index=(rm_item[0] + 2) ) log.debug("Adding menu item: {}".format(name)) @@ -63,7 +61,7 @@ def install(): name = "Apply All Settings" menu.addCommand( name, - lambda: workfile_settings().set_context_settings(), + lambda: WorkfileSettings().set_context_settings(), index=(rm_item[0] + 3) ) log.debug("Adding menu item: {}".format(name)) diff --git a/pype/hosts/nuke/utils.py b/pype/hosts/nuke/api/utils.py similarity index 100% rename from pype/hosts/nuke/utils.py rename to pype/hosts/nuke/api/utils.py From e76fb5e8979ff65bf029e344c45e6f31f8ab20ce Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:46:15 +0100 Subject: [PATCH 12/44] temporarily point avalon-core to wip branch --- repos/avalon-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/avalon-core b/repos/avalon-core index 67270d7430..c78e83d4b8 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit 67270d74304cf2dc86c9ea67b50c5524c259b019 +Subproject commit c78e83d4b8e6b409dbe5aafe5a7ec7725cb88145 From 367b0649f0203c6ca1483fd1538d81d7b1ca3f0c Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 12:47:12 +0100 Subject: [PATCH 13/44] move nuke to nuke.api and temp disable onscript callbacks --- setup/nuke/nuke_path/menu.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup/nuke/nuke_path/menu.py b/setup/nuke/nuke_path/menu.py index d9341045a9..3cfae8c7b1 100644 --- a/setup/nuke/nuke_path/menu.py +++ b/setup/nuke/nuke_path/menu.py @@ -2,7 +2,7 @@ import os import sys import KnobScripter -from pype.hosts.nuke.lib import ( +from pype.hosts.nuke.api.lib import ( writes_version_sync, on_script_load, check_inventory_versions @@ -14,10 +14,10 @@ from pype.api import Logger log = Logger().get_logger(__name__, "nuke") -# nuke.addOnScriptSave(writes_version_sync) -nuke.addOnScriptSave(on_script_load) -nuke.addOnScriptLoad(check_inventory_versions) -nuke.addOnScriptSave(check_inventory_versions) -# nuke.addOnScriptSave(writes_version_sync) +# nuke.addOnScriptSave(lib.writes_version_sync) +# nuke.addOnScriptSave(lib.on_script_load) +# nuke.addOnScriptLoad(lib.check_inventory_versions) +# nuke.addOnScriptSave(lib.check_inventory_versions) +# nuke.addOnScriptSave(lib.writes_version_sync) log.info('Automatic syncing of write file knob to script version') From fa6d0c395ae427d800fa96a74cb96db7074379da Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 14:25:27 +0100 Subject: [PATCH 14/44] load colorspace from anatomy settings --- pype/hosts/nuke/api/lib.py | 18 ++++++++++ pype/plugins/nuke/load/load_image.py | 15 +++------ pype/plugins/nuke/load/load_luts_ip.py | 2 +- pype/plugins/nuke/load/load_mov.py | 44 +++++++++++-------------- pype/plugins/nuke/load/load_sequence.py | 16 ++++----- 5 files changed, 49 insertions(+), 46 deletions(-) diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index a42f27226e..67f51daad5 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -57,6 +57,24 @@ def get_node_imageio_setting(**kwarg): return imageio_node +def get_imageio_input_colorspace(filename): + ''' Get input file colorspace based on regex in settings. + ''' + imageio_regex_inputs = (get_anatomy_settings(os.getenv("AVALON_PROJECT")) + ["imageio"] + ["nuke"] + ["regexInputs"] + ["inputs"] + ) + + preset_clrsp = None + for regexInput in imageio_regex_inputs: + if bool(re.search(regexInput["regex"], filename)): + preset_clrsp = str(regexInput["colorspace"]) + + return preset_clrsp + + def on_script_load(): ''' Callback for ffmpeg support ''' diff --git a/pype/plugins/nuke/load/load_image.py b/pype/plugins/nuke/load/load_image.py index 377d52aa14..ac54a90bc0 100644 --- a/pype/plugins/nuke/load/load_image.py +++ b/pype/plugins/nuke/load/load_image.py @@ -4,7 +4,9 @@ import nuke from avalon.vendor import qargparse from avalon import api, io -from pype.hosts.nuke import presets +from pype.hosts.nuke.api.lib import ( + get_imageio_input_colorspace +) class LoadImage(api.Loader): @@ -90,17 +92,10 @@ class LoadImage(api.Loader): if colorspace: r["colorspace"].setValue(str(colorspace)) - # load nuke presets for Read's colorspace - read_clrs_presets = presets.get_colorspace_preset().get( - "nuke", {}).get("read", {}) + preset_clrsp = get_imageio_input_colorspace(file) - # check if any colorspace presets for read is mathing - preset_clrsp = next((read_clrs_presets[k] - for k in read_clrs_presets - if bool(re.search(k, file))), - None) if preset_clrsp is not None: - r["colorspace"].setValue(str(preset_clrsp)) + r["colorspace"].setValue(preset_clrsp) r["origfirst"].setValue(first) r["first"].setValue(first) diff --git a/pype/plugins/nuke/load/load_luts_ip.py b/pype/plugins/nuke/load/load_luts_ip.py index 241e077659..1e2469055f 100644 --- a/pype/plugins/nuke/load/load_luts_ip.py +++ b/pype/plugins/nuke/load/load_luts_ip.py @@ -2,7 +2,7 @@ from avalon import api, style, io import nuke import json from collections import OrderedDict -from pype.hosts.nuke import lib +from pype.hosts.nuke.api import lib class LoadLutsInputProcess(api.Loader): diff --git a/pype/plugins/nuke/load/load_mov.py b/pype/plugins/nuke/load/load_mov.py index 104f59d5be..95bd780896 100644 --- a/pype/plugins/nuke/load/load_mov.py +++ b/pype/plugins/nuke/load/load_mov.py @@ -3,8 +3,11 @@ import nuke import contextlib from avalon import api, io -from pype.hosts.nuke import presets -from pype.api import get_project_settings +from pype.api import get_current_project_settings +from pype.hosts.nuke.api.lib import ( + get_imageio_input_colorspace +) + @contextlib.contextmanager @@ -73,12 +76,17 @@ def add_review_presets_config(): "families": list(), "representations": list() } - settings = get_project_settings(io.Session["AVALON_PROJECT"]) - review_presets = settings["global"]["publish"].get( - "ExtractReview", {}) + settings = get_current_project_settings() + review_profiles = (settings["global"] + ["publish"] + ["ExtractReview"] + ["profiles"] + ) - outputs = review_presets.get("outputs", {}) - # + outputs = {} + for profile in review_profiles: + outputs.update(profile.get("outputs", {})) + for output, properities in outputs.items(): returning["representations"].append(output) returning["families"] += properities.get("families", []) @@ -175,17 +183,10 @@ class LoadMov(api.Loader): if colorspace: read_node["colorspace"].setValue(str(colorspace)) - # load nuke presets for Read's colorspace - read_clrs_presets = presets.get_colorspace_preset().get( - "nuke", {}).get("read", {}) + preset_clrsp = get_imageio_input_colorspace(file) - # check if any colorspace presets for read is mathing - preset_clrsp = next((read_clrs_presets[k] - for k in read_clrs_presets - if bool(re.search(k, file))), - None) if preset_clrsp is not None: - read_node["colorspace"].setValue(str(preset_clrsp)) + read_node["colorspace"].setValue(preset_clrsp) # add additional metadata from the version to imprint Avalon knob add_keys = [ @@ -309,17 +310,10 @@ class LoadMov(api.Loader): if colorspace: node["colorspace"].setValue(str(colorspace)) - # load nuke presets for Read's colorspace - read_clrs_presets = presets.get_colorspace_preset().get( - "nuke", {}).get("read", {}) + preset_clrsp = get_imageio_input_colorspace(file) - # check if any colorspace presets for read is mathing - preset_clrsp = next((read_clrs_presets[k] - for k in read_clrs_presets - if bool(re.search(k, file))), - None) if preset_clrsp is not None: - node["colorspace"].setValue(str(preset_clrsp)) + r["colorspace"].setValue(preset_clrsp) updated_dict = {} updated_dict.update({ diff --git a/pype/plugins/nuke/load/load_sequence.py b/pype/plugins/nuke/load/load_sequence.py index 411aec6ad6..e3c0202395 100644 --- a/pype/plugins/nuke/load/load_sequence.py +++ b/pype/plugins/nuke/load/load_sequence.py @@ -1,9 +1,12 @@ import re +import os import nuke import contextlib from avalon import api, io -from pype.hosts.nuke import presets +from pype.hosts.nuke.api.lib import ( + get_imageio_input_colorspace +) @contextlib.contextmanager @@ -142,17 +145,10 @@ class LoadSequence(api.Loader): if colorspace: r["colorspace"].setValue(str(colorspace)) - # load nuke presets for Read's colorspace - read_clrs_presets = presets.get_colorspace_preset().get( - "nuke", {}).get("read", {}) + preset_clrsp = get_imageio_input_colorspace(file) - # check if any colorspace presets for read is mathing - preset_clrsp = next((read_clrs_presets[k] - for k in read_clrs_presets - if bool(re.search(k, file))), - None) if preset_clrsp is not None: - r["colorspace"].setValue(str(preset_clrsp)) + r["colorspace"].setValue(preset_clrsp) loader_shift(r, first, relative=True) r["origfirst"].setValue(int(first)) From 061cd28ee3b382e1411ca814dda17f52a795fd74 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 16:54:22 +0100 Subject: [PATCH 15/44] consolidate nuke host to a single host folder --- pype/hosts/nuke/api/__init__.py | 19 +++++++++++-------- .../nuke/plugins}/create/create_backdrop.py | 0 .../nuke/plugins}/create/create_camera.py | 0 .../nuke/plugins}/create/create_gizmo.py | 0 .../nuke/plugins}/create/create_read.py | 0 .../plugins}/create/create_write_prerender.py | 0 .../plugins}/create/create_write_render.py | 0 .../plugins}/inventory/select_containers.py | 0 .../nuke/plugins}/inventory/set_tool_color.py | 0 .../nuke/plugins}/load/actions.py | 0 .../nuke/plugins}/load/load_backdrop.py | 0 .../nuke/plugins}/load/load_camera_abc.py | 0 .../nuke/plugins}/load/load_gizmo.py | 0 .../nuke/plugins}/load/load_gizmo_ip.py | 0 .../nuke/plugins}/load/load_image.py | 0 .../nuke/plugins}/load/load_luts.py | 0 .../nuke/plugins}/load/load_luts_ip.py | 0 .../nuke/plugins}/load/load_matchmove.py | 0 .../nuke/plugins}/load/load_mov.py | 0 .../nuke/plugins}/load/load_script_precomp.py | 0 .../nuke/plugins}/load/load_sequence.py | 0 .../nuke/plugins}/publish/collect_backdrop.py | 0 .../plugins}/publish/collect_current_file.py | 0 .../plugins}/publish/collect_framerate.py | 0 .../nuke/plugins}/publish/collect_gizmo.py | 0 .../nuke/plugins}/publish/collect_host.py | 0 .../plugins}/publish/collect_host_version.py | 0 .../plugins}/publish/collect_instances.py | 0 .../plugins}/publish/collect_legacy_read.py | 0 .../nuke/plugins}/publish/collect_reads.py | 0 .../nuke/plugins}/publish/collect_review.py | 0 .../plugins}/publish/collect_selection.py | 0 .../plugins}/publish/collect_slate_node.py | 0 .../nuke/plugins}/publish/collect_workfile.py | 0 .../nuke/plugins}/publish/collect_writes.py | 0 .../nuke/plugins}/publish/extract_backdrop.py | 0 .../nuke/plugins}/publish/extract_camera.py | 0 .../nuke/plugins}/publish/extract_gizmo.py | 0 .../plugins}/publish/extract_ouput_node.py | 0 .../publish/extract_output_directory.py | 0 .../plugins}/publish/extract_render_local.py | 0 .../publish/extract_review_data_lut.py | 0 .../publish/extract_review_data_mov.py | 0 .../plugins}/publish/extract_script_save.py | 0 .../plugins}/publish/extract_slate_frame.py | 0 .../plugins}/publish/extract_thumbnail.py | 0 .../publish/increment_script_version.py | 0 .../plugins}/publish/remove_ouput_node.py | 0 .../plugins}/publish/submit_nuke_deadline.py | 0 .../plugins}/publish/validate_backdrop.py | 0 .../nuke/plugins}/publish/validate_gizmo.py | 0 .../nuke/plugins}/publish/validate_knobs.py | 0 .../publish/validate_output_resolution.py | 0 .../plugins}/publish/validate_read_legacy.py | 0 .../publish/validate_rendered_frames.py | 0 .../nuke/plugins}/publish/validate_script.py | 0 .../publish/validate_write_bounding_box.py | 0 .../publish/validate_write_deadline_tab.py | 0 .../plugins}/publish/validate_write_legacy.py | 0 .../plugins}/publish/validate_write_nodes.py | 0 60 files changed, 11 insertions(+), 8 deletions(-) rename pype/{plugins/nuke => hosts/nuke/plugins}/create/create_backdrop.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/create/create_camera.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/create/create_gizmo.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/create/create_read.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/create/create_write_prerender.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/create/create_write_render.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/inventory/select_containers.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/inventory/set_tool_color.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/actions.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_backdrop.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_camera_abc.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_gizmo.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_gizmo_ip.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_image.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_luts.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_luts_ip.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_matchmove.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_mov.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_script_precomp.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/load/load_sequence.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_backdrop.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_current_file.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_framerate.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_gizmo.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_host.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_host_version.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_instances.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_legacy_read.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_reads.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_review.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_selection.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_slate_node.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_workfile.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/collect_writes.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_backdrop.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_camera.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_gizmo.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_ouput_node.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_output_directory.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_render_local.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_review_data_lut.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_review_data_mov.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_script_save.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_slate_frame.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/extract_thumbnail.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/increment_script_version.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/remove_ouput_node.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/submit_nuke_deadline.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_backdrop.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_gizmo.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_knobs.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_output_resolution.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_read_legacy.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_rendered_frames.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_script.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_write_bounding_box.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_write_deadline_tab.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_write_legacy.py (100%) rename pype/{plugins/nuke => hosts/nuke/plugins}/publish/validate_write_nodes.py (100%) diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py index 87c3e190e2..22085af37c 100644 --- a/pype/hosts/nuke/api/__init__.py +++ b/pype/hosts/nuke/api/__init__.py @@ -8,6 +8,7 @@ from avalon import api as avalon from avalon.tools import workfiles from pyblish import api as pyblish from pype.api import Logger +from pype.hosts import nuke from pype import PLUGINS_DIR from . import lib, menu @@ -18,10 +19,12 @@ log = Logger().get_logger(__name__, "nuke") AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") -PUBLISH_PATH = os.path.join(PLUGINS_DIR, "nuke", "publish") -LOAD_PATH = os.path.join(PLUGINS_DIR, "nuke", "load") -CREATE_PATH = os.path.join(PLUGINS_DIR, "nuke", "create") -INVENTORY_PATH = os.path.join(PLUGINS_DIR, "nuke", "inventory") +HOST_DIR = os.path.dirname(os.path.abspath(nuke.__file__)) +PLUGINS_DIR = os.path.join(HOST_DIR, "plugins") +PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish") +LOAD_PATH = os.path.join(PLUGINS_DIR, "load") +CREATE_PATH = os.path.join(PLUGINS_DIR, "create") +INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") # registering pyblish gui regarding settings in presets @@ -40,10 +43,10 @@ def reload_config(): for module in ( "{}.api".format(AVALON_CONFIG), - "{}.hosts.nuke.actions".format(AVALON_CONFIG), - "{}.hosts.nuke.menu".format(AVALON_CONFIG), - "{}.hosts.nuke.plugin".format(AVALON_CONFIG), - "{}.hosts.nuke.lib".format(AVALON_CONFIG), + "{}.hosts.nuke.api.actions".format(AVALON_CONFIG), + "{}.hosts.nuke.api.menu".format(AVALON_CONFIG), + "{}.hosts.nuke.api.plugin".format(AVALON_CONFIG), + "{}.hosts.nuke.api.lib".format(AVALON_CONFIG), ): log.info("Reloading module: {}...".format(module)) diff --git a/pype/plugins/nuke/create/create_backdrop.py b/pype/hosts/nuke/plugins/create/create_backdrop.py similarity index 100% rename from pype/plugins/nuke/create/create_backdrop.py rename to pype/hosts/nuke/plugins/create/create_backdrop.py diff --git a/pype/plugins/nuke/create/create_camera.py b/pype/hosts/nuke/plugins/create/create_camera.py similarity index 100% rename from pype/plugins/nuke/create/create_camera.py rename to pype/hosts/nuke/plugins/create/create_camera.py diff --git a/pype/plugins/nuke/create/create_gizmo.py b/pype/hosts/nuke/plugins/create/create_gizmo.py similarity index 100% rename from pype/plugins/nuke/create/create_gizmo.py rename to pype/hosts/nuke/plugins/create/create_gizmo.py diff --git a/pype/plugins/nuke/create/create_read.py b/pype/hosts/nuke/plugins/create/create_read.py similarity index 100% rename from pype/plugins/nuke/create/create_read.py rename to pype/hosts/nuke/plugins/create/create_read.py diff --git a/pype/plugins/nuke/create/create_write_prerender.py b/pype/hosts/nuke/plugins/create/create_write_prerender.py similarity index 100% rename from pype/plugins/nuke/create/create_write_prerender.py rename to pype/hosts/nuke/plugins/create/create_write_prerender.py diff --git a/pype/plugins/nuke/create/create_write_render.py b/pype/hosts/nuke/plugins/create/create_write_render.py similarity index 100% rename from pype/plugins/nuke/create/create_write_render.py rename to pype/hosts/nuke/plugins/create/create_write_render.py diff --git a/pype/plugins/nuke/inventory/select_containers.py b/pype/hosts/nuke/plugins/inventory/select_containers.py similarity index 100% rename from pype/plugins/nuke/inventory/select_containers.py rename to pype/hosts/nuke/plugins/inventory/select_containers.py diff --git a/pype/plugins/nuke/inventory/set_tool_color.py b/pype/hosts/nuke/plugins/inventory/set_tool_color.py similarity index 100% rename from pype/plugins/nuke/inventory/set_tool_color.py rename to pype/hosts/nuke/plugins/inventory/set_tool_color.py diff --git a/pype/plugins/nuke/load/actions.py b/pype/hosts/nuke/plugins/load/actions.py similarity index 100% rename from pype/plugins/nuke/load/actions.py rename to pype/hosts/nuke/plugins/load/actions.py diff --git a/pype/plugins/nuke/load/load_backdrop.py b/pype/hosts/nuke/plugins/load/load_backdrop.py similarity index 100% rename from pype/plugins/nuke/load/load_backdrop.py rename to pype/hosts/nuke/plugins/load/load_backdrop.py diff --git a/pype/plugins/nuke/load/load_camera_abc.py b/pype/hosts/nuke/plugins/load/load_camera_abc.py similarity index 100% rename from pype/plugins/nuke/load/load_camera_abc.py rename to pype/hosts/nuke/plugins/load/load_camera_abc.py diff --git a/pype/plugins/nuke/load/load_gizmo.py b/pype/hosts/nuke/plugins/load/load_gizmo.py similarity index 100% rename from pype/plugins/nuke/load/load_gizmo.py rename to pype/hosts/nuke/plugins/load/load_gizmo.py diff --git a/pype/plugins/nuke/load/load_gizmo_ip.py b/pype/hosts/nuke/plugins/load/load_gizmo_ip.py similarity index 100% rename from pype/plugins/nuke/load/load_gizmo_ip.py rename to pype/hosts/nuke/plugins/load/load_gizmo_ip.py diff --git a/pype/plugins/nuke/load/load_image.py b/pype/hosts/nuke/plugins/load/load_image.py similarity index 100% rename from pype/plugins/nuke/load/load_image.py rename to pype/hosts/nuke/plugins/load/load_image.py diff --git a/pype/plugins/nuke/load/load_luts.py b/pype/hosts/nuke/plugins/load/load_luts.py similarity index 100% rename from pype/plugins/nuke/load/load_luts.py rename to pype/hosts/nuke/plugins/load/load_luts.py diff --git a/pype/plugins/nuke/load/load_luts_ip.py b/pype/hosts/nuke/plugins/load/load_luts_ip.py similarity index 100% rename from pype/plugins/nuke/load/load_luts_ip.py rename to pype/hosts/nuke/plugins/load/load_luts_ip.py diff --git a/pype/plugins/nuke/load/load_matchmove.py b/pype/hosts/nuke/plugins/load/load_matchmove.py similarity index 100% rename from pype/plugins/nuke/load/load_matchmove.py rename to pype/hosts/nuke/plugins/load/load_matchmove.py diff --git a/pype/plugins/nuke/load/load_mov.py b/pype/hosts/nuke/plugins/load/load_mov.py similarity index 100% rename from pype/plugins/nuke/load/load_mov.py rename to pype/hosts/nuke/plugins/load/load_mov.py diff --git a/pype/plugins/nuke/load/load_script_precomp.py b/pype/hosts/nuke/plugins/load/load_script_precomp.py similarity index 100% rename from pype/plugins/nuke/load/load_script_precomp.py rename to pype/hosts/nuke/plugins/load/load_script_precomp.py diff --git a/pype/plugins/nuke/load/load_sequence.py b/pype/hosts/nuke/plugins/load/load_sequence.py similarity index 100% rename from pype/plugins/nuke/load/load_sequence.py rename to pype/hosts/nuke/plugins/load/load_sequence.py diff --git a/pype/plugins/nuke/publish/collect_backdrop.py b/pype/hosts/nuke/plugins/publish/collect_backdrop.py similarity index 100% rename from pype/plugins/nuke/publish/collect_backdrop.py rename to pype/hosts/nuke/plugins/publish/collect_backdrop.py diff --git a/pype/plugins/nuke/publish/collect_current_file.py b/pype/hosts/nuke/plugins/publish/collect_current_file.py similarity index 100% rename from pype/plugins/nuke/publish/collect_current_file.py rename to pype/hosts/nuke/plugins/publish/collect_current_file.py diff --git a/pype/plugins/nuke/publish/collect_framerate.py b/pype/hosts/nuke/plugins/publish/collect_framerate.py similarity index 100% rename from pype/plugins/nuke/publish/collect_framerate.py rename to pype/hosts/nuke/plugins/publish/collect_framerate.py diff --git a/pype/plugins/nuke/publish/collect_gizmo.py b/pype/hosts/nuke/plugins/publish/collect_gizmo.py similarity index 100% rename from pype/plugins/nuke/publish/collect_gizmo.py rename to pype/hosts/nuke/plugins/publish/collect_gizmo.py diff --git a/pype/plugins/nuke/publish/collect_host.py b/pype/hosts/nuke/plugins/publish/collect_host.py similarity index 100% rename from pype/plugins/nuke/publish/collect_host.py rename to pype/hosts/nuke/plugins/publish/collect_host.py diff --git a/pype/plugins/nuke/publish/collect_host_version.py b/pype/hosts/nuke/plugins/publish/collect_host_version.py similarity index 100% rename from pype/plugins/nuke/publish/collect_host_version.py rename to pype/hosts/nuke/plugins/publish/collect_host_version.py diff --git a/pype/plugins/nuke/publish/collect_instances.py b/pype/hosts/nuke/plugins/publish/collect_instances.py similarity index 100% rename from pype/plugins/nuke/publish/collect_instances.py rename to pype/hosts/nuke/plugins/publish/collect_instances.py diff --git a/pype/plugins/nuke/publish/collect_legacy_read.py b/pype/hosts/nuke/plugins/publish/collect_legacy_read.py similarity index 100% rename from pype/plugins/nuke/publish/collect_legacy_read.py rename to pype/hosts/nuke/plugins/publish/collect_legacy_read.py diff --git a/pype/plugins/nuke/publish/collect_reads.py b/pype/hosts/nuke/plugins/publish/collect_reads.py similarity index 100% rename from pype/plugins/nuke/publish/collect_reads.py rename to pype/hosts/nuke/plugins/publish/collect_reads.py diff --git a/pype/plugins/nuke/publish/collect_review.py b/pype/hosts/nuke/plugins/publish/collect_review.py similarity index 100% rename from pype/plugins/nuke/publish/collect_review.py rename to pype/hosts/nuke/plugins/publish/collect_review.py diff --git a/pype/plugins/nuke/publish/collect_selection.py b/pype/hosts/nuke/plugins/publish/collect_selection.py similarity index 100% rename from pype/plugins/nuke/publish/collect_selection.py rename to pype/hosts/nuke/plugins/publish/collect_selection.py diff --git a/pype/plugins/nuke/publish/collect_slate_node.py b/pype/hosts/nuke/plugins/publish/collect_slate_node.py similarity index 100% rename from pype/plugins/nuke/publish/collect_slate_node.py rename to pype/hosts/nuke/plugins/publish/collect_slate_node.py diff --git a/pype/plugins/nuke/publish/collect_workfile.py b/pype/hosts/nuke/plugins/publish/collect_workfile.py similarity index 100% rename from pype/plugins/nuke/publish/collect_workfile.py rename to pype/hosts/nuke/plugins/publish/collect_workfile.py diff --git a/pype/plugins/nuke/publish/collect_writes.py b/pype/hosts/nuke/plugins/publish/collect_writes.py similarity index 100% rename from pype/plugins/nuke/publish/collect_writes.py rename to pype/hosts/nuke/plugins/publish/collect_writes.py diff --git a/pype/plugins/nuke/publish/extract_backdrop.py b/pype/hosts/nuke/plugins/publish/extract_backdrop.py similarity index 100% rename from pype/plugins/nuke/publish/extract_backdrop.py rename to pype/hosts/nuke/plugins/publish/extract_backdrop.py diff --git a/pype/plugins/nuke/publish/extract_camera.py b/pype/hosts/nuke/plugins/publish/extract_camera.py similarity index 100% rename from pype/plugins/nuke/publish/extract_camera.py rename to pype/hosts/nuke/plugins/publish/extract_camera.py diff --git a/pype/plugins/nuke/publish/extract_gizmo.py b/pype/hosts/nuke/plugins/publish/extract_gizmo.py similarity index 100% rename from pype/plugins/nuke/publish/extract_gizmo.py rename to pype/hosts/nuke/plugins/publish/extract_gizmo.py diff --git a/pype/plugins/nuke/publish/extract_ouput_node.py b/pype/hosts/nuke/plugins/publish/extract_ouput_node.py similarity index 100% rename from pype/plugins/nuke/publish/extract_ouput_node.py rename to pype/hosts/nuke/plugins/publish/extract_ouput_node.py diff --git a/pype/plugins/nuke/publish/extract_output_directory.py b/pype/hosts/nuke/plugins/publish/extract_output_directory.py similarity index 100% rename from pype/plugins/nuke/publish/extract_output_directory.py rename to pype/hosts/nuke/plugins/publish/extract_output_directory.py diff --git a/pype/plugins/nuke/publish/extract_render_local.py b/pype/hosts/nuke/plugins/publish/extract_render_local.py similarity index 100% rename from pype/plugins/nuke/publish/extract_render_local.py rename to pype/hosts/nuke/plugins/publish/extract_render_local.py diff --git a/pype/plugins/nuke/publish/extract_review_data_lut.py b/pype/hosts/nuke/plugins/publish/extract_review_data_lut.py similarity index 100% rename from pype/plugins/nuke/publish/extract_review_data_lut.py rename to pype/hosts/nuke/plugins/publish/extract_review_data_lut.py diff --git a/pype/plugins/nuke/publish/extract_review_data_mov.py b/pype/hosts/nuke/plugins/publish/extract_review_data_mov.py similarity index 100% rename from pype/plugins/nuke/publish/extract_review_data_mov.py rename to pype/hosts/nuke/plugins/publish/extract_review_data_mov.py diff --git a/pype/plugins/nuke/publish/extract_script_save.py b/pype/hosts/nuke/plugins/publish/extract_script_save.py similarity index 100% rename from pype/plugins/nuke/publish/extract_script_save.py rename to pype/hosts/nuke/plugins/publish/extract_script_save.py diff --git a/pype/plugins/nuke/publish/extract_slate_frame.py b/pype/hosts/nuke/plugins/publish/extract_slate_frame.py similarity index 100% rename from pype/plugins/nuke/publish/extract_slate_frame.py rename to pype/hosts/nuke/plugins/publish/extract_slate_frame.py diff --git a/pype/plugins/nuke/publish/extract_thumbnail.py b/pype/hosts/nuke/plugins/publish/extract_thumbnail.py similarity index 100% rename from pype/plugins/nuke/publish/extract_thumbnail.py rename to pype/hosts/nuke/plugins/publish/extract_thumbnail.py diff --git a/pype/plugins/nuke/publish/increment_script_version.py b/pype/hosts/nuke/plugins/publish/increment_script_version.py similarity index 100% rename from pype/plugins/nuke/publish/increment_script_version.py rename to pype/hosts/nuke/plugins/publish/increment_script_version.py diff --git a/pype/plugins/nuke/publish/remove_ouput_node.py b/pype/hosts/nuke/plugins/publish/remove_ouput_node.py similarity index 100% rename from pype/plugins/nuke/publish/remove_ouput_node.py rename to pype/hosts/nuke/plugins/publish/remove_ouput_node.py diff --git a/pype/plugins/nuke/publish/submit_nuke_deadline.py b/pype/hosts/nuke/plugins/publish/submit_nuke_deadline.py similarity index 100% rename from pype/plugins/nuke/publish/submit_nuke_deadline.py rename to pype/hosts/nuke/plugins/publish/submit_nuke_deadline.py diff --git a/pype/plugins/nuke/publish/validate_backdrop.py b/pype/hosts/nuke/plugins/publish/validate_backdrop.py similarity index 100% rename from pype/plugins/nuke/publish/validate_backdrop.py rename to pype/hosts/nuke/plugins/publish/validate_backdrop.py diff --git a/pype/plugins/nuke/publish/validate_gizmo.py b/pype/hosts/nuke/plugins/publish/validate_gizmo.py similarity index 100% rename from pype/plugins/nuke/publish/validate_gizmo.py rename to pype/hosts/nuke/plugins/publish/validate_gizmo.py diff --git a/pype/plugins/nuke/publish/validate_knobs.py b/pype/hosts/nuke/plugins/publish/validate_knobs.py similarity index 100% rename from pype/plugins/nuke/publish/validate_knobs.py rename to pype/hosts/nuke/plugins/publish/validate_knobs.py diff --git a/pype/plugins/nuke/publish/validate_output_resolution.py b/pype/hosts/nuke/plugins/publish/validate_output_resolution.py similarity index 100% rename from pype/plugins/nuke/publish/validate_output_resolution.py rename to pype/hosts/nuke/plugins/publish/validate_output_resolution.py diff --git a/pype/plugins/nuke/publish/validate_read_legacy.py b/pype/hosts/nuke/plugins/publish/validate_read_legacy.py similarity index 100% rename from pype/plugins/nuke/publish/validate_read_legacy.py rename to pype/hosts/nuke/plugins/publish/validate_read_legacy.py diff --git a/pype/plugins/nuke/publish/validate_rendered_frames.py b/pype/hosts/nuke/plugins/publish/validate_rendered_frames.py similarity index 100% rename from pype/plugins/nuke/publish/validate_rendered_frames.py rename to pype/hosts/nuke/plugins/publish/validate_rendered_frames.py diff --git a/pype/plugins/nuke/publish/validate_script.py b/pype/hosts/nuke/plugins/publish/validate_script.py similarity index 100% rename from pype/plugins/nuke/publish/validate_script.py rename to pype/hosts/nuke/plugins/publish/validate_script.py diff --git a/pype/plugins/nuke/publish/validate_write_bounding_box.py b/pype/hosts/nuke/plugins/publish/validate_write_bounding_box.py similarity index 100% rename from pype/plugins/nuke/publish/validate_write_bounding_box.py rename to pype/hosts/nuke/plugins/publish/validate_write_bounding_box.py diff --git a/pype/plugins/nuke/publish/validate_write_deadline_tab.py b/pype/hosts/nuke/plugins/publish/validate_write_deadline_tab.py similarity index 100% rename from pype/plugins/nuke/publish/validate_write_deadline_tab.py rename to pype/hosts/nuke/plugins/publish/validate_write_deadline_tab.py diff --git a/pype/plugins/nuke/publish/validate_write_legacy.py b/pype/hosts/nuke/plugins/publish/validate_write_legacy.py similarity index 100% rename from pype/plugins/nuke/publish/validate_write_legacy.py rename to pype/hosts/nuke/plugins/publish/validate_write_legacy.py diff --git a/pype/plugins/nuke/publish/validate_write_nodes.py b/pype/hosts/nuke/plugins/publish/validate_write_nodes.py similarity index 100% rename from pype/plugins/nuke/publish/validate_write_nodes.py rename to pype/hosts/nuke/plugins/publish/validate_write_nodes.py From 694a90c6892d89a978013c9abdf834d3113b5963 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 17:02:53 +0100 Subject: [PATCH 16/44] move nuke setup to host --- .../hosts/nuke/startup}/KnobScripter/__init__.py | 0 .../KnobScripter/icons/icon_clearConsole.png | Bin .../startup}/KnobScripter/icons/icon_download.png | Bin .../startup}/KnobScripter/icons/icon_exitnode.png | Bin .../nuke/startup}/KnobScripter/icons/icon_pick.png | Bin .../nuke/startup}/KnobScripter/icons/icon_prefs.png | Bin .../startup}/KnobScripter/icons/icon_prefs2.png | Bin .../startup}/KnobScripter/icons/icon_refresh.png | Bin .../nuke/startup}/KnobScripter/icons/icon_run.png | Bin .../nuke/startup}/KnobScripter/icons/icon_save.png | Bin .../startup}/KnobScripter/icons/icon_search.png | Bin .../startup}/KnobScripter/icons/icon_snippets.png | Bin .../nuke/startup}/KnobScripter/knob_scripter.py | 0 .../nuke_path => pype/hosts/nuke/startup}/init.py | 0 .../nuke_path => pype/hosts/nuke/startup}/menu.py | 0 .../hosts/nuke/startup}/write_to_read.py | 0 .../defaults/system_settings/applications.json | 4 ++-- pype/settings/defaults/system_settings/modules.json | 2 +- 18 files changed, 3 insertions(+), 3 deletions(-) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/__init__.py (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_clearConsole.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_download.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_exitnode.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_pick.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_prefs.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_prefs2.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_refresh.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_run.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_save.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_search.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/icons/icon_snippets.png (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/KnobScripter/knob_scripter.py (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/init.py (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/menu.py (100%) rename {setup/nuke/nuke_path => pype/hosts/nuke/startup}/write_to_read.py (100%) diff --git a/setup/nuke/nuke_path/KnobScripter/__init__.py b/pype/hosts/nuke/startup/KnobScripter/__init__.py similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/__init__.py rename to pype/hosts/nuke/startup/KnobScripter/__init__.py diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_clearConsole.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_clearConsole.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_clearConsole.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_clearConsole.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_download.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_download.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_download.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_download.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_exitnode.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_exitnode.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_exitnode.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_exitnode.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_pick.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_pick.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_pick.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_pick.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_prefs.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_prefs.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_prefs.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_prefs.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_prefs2.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_prefs2.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_prefs2.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_prefs2.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_refresh.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_refresh.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_refresh.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_refresh.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_run.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_run.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_run.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_run.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_save.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_save.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_save.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_save.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_search.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_search.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_search.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_search.png diff --git a/setup/nuke/nuke_path/KnobScripter/icons/icon_snippets.png b/pype/hosts/nuke/startup/KnobScripter/icons/icon_snippets.png similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/icons/icon_snippets.png rename to pype/hosts/nuke/startup/KnobScripter/icons/icon_snippets.png diff --git a/setup/nuke/nuke_path/KnobScripter/knob_scripter.py b/pype/hosts/nuke/startup/KnobScripter/knob_scripter.py similarity index 100% rename from setup/nuke/nuke_path/KnobScripter/knob_scripter.py rename to pype/hosts/nuke/startup/KnobScripter/knob_scripter.py diff --git a/setup/nuke/nuke_path/init.py b/pype/hosts/nuke/startup/init.py similarity index 100% rename from setup/nuke/nuke_path/init.py rename to pype/hosts/nuke/startup/init.py diff --git a/setup/nuke/nuke_path/menu.py b/pype/hosts/nuke/startup/menu.py similarity index 100% rename from setup/nuke/nuke_path/menu.py rename to pype/hosts/nuke/startup/menu.py diff --git a/setup/nuke/nuke_path/write_to_read.py b/pype/hosts/nuke/startup/write_to_read.py similarity index 100% rename from setup/nuke/nuke_path/write_to_read.py rename to pype/hosts/nuke/startup/write_to_read.py diff --git a/pype/settings/defaults/system_settings/applications.json b/pype/settings/defaults/system_settings/applications.json index 79d39c94f9..e9f6d17480 100644 --- a/pype/settings/defaults/system_settings/applications.json +++ b/pype/settings/defaults/system_settings/applications.json @@ -241,8 +241,8 @@ ] }, "NUKE_PATH": [ - "{PYPE_MODULE_ROOT}/repos/avalon-core/setup/nuke/nuke_path", - "{PYPE_MODULE_ROOT}/setup/nuke/nuke_path", + "{PYPE_ROOT}/repos/avalon-core/setup/nuke/nuke_path", + "{PYPE_ROOT}/hosts/nuke/startup", "{PYPE_STUDIO_PLUGINS}/nuke" ], "PATH": { diff --git a/pype/settings/defaults/system_settings/modules.json b/pype/settings/defaults/system_settings/modules.json index 0f4b0b37f3..488cb91827 100644 --- a/pype/settings/defaults/system_settings/modules.json +++ b/pype/settings/defaults/system_settings/modules.json @@ -153,4 +153,4 @@ "idle_manager": { "enabled": true } -} +} \ No newline at end of file From f6787c5d0bdb261298ce453f6faa60626e1634d0 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 17:58:18 +0100 Subject: [PATCH 17/44] fix nuke callbacks in 3.0 --- pype/hosts/nuke/api/__init__.py | 8 ++++---- pype/hosts/nuke/api/lib.py | 12 ++++++------ pype/hosts/nuke/startup/menu.py | 9 ++++----- .../defaults/system_settings/applications.json | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py index 22085af37c..b60f79d910 100644 --- a/pype/hosts/nuke/api/__init__.py +++ b/pype/hosts/nuke/api/__init__.py @@ -8,7 +8,7 @@ from avalon import api as avalon from avalon.tools import workfiles from pyblish import api as pyblish from pype.api import Logger -from pype.hosts import nuke +import pype.hosts.nuke from pype import PLUGINS_DIR from . import lib, menu @@ -19,7 +19,7 @@ log = Logger().get_logger(__name__, "nuke") AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") -HOST_DIR = os.path.dirname(os.path.abspath(nuke.__file__)) +HOST_DIR = os.path.dirname(os.path.abspath(pype.hosts.nuke.__file__)) PLUGINS_DIR = os.path.join(HOST_DIR, "plugins") PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish") LOAD_PATH = os.path.join(PLUGINS_DIR, "load") @@ -70,7 +70,7 @@ def install(): avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH) # Register Avalon event for workfiles loading. - # avalon.on("workio.open_file", lib.check_inventory_versions) + avalon.on("workio.open_file", lib.check_inventory_versions) # pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) workfile_settings = lib.WorkfileSettings() @@ -92,7 +92,7 @@ def install(): nuke.addOnCreate(launch_workfiles_app, nodeClass="Root") # Set context settings. - # nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root") + nuke.addOnCreate(workfile_settings.set_context_settings, nodeClass="Root") # nuke.addOnCreate(workfile_settings.set_favorites, nodeClass="Root") menu.install() diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index 67f51daad5..c51fd7cbe4 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -88,7 +88,7 @@ def on_script_load(): def check_inventory_versions(): """ - Actiual version idetifier of Loaded containers + Actual version idetifier of Loaded containers Any time this function is run it will check all nodes and filter only Loader nodes for its version. It will get all versions from database @@ -103,7 +103,7 @@ def check_inventory_versions(): if container: node = container["_node"] avalon_knob_data = avalon.nuke.read( - node, ['avalon:', 'ak:']) + node) # get representation from io representation = io.find_one({ @@ -153,7 +153,7 @@ def writes_version_sync(): continue avalon_knob_data = avalon.nuke.read( - each, ['avalon:', 'ak:']) + each) try: if avalon_knob_data['families'] not in ["render"]: @@ -204,7 +204,7 @@ def get_render_path(node): ''' data = dict() data['avalon'] = avalon.nuke.read( - node, ['avalon:', 'ak:']) + node) data_preset = { "class": data['avalon']['family'], @@ -749,7 +749,7 @@ class WorkfileSettings(object): continue # get data from avalon knob - avalon_knob_data = read(node, ["avalon:", "ak:"]) + avalon_knob_data = read(node) if not avalon_knob_data: continue @@ -1099,7 +1099,7 @@ def get_write_node_template_attr(node): # get avalon data from node data = dict() data['avalon'] = avalon.nuke.read( - node, ['avalon:', 'ak:']) + node) data_preset = { "class": data['avalon']['family'], "families": data['avalon']['families'], diff --git a/pype/hosts/nuke/startup/menu.py b/pype/hosts/nuke/startup/menu.py index 3cfae8c7b1..eb3b88c6cc 100644 --- a/pype/hosts/nuke/startup/menu.py +++ b/pype/hosts/nuke/startup/menu.py @@ -1,6 +1,5 @@ import os import sys -import KnobScripter from pype.hosts.nuke.api.lib import ( writes_version_sync, @@ -14,10 +13,10 @@ from pype.api import Logger log = Logger().get_logger(__name__, "nuke") -# nuke.addOnScriptSave(lib.writes_version_sync) -# nuke.addOnScriptSave(lib.on_script_load) -# nuke.addOnScriptLoad(lib.check_inventory_versions) -# nuke.addOnScriptSave(lib.check_inventory_versions) +# nuke.addOnScriptSave(writes_version_sync) +nuke.addOnScriptSave(on_script_load) +nuke.addOnScriptLoad(check_inventory_versions) +nuke.addOnScriptSave(check_inventory_versions) # nuke.addOnScriptSave(lib.writes_version_sync) log.info('Automatic syncing of write file knob to script version') diff --git a/pype/settings/defaults/system_settings/applications.json b/pype/settings/defaults/system_settings/applications.json index e9f6d17480..f0e68aefd2 100644 --- a/pype/settings/defaults/system_settings/applications.json +++ b/pype/settings/defaults/system_settings/applications.json @@ -242,7 +242,7 @@ }, "NUKE_PATH": [ "{PYPE_ROOT}/repos/avalon-core/setup/nuke/nuke_path", - "{PYPE_ROOT}/hosts/nuke/startup", + "{PYPE_ROOT}/pype/hosts/nuke/startup", "{PYPE_STUDIO_PLUGINS}/nuke" ], "PATH": { From 1962f51a9ba2c137db169088ba5b0cc4aa029b68 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 19:04:24 +0100 Subject: [PATCH 18/44] fix checking for the latest version and fix updatting --- pype/hosts/nuke/api/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index c51fd7cbe4..a30ef5ae76 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -101,7 +101,7 @@ def check_inventory_versions(): container = avalon.nuke.parse_container(each) if container: - node = container["_node"] + node = nuke.toNode(container["objectName"]) avalon_knob_data = avalon.nuke.read( node) From ca1d29ec9cb21aa4665ca56bcba76f1dcceaf029 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Wed, 23 Dec 2020 19:14:11 +0100 Subject: [PATCH 19/44] return set_avalon_knob_data --- pype/hosts/nuke/api/lib.py | 4 ++-- pype/hosts/nuke/plugins/create/create_backdrop.py | 4 ++-- pype/hosts/nuke/plugins/create/create_camera.py | 4 ++-- pype/hosts/nuke/plugins/create/create_gizmo.py | 6 +++--- pype/hosts/nuke/plugins/create/create_read.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index a30ef5ae76..1f3c34fe31 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -450,7 +450,7 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): now_node.setInput(0, prev_node) # imprinting group node - avalon.nuke.imprint(GN, data["avalon"]) + anlib.set_avalon_knob_data(GN, data["avalon"]) # add divider GN.addKnob(nuke.Text_Knob('')) @@ -930,7 +930,7 @@ class WorkfileSettings(object): node['frame_range_lock'].setValue(True) # adding handle_start/end to root avalon knob - if not avalon.nuke.imprint(self._root_node, { + if not anlib.set_avalon_knob_data(self._root_node, { "handleStart": int(handle_start), "handleEnd": int(handle_end) }): diff --git a/pype/hosts/nuke/plugins/create/create_backdrop.py b/pype/hosts/nuke/plugins/create/create_backdrop.py index 0d2b621e21..243b14c2d8 100644 --- a/pype/hosts/nuke/plugins/create/create_backdrop.py +++ b/pype/hosts/nuke/plugins/create/create_backdrop.py @@ -32,7 +32,7 @@ class CreateBackdrop(avalon.nuke.Creator): bckd_node["note_font_size"].setValue(24) bckd_node["label"].setValue("[{}]".format(self.name)) # add avalon knobs - instance = anlib.imprint(bckd_node, self.data) + instance = anlib.set_avalon_knob_data(bckd_node, self.data) return instance else: @@ -48,6 +48,6 @@ class CreateBackdrop(avalon.nuke.Creator): bckd_node["note_font_size"].setValue(24) bckd_node["label"].setValue("[{}]".format(self.name)) # add avalon knobs - instance = anlib.imprint(bckd_node, self.data) + instance = anlib.set_avalon_knob_data(bckd_node, self.data) return instance diff --git a/pype/hosts/nuke/plugins/create/create_camera.py b/pype/hosts/nuke/plugins/create/create_camera.py index 4c668925ad..919be0ea79 100644 --- a/pype/hosts/nuke/plugins/create/create_camera.py +++ b/pype/hosts/nuke/plugins/create/create_camera.py @@ -36,7 +36,7 @@ class CreateCamera(avalon.nuke.Creator): # change node color n["tile_color"].setValue(int(self.node_color, 16)) # add avalon knobs - anlib.imprint(n, data) + anlib.set_avalon_knob_data(n, data) return True else: msg = str("Please select nodes you " @@ -49,5 +49,5 @@ class CreateCamera(avalon.nuke.Creator): camera_node = nuke.createNode("Camera2") camera_node["tile_color"].setValue(int(self.node_color, 16)) # add avalon knobs - instance = anlib.imprint(camera_node, self.data) + instance = anlib.set_avalon_knob_data(camera_node, self.data) return instance diff --git a/pype/hosts/nuke/plugins/create/create_gizmo.py b/pype/hosts/nuke/plugins/create/create_gizmo.py index eb5b1a3fb0..19b5bead8f 100644 --- a/pype/hosts/nuke/plugins/create/create_gizmo.py +++ b/pype/hosts/nuke/plugins/create/create_gizmo.py @@ -34,7 +34,7 @@ class CreateGizmo(avalon.nuke.Creator): if node.Class() in "Group": node["name"].setValue("{}_GZM".format(self.name)) node["tile_color"].setValue(int(self.node_color, 16)) - return anlib.imprint(node, self.data) + return anlib.set_avalon_knob_data(node, self.data) else: msg = ("Please select a group node " "you wish to publish as the gizmo") @@ -57,7 +57,7 @@ class CreateGizmo(avalon.nuke.Creator): "- create User knobs on the group") # add avalon knobs - return anlib.imprint(gizmo_node, self.data) + return anlib.set_avalon_knob_data(gizmo_node, self.data) else: msg = ("Please select nodes you " @@ -80,4 +80,4 @@ class CreateGizmo(avalon.nuke.Creator): "- create User knobs on the group") # add avalon knobs - return anlib.imprint(gizmo_node, self.data) + return anlib.set_avalon_knob_data(gizmo_node, self.data) diff --git a/pype/hosts/nuke/plugins/create/create_read.py b/pype/hosts/nuke/plugins/create/create_read.py index 072d234b32..591f9c14a2 100644 --- a/pype/hosts/nuke/plugins/create/create_read.py +++ b/pype/hosts/nuke/plugins/create/create_read.py @@ -44,7 +44,7 @@ class CrateRead(avalon.nuke.Creator): continue avalon_data = self.data avalon_data['subset'] = "{}".format(self.name) - avalon.nuke.lib.imprint(node, avalon_data) + avalon.nuke.lib.set_avalon_knob_data(node, avalon_data) node['tile_color'].setValue(16744935) count_reads += 1 From 330ffb23a22ccb91e1ac2a9864e1d2ac98b45fc2 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 6 Jan 2021 16:36:35 +0100 Subject: [PATCH 20/44] minor fixes nuke --- pype/hosts/nuke/api/__init__.py | 1 - pype/hosts/nuke/api/lib.py | 33 ++++++++++--------- .../plugins/create/create_write_render.py | 2 ++ pype/hosts/nuke/startup/menu.py | 6 ---- .../system_settings/applications.json | 17 ++++++---- .../defaults/system_settings/general.json | 2 +- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py index b60f79d910..c303c17b39 100644 --- a/pype/hosts/nuke/api/__init__.py +++ b/pype/hosts/nuke/api/__init__.py @@ -116,7 +116,6 @@ def uninstall(): pyblish.deregister_callback("instanceToggled", on_pyblish_instance_toggled) - reload_config() menu.uninstall() diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index 1f3c34fe31..e9dcb827fb 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -17,7 +17,7 @@ from pype.api import ( config, ApplicationManager ) - + import nuke from .utils import set_context_favorites @@ -41,11 +41,11 @@ def get_node_imageio_setting(**kwarg): "`{}`: Missing mandatory kwargs `host`, `cls`".format(__file__)) imageio_nodes = (get_anatomy_settings(project_name) - ["imageio"] - .get(host, None) - ["nodes"] - ["requiredNodes"] - ) + ["imageio"] + .get(host, None) + ["nodes"] + ["requiredNodes"] + ) for node in imageio_nodes: log.info(node) @@ -61,11 +61,11 @@ def get_imageio_input_colorspace(filename): ''' Get input file colorspace based on regex in settings. ''' imageio_regex_inputs = (get_anatomy_settings(os.getenv("AVALON_PROJECT")) - ["imageio"] - ["nuke"] - ["regexInputs"] - ["inputs"] - ) + ["imageio"] + ["nuke"] + ["regexInputs"] + ["inputs"] + ) preset_clrsp = None for regexInput in imageio_regex_inputs: @@ -253,7 +253,7 @@ def format_anatomy(data): log.error(msg) nuke.message(msg) - + version = data.get("version", None) if not version: file = script_name() @@ -363,7 +363,6 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): if knob["name"] not in ["_id", "_previous"]: _data.update({knob["name"]: knob["value"]}) - _data = avalon.nuke.lib.fix_data_for_node_create(_data) log.debug("_data: `{}`".format(_data)) @@ -838,7 +837,8 @@ class WorkfileSettings(object): def set_colorspace(self): ''' Setting colorpace following presets ''' - nuke_colorspace = config.get_init_presets()["colorspace"].get("nuke", None) + nuke_colorspace = config.get_init_presets( + )["colorspace"].get("nuke", None) try: self.set_root_colorspace(nuke_colorspace["root"]) @@ -903,7 +903,7 @@ class WorkfileSettings(object): handle_start = data["handleStart"] handle_end = data["handleEnd"] - fps = data["fps"] + fps = float(data["fps"]) frame_start = int(data["frameStart"]) - handle_start frame_end = int(data["frameEnd"]) + handle_end @@ -1119,7 +1119,6 @@ def get_write_node_template_attr(node): for k, v in nuke_imageio_writes.items() if k not in ["_id", "_previous"]} - # fix badly encoded data return avalon.nuke.lib.fix_data_for_node_create(correct_data) @@ -1240,6 +1239,7 @@ class ExporterReviewLut(ExporterReview): """ + def __init__(self, klass, instance, @@ -1342,6 +1342,7 @@ class ExporterReviewMov(ExporterReview): instance (pyblish.instance): instance of pyblish context """ + def __init__(self, klass, instance, diff --git a/pype/hosts/nuke/plugins/create/create_write_render.py b/pype/hosts/nuke/plugins/create/create_write_render.py index 3876ba5806..60db8800dd 100644 --- a/pype/hosts/nuke/plugins/create/create_write_render.py +++ b/pype/hosts/nuke/plugins/create/create_write_render.py @@ -48,6 +48,7 @@ class CreateWriteRender(plugin.PypeCreator): "or tick off `Use selection`") self.log.error(msg) nuke.message(msg) + return if len(nodes) == 0: msg = ( @@ -56,6 +57,7 @@ class CreateWriteRender(plugin.PypeCreator): ) self.log.error(msg) nuke.message(msg) + return selected_node = nodes[0] inputs = [selected_node] diff --git a/pype/hosts/nuke/startup/menu.py b/pype/hosts/nuke/startup/menu.py index eb3b88c6cc..be0f6c411c 100644 --- a/pype/hosts/nuke/startup/menu.py +++ b/pype/hosts/nuke/startup/menu.py @@ -1,8 +1,4 @@ -import os -import sys - from pype.hosts.nuke.api.lib import ( - writes_version_sync, on_script_load, check_inventory_versions ) @@ -13,10 +9,8 @@ from pype.api import Logger log = Logger().get_logger(__name__, "nuke") -# nuke.addOnScriptSave(writes_version_sync) nuke.addOnScriptSave(on_script_load) nuke.addOnScriptLoad(check_inventory_versions) nuke.addOnScriptSave(check_inventory_versions) -# nuke.addOnScriptSave(lib.writes_version_sync) log.info('Automatic syncing of write file knob to script version') diff --git a/pype/settings/defaults/system_settings/applications.json b/pype/settings/defaults/system_settings/applications.json index f0e68aefd2..24bed66783 100644 --- a/pype/settings/defaults/system_settings/applications.json +++ b/pype/settings/defaults/system_settings/applications.json @@ -237,7 +237,8 @@ "__environment_keys__": { "nuke": [ "NUKE_PATH", - "PATH" + "PATH", + "LOGLEVEL" ] }, "NUKE_PATH": [ @@ -247,7 +248,8 @@ ], "PATH": { "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" - } + }, + "LOGLEVEL": "INFO" }, "variants": { "nuke_12.2": { @@ -788,9 +790,7 @@ "RESOLVE_DEV" ] }, - "RESOLVE_UTILITY_SCRIPTS_SOURCE_DIR": [ - "{STUDIO_SOFT}/davinci_resolve/scripts/python" - ], + "RESOLVE_UTILITY_SCRIPTS_SOURCE_DIR": [], "RESOLVE_SCRIPT_API": { "windows": "{PROGRAMDATA}/Blackmagic Design/DaVinci Resolve/Support/Developer/Scripting", "darvin": "/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting", @@ -834,7 +834,12 @@ "variant_label": "16", "icon": "", "executables": { - "windows": [], + "windows": [ + [ + "C:/Program Files/Blackmagic Design/DaVinci Resolve/Resolve.exe", + "" + ] + ], "darwin": [], "linux": [] }, diff --git a/pype/settings/defaults/system_settings/general.json b/pype/settings/defaults/system_settings/general.json index bae0ed4e87..31ee818715 100644 --- a/pype/settings/defaults/system_settings/general.json +++ b/pype/settings/defaults/system_settings/general.json @@ -25,7 +25,7 @@ ] }, "FFMPEG_PATH": { - "windows": "{VIRTUAL_ENV}/localized/ffmpeg_exec/windows/bin;{PYPE_SETUP_PATH}/vendor/bin/ffmpeg_exec/windows/bin", + "windows": "C:/CODE/__PYPE/pype3/vendor/bin/ffmpeg_exec/windows/bin", "darwin": "{VIRTUAL_ENV}/localized/ffmpeg_exec/darwin/bin:{PYPE_SETUP_PATH}/vendor/bin/ffmpeg_exec/darwin/bin", "linux": "{VIRTUAL_ENV}/localized/ffmpeg_exec/linux:{PYPE_SETUP_PATH}/vendor/bin/ffmpeg_exec/linux" }, From bf13ba0fc691d8a138d9bc1bd058549084f15315 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 6 Jan 2021 16:41:05 +0100 Subject: [PATCH 21/44] Updated submodule repos/avalon-core --- repos/avalon-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/avalon-core b/repos/avalon-core index c78e83d4b8..a7ddbe7ee4 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit c78e83d4b8e6b409dbe5aafe5a7ec7725cb88145 +Subproject commit a7ddbe7ee4adc1be107064c4ac27e44ee2887f10 From 66134f4f0d136cf7f006211795f1927033ca1b6a Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 6 Jan 2021 16:41:40 +0100 Subject: [PATCH 22/44] setuptools version update to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 658405e2fb..57e10a06ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,6 +24,7 @@ pytest-cov pytest-print pyqt5 Qt.py +setuptools==45.0.0 speedcopy six Sphinx From d39f3af5b1175a2f357b4732cf6bb536d4f0f0e9 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Thu, 7 Jan 2021 16:38:46 +0100 Subject: [PATCH 23/44] nuke fixes --- pype/hosts/nuke/api/lib.py | 7 +++---- pype/hosts/nuke/plugins/publish/collect_instances.py | 8 ++++---- repos/avalon-core | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index e9dcb827fb..81d00542cc 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -5,7 +5,6 @@ from collections import OrderedDict from avalon import api, io, lib import avalon.nuke -import acre from avalon.nuke import lib as anlib from pype.api import ( Logger, @@ -363,7 +362,7 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): if knob["name"] not in ["_id", "_previous"]: _data.update({knob["name"]: knob["value"]}) - _data = avalon.nuke.lib.fix_data_for_node_create(_data) + _data = anlib.fix_data_for_node_create(_data) log.debug("_data: `{}`".format(_data)) @@ -432,7 +431,7 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): prev_node = now_node # creating write node - write_node = now_node = avalon.nuke.lib.add_write_node( + write_node = now_node = anlib.add_write_node( "inside_{}".format(name), **_data ) @@ -1120,7 +1119,7 @@ def get_write_node_template_attr(node): if k not in ["_id", "_previous"]} # fix badly encoded data - return avalon.nuke.lib.fix_data_for_node_create(correct_data) + return anlib.fix_data_for_node_create(correct_data) class ExporterReview: diff --git a/pype/hosts/nuke/plugins/publish/collect_instances.py b/pype/hosts/nuke/plugins/publish/collect_instances.py index 4b192bfaff..78146f704b 100644 --- a/pype/hosts/nuke/plugins/publish/collect_instances.py +++ b/pype/hosts/nuke/plugins/publish/collect_instances.py @@ -3,8 +3,7 @@ import os import nuke import pyblish.api from avalon import io, api -from avalon.nuke import get_avalon_knob_data - +from avalon.nuke import lib as anlib @pyblish.api.log class CollectNukeInstances(pyblish.api.ContextPlugin): @@ -39,7 +38,8 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): # get data from avalon knob self.log.debug("node[name]: {}".format(node['name'].value())) - avalon_knob_data = get_avalon_knob_data(node, ["avalon:", "ak:"]) + avalon_knob_data = anlib.get_avalon_knob_data( + node, ["avalon:", "ak:"]) self.log.debug("avalon_knob_data: {}".format(avalon_knob_data)) @@ -55,7 +55,7 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): families = list() if families_ak: - families.append(families_ak) + families.append(families_ak.lower()) families.append(family) diff --git a/repos/avalon-core b/repos/avalon-core index a7ddbe7ee4..feba419c4c 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit a7ddbe7ee4adc1be107064c4ac27e44ee2887f10 +Subproject commit feba419c4c8e25bd9e2119f83caad71d45d4f755 From 149823a3c848708b56370a5d5f8633cc03e7c35f Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 8 Jan 2021 16:52:32 +0100 Subject: [PATCH 24/44] improving Created Write UX https://pype.freshdesk.com/a/tickets/487 --- pype/hosts/nuke/api/lib.py | 50 +++++++++++++++++++++++--------------- repos/avalon-core | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index 81d00542cc..ba4c15c180 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -279,11 +279,11 @@ def script_name(): def add_button_write_to_read(node): name = "createReadNode" - label = "[ Create Read ]" + label = "Cread Read From Rendered" value = "import write_to_read;write_to_read.write_to_read(nuke.thisNode())" - k = nuke.PyScript_Knob(name, label, value) - k.setFlag(0x1000) - node.addKnob(k) + knob = nuke.PyScript_Knob(name, label, value) + knob.clearFlag(nuke.STARTLINE) + node.addKnob(knob) def create_write_node(name, data, input=None, prenodes=None, review=True): @@ -449,29 +449,39 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): # imprinting group node anlib.set_avalon_knob_data(GN, data["avalon"]) - - # add divider - GN.addKnob(nuke.Text_Knob('')) - + anlib.add_publish_knob(GN) add_rendering_knobs(GN) if review: add_review_knob(GN) # add divider - GN.addKnob(nuke.Text_Knob('')) + GN.addKnob(nuke.Text_Knob('', 'Rendering')) # Add linked knobs. - linked_knob_names = ["Render", "use_limit", "first", "last"] + linked_knob_names = [ + "_grp-start_", + "use_limit", "first", "last", + "_grp-end_", + "Render" + ] for name in linked_knob_names: - link = nuke.Link_Knob(name) - link.makeLink(write_node.name(), name) - link.setName(name) - link.setFlag(0x1000) - GN.addKnob(link) - - # add divider - GN.addKnob(nuke.Text_Knob('')) + if "_grp-start_" in name: + knob = nuke.Tab_Knob( + "rnd_attr", "Rendering attributes", nuke.TABBEGINCLOSEDGROUP) + GN.addKnob(knob) + elif "_grp-end_" in name: + knob = nuke.Tab_Knob( + "rnd_attr", "Rendering attributes", nuke.TABENDGROUP) + GN.addKnob(knob) + else: + link = nuke.Link_Knob("") + link.makeLink(write_node.name(), name) + link.setName(name) + if "Render" in name: + link.setLabel("Render Local") + link.setFlag(0x1000) + GN.addKnob(link) # adding write to read button add_button_write_to_read(GN) @@ -496,9 +506,9 @@ def add_rendering_knobs(node): node (obj): with added knobs ''' if "render" not in node.knobs(): - knob = nuke.Enumeration_Knob("render", "Render", [ + knob = nuke.Enumeration_Knob("render", "", [ "Use existing frames", "Local", "On farm"]) - knob.setFlag(0x1000) + knob.clearFlag(nuke.STARTLINE) node.addKnob(knob) return node diff --git a/repos/avalon-core b/repos/avalon-core index feba419c4c..d98cf8f0db 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit feba419c4c8e25bd9e2119f83caad71d45d4f755 +Subproject commit d98cf8f0db78e5d225dda09cc5ca140bf41772d5 From 97a4ac562e6d7856ab1cf097c1a6a14a847a47ee Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 8 Jan 2021 17:12:23 +0100 Subject: [PATCH 25/44] nuke instance collect to pre-collect --- .../{collect_instances.py => precollect_instances.py} | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) rename pype/hosts/nuke/plugins/publish/{collect_instances.py => precollect_instances.py} (96%) diff --git a/pype/hosts/nuke/plugins/publish/collect_instances.py b/pype/hosts/nuke/plugins/publish/precollect_instances.py similarity index 96% rename from pype/hosts/nuke/plugins/publish/collect_instances.py rename to pype/hosts/nuke/plugins/publish/precollect_instances.py index 78146f704b..60e90002da 100644 --- a/pype/hosts/nuke/plugins/publish/collect_instances.py +++ b/pype/hosts/nuke/plugins/publish/precollect_instances.py @@ -1,16 +1,15 @@ -import os - import nuke import pyblish.api from avalon import io, api from avalon.nuke import lib as anlib + @pyblish.api.log -class CollectNukeInstances(pyblish.api.ContextPlugin): +class PreCollectNukeInstances(pyblish.api.ContextPlugin): """Collect all nodes with Avalon knob.""" - order = pyblish.api.CollectorOrder + 0.01 - label = "Collect Instances" + order = pyblish.api.CollectorOrder - 0.6 + label = "Pre-collect Instances" hosts = ["nuke", "nukeassist"] def process(self, context): @@ -122,7 +121,6 @@ class CollectNukeInstances(pyblish.api.ContextPlugin): "pixelAspect": pixel_aspect, }) - self.log.info("collected instance: {}".format(instance.data)) instances.append(instance) From 3ba9964edd99d9f233405649fcf8f515a6be5989 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 8 Jan 2021 17:13:42 +0100 Subject: [PATCH 26/44] nuke fixing closing group issue --- pype/hosts/nuke/api/__init__.py | 4 +--- pype/hosts/nuke/api/lib.py | 2 +- repos/avalon-core | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py index c303c17b39..0c9618bcf4 100644 --- a/pype/hosts/nuke/api/__init__.py +++ b/pype/hosts/nuke/api/__init__.py @@ -9,7 +9,6 @@ from avalon.tools import workfiles from pyblish import api as pyblish from pype.api import Logger import pype.hosts.nuke -from pype import PLUGINS_DIR from . import lib, menu @@ -18,7 +17,6 @@ self.workfiles_launched = False log = Logger().get_logger(__name__, "nuke") AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") - HOST_DIR = os.path.dirname(os.path.abspath(pype.hosts.nuke.__file__)) PLUGINS_DIR = os.path.join(HOST_DIR, "plugins") PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish") @@ -72,7 +70,7 @@ def install(): # Register Avalon event for workfiles loading. avalon.on("workio.open_file", lib.check_inventory_versions) - # pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) + pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled) workfile_settings = lib.WorkfileSettings() # Disable all families except for the ones we explicitly want to see family_states = [ diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index ba4c15c180..b2ada0d19c 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -472,7 +472,7 @@ def create_write_node(name, data, input=None, prenodes=None, review=True): GN.addKnob(knob) elif "_grp-end_" in name: knob = nuke.Tab_Knob( - "rnd_attr", "Rendering attributes", nuke.TABENDGROUP) + "rnd_attr_end", "Rendering attributes", nuke.TABENDGROUP) GN.addKnob(knob) else: link = nuke.Link_Knob("") diff --git a/repos/avalon-core b/repos/avalon-core index d98cf8f0db..8a19fc31f9 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit d98cf8f0db78e5d225dda09cc5ca140bf41772d5 +Subproject commit 8a19fc31f9f503f63a1b4d6cb90f3690902c2e5d From 889c301a6c219910d6f36e6e9bbe93f60baf79f7 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 15 Jan 2021 17:30:24 +0100 Subject: [PATCH 27/44] clean code with deprecated code and other mess --- pype/hosts/nuke/api/__init__.py | 2 +- pype/hosts/nuke/api/lib.py | 2 +- pype/hosts/nuke/api/menu.py | 2 +- pype/hosts/nuke/api/plugin.py | 10 +++------- pype/hosts/nuke/api/utils.py | 3 ++- pype/hosts/nuke/startup/menu.py | 2 +- pype/hosts/nuke/startup/write_to_read.py | 2 +- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py index 0c9618bcf4..cca17eae57 100644 --- a/pype/hosts/nuke/api/__init__.py +++ b/pype/hosts/nuke/api/__init__.py @@ -14,7 +14,7 @@ from . import lib, menu self = sys.modules[__name__] self.workfiles_launched = False -log = Logger().get_logger(__name__, "nuke") +log = Logger().get_logger(__name__) AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") HOST_DIR = os.path.dirname(os.path.abspath(pype.hosts.nuke.__file__)) diff --git a/pype/hosts/nuke/api/lib.py b/pype/hosts/nuke/api/lib.py index b2ada0d19c..96067a3d48 100644 --- a/pype/hosts/nuke/api/lib.py +++ b/pype/hosts/nuke/api/lib.py @@ -21,7 +21,7 @@ import nuke from .utils import set_context_favorites -log = Logger().get_logger(__name__, "nuke") +log = Logger().get_logger(__name__) self = sys.modules[__name__] self._project = None diff --git a/pype/hosts/nuke/api/menu.py b/pype/hosts/nuke/api/menu.py index 7bebbeeefc..8161b9024c 100644 --- a/pype/hosts/nuke/api/menu.py +++ b/pype/hosts/nuke/api/menu.py @@ -4,7 +4,7 @@ from avalon.api import Session from .lib import WorkfileSettings from pype.api import Logger, BuildWorkfile -log = Logger().get_logger(__name__, "nuke") +log = Logger().get_logger(__name__) def install(): diff --git a/pype/hosts/nuke/api/plugin.py b/pype/hosts/nuke/api/plugin.py index 1d8d137156..d6799ed6ca 100644 --- a/pype/hosts/nuke/api/plugin.py +++ b/pype/hosts/nuke/api/plugin.py @@ -1,11 +1,10 @@ -import re import avalon.api import avalon.nuke from pype.api import get_current_project_settings from .lib import check_subsetname_exists - import nuke + class PypeCreator(avalon.nuke.pipeline.Creator): """Pype Nuke Creator class wrapper """ @@ -17,11 +16,8 @@ class PypeCreator(avalon.nuke.pipeline.Creator): if check_subsetname_exists( nuke.allNodes(), self.data["subset"]): - msg = "The subset name `{0}` is already used on a node in" \ - "this workfile.".format(self.data["subset"]) + msg = ("The subset name `{0}` is already used on a node in" + "this workfile.".format(self.data["subset"])) self.log.error(msg + '\n\nPlease use other subset name!') raise NameError("`{0}: {1}".format(__name__, msg)) return - - - diff --git a/pype/hosts/nuke/api/utils.py b/pype/hosts/nuke/api/utils.py index 72c7b7bc14..e14b03d453 100644 --- a/pype/hosts/nuke/api/utils.py +++ b/pype/hosts/nuke/api/utils.py @@ -4,12 +4,13 @@ from avalon.nuke import lib as anlib from pype.api import resources -def set_context_favorites(favorites={}): +def set_context_favorites(favorites=None): """ Addig favorite folders to nuke's browser Argumets: favorites (dict): couples of {name:path} """ + favorites = favorites or {} icon_path = resources.get_resource("icons", "folder-favorite3.png") for name, path in favorites.items(): nuke.addFavoriteDir( diff --git a/pype/hosts/nuke/startup/menu.py b/pype/hosts/nuke/startup/menu.py index be0f6c411c..8e2e06a169 100644 --- a/pype/hosts/nuke/startup/menu.py +++ b/pype/hosts/nuke/startup/menu.py @@ -6,7 +6,7 @@ from pype.hosts.nuke.api.lib import ( import nuke from pype.api import Logger -log = Logger().get_logger(__name__, "nuke") +log = Logger().get_logger(__name__) nuke.addOnScriptSave(on_script_load) diff --git a/pype/hosts/nuke/startup/write_to_read.py b/pype/hosts/nuke/startup/write_to_read.py index 58985947bd..d4556fa64c 100644 --- a/pype/hosts/nuke/startup/write_to_read.py +++ b/pype/hosts/nuke/startup/write_to_read.py @@ -3,7 +3,7 @@ import os import glob import nuke from pype.api import Logger -log = Logger().get_logger(__name__, "nuke") +log = Logger().get_logger(__name__) SINGLE_FILE_FORMATS = ['avi', 'mp4', 'mxf', 'mov', 'mpg', 'mpeg', 'wmv', 'm4v', 'm2v'] From fe8c9546db0c4c31ed1e0e5c5bf72252a636d802 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 18 Jan 2021 10:58:26 +0100 Subject: [PATCH 28/44] fix(global): import otio python27 workaround --- pype/lib/editorial.py | 49 +++++++++++++++++++++------------------- pype/lib/import_utils.py | 25 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 pype/lib/import_utils.py diff --git a/pype/lib/editorial.py b/pype/lib/editorial.py index 7f29bf00bb..1dbc4d7954 100644 --- a/pype/lib/editorial.py +++ b/pype/lib/editorial.py @@ -1,15 +1,18 @@ import os import re import clique -from opentimelineio import opentime -from opentimelineio.opentime import ( - to_frames, RationalTime, TimeRange) +from .import_utils import discover_host_vendor_module + +try: + from opentimelineio import opentime as _ot +except ImportError: + _ot = discover_host_vendor_module("opentimelineio.opentime") def otio_range_to_frame_range(otio_range): - start = to_frames( + start = _ot.to_frames( otio_range.start_time, otio_range.start_time.rate) - end = start + to_frames( + end = start + _ot.to_frames( otio_range.duration, otio_range.duration.rate) - 1 return start, end @@ -19,12 +22,12 @@ def otio_range_with_handles(otio_range, instance): handle_end = instance.data["handleEnd"] handles_duration = handle_start + handle_end fps = float(otio_range.start_time.rate) - start = to_frames(otio_range.start_time, fps) - duration = to_frames(otio_range.duration, fps) + start = _ot.to_frames(otio_range.start_time, fps) + duration = _ot.to_frames(otio_range.duration, fps) - return TimeRange( - start_time=RationalTime((start - handle_start), fps), - duration=RationalTime((duration + handles_duration), fps) + return _ot.TimeRange( + start_time=_ot.RationalTime((start - handle_start), fps), + duration=_ot.RationalTime((duration + handles_duration), fps) ) @@ -80,22 +83,22 @@ def trim_media_range(media_range, source_range): Trim input media range with clip source range. Args: - media_range (otio.opentime.TimeRange): available range of media - source_range (otio.opentime.TimeRange): clip required range + media_range (otio._ot._ot.TimeRange): available range of media + source_range (otio._ot._ot.TimeRange): clip required range Returns: - otio.opentime.TimeRange: trimmed media range + otio._ot._ot.TimeRange: trimmed media range """ - rw_media_start = RationalTime( + rw_media_start = _ot.RationalTime( media_range.start_time.value + source_range.start_time.value, media_range.start_time.rate ) - rw_media_duration = RationalTime( + rw_media_duration = _ot.RationalTime( source_range.duration.value, media_range.duration.rate ) - return TimeRange( + return _ot.TimeRange( rw_media_start, rw_media_duration) @@ -109,12 +112,12 @@ def range_from_frames(start, duration, fps): fps (float): frame range Returns: - otio.opentime.TimeRange: crated range + otio._ot._ot.TimeRange: crated range """ - return TimeRange( - RationalTime(start, fps), - RationalTime(duration, fps) + return _ot.TimeRange( + _ot.RationalTime(start, fps), + _ot.RationalTime(duration, fps) ) @@ -130,8 +133,8 @@ def frames_to_secons(frames, framerate): float: second value """ - rt = opentime.from_frames(frames, framerate) - return opentime.to_seconds(rt) + rt = _ot.from_frames(frames, framerate) + return _ot.to_seconds(rt) def make_sequence_collection(path, otio_range, metadata): @@ -140,7 +143,7 @@ def make_sequence_collection(path, otio_range, metadata): Args: path (str): path to image sequence with `%d` - otio_range (otio.opentime.TimeRange): range to be used + otio_range (otio._ot._ot.TimeRange): range to be used metadata (dict): data where padding value can be found Returns: diff --git a/pype/lib/import_utils.py b/pype/lib/import_utils.py new file mode 100644 index 0000000000..5c832a925c --- /dev/null +++ b/pype/lib/import_utils.py @@ -0,0 +1,25 @@ +import os +import sys +import importlib +from .log import PypeLogger as Logger + +log = Logger().get_logger(__name__) + + +def discover_host_vendor_module(module_name): + host = os.environ["AVALON_APP"] + pype_root = os.environ["PYPE_ROOT"] + main_module = module_name.split(".")[0] + module_path = os.path.join( + pype_root, "hosts", host, "vendor", main_module) + + log.debug( + "Importing moduel from host vendor path: `{}`".format(module_path)) + + if not os.path.exists(module_path): + log.warning( + "Path not existing: `{}`".format(module_path)) + return None + + sys.path.insert(1, module_path) + return importlib.import_module(module_name) From 0911787fdb9e72d993598243beda879583d3e88c Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Tue, 19 Jan 2021 17:36:44 +0100 Subject: [PATCH 29/44] hound(nuke): pep8 suggestions --- pype/hosts/nuke/api/__init__.py | 3 +-- .../plugins/create/create_write_prerender.py | 2 +- pype/hosts/nuke/plugins/load/load_mov.py | 26 +++++++++---------- pype/hosts/nuke/plugins/load/load_sequence.py | 2 -- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/pype/hosts/nuke/api/__init__.py b/pype/hosts/nuke/api/__init__.py index cca17eae57..26a8248f01 100644 --- a/pype/hosts/nuke/api/__init__.py +++ b/pype/hosts/nuke/api/__init__.py @@ -1,7 +1,5 @@ import os import sys -import logging - import nuke from avalon import api as avalon @@ -53,6 +51,7 @@ def reload_config(): try: importlib.reload(module) except AttributeError as e: + from importlib import reload log.warning("Cannot reload module: {}".format(e)) reload(module) diff --git a/pype/hosts/nuke/plugins/create/create_write_prerender.py b/pype/hosts/nuke/plugins/create/create_write_prerender.py index 44b01f4bcd..d1969c7fba 100644 --- a/pype/hosts/nuke/plugins/create/create_write_prerender.py +++ b/pype/hosts/nuke/plugins/create/create_write_prerender.py @@ -91,7 +91,7 @@ class CreateWritePrerender(plugin.PypeCreator): write_data.update({ "fpath_template": ("{work}/prerenders/nuke/{subset}" "/{subset}.{frame}.{ext}")}) - + self.log.info("write_data: {}".format(write_data)) write_node = lib.create_write_node( diff --git a/pype/hosts/nuke/plugins/load/load_mov.py b/pype/hosts/nuke/plugins/load/load_mov.py index 95bd780896..f9be675cb9 100644 --- a/pype/hosts/nuke/plugins/load/load_mov.py +++ b/pype/hosts/nuke/plugins/load/load_mov.py @@ -1,4 +1,3 @@ -import re import nuke import contextlib @@ -9,7 +8,6 @@ from pype.hosts.nuke.api.lib import ( ) - @contextlib.contextmanager def preserve_trim(node): """Preserve the relative trim of the Loader tool. @@ -77,16 +75,17 @@ def add_review_presets_config(): "representations": list() } settings = get_current_project_settings() - review_profiles = (settings["global"] - ["publish"] - ["ExtractReview"] - ["profiles"] - ) + review_profiles = ( + settings["global"] + ["publish"] + ["ExtractReview"] + ["profiles"] + ) outputs = {} for profile in review_profiles: outputs.update(profile.get("outputs", {})) - + for output, properities in outputs.items(): returning["representations"].append(output) returning["families"] += properities.get("families", []) @@ -277,10 +276,11 @@ class LoadMov(api.Loader): colorspace = version_data.get("colorspace") if first is None: - self.log.warning("Missing start frame for updated version" - "assuming starts at frame 0 for: " - "{} ({})".format( - node['name'].value(), representation)) + self.log.warning(( + "Missing start frame for updated version" + "assuming starts at frame 0 for: " + "{} ({})").format( + node['name'].value(), representation)) first = 0 # fix handle start and end if none are available @@ -313,7 +313,7 @@ class LoadMov(api.Loader): preset_clrsp = get_imageio_input_colorspace(file) if preset_clrsp is not None: - r["colorspace"].setValue(preset_clrsp) + node["colorspace"].setValue(preset_clrsp) updated_dict = {} updated_dict.update({ diff --git a/pype/hosts/nuke/plugins/load/load_sequence.py b/pype/hosts/nuke/plugins/load/load_sequence.py index e3c0202395..f99b7be52f 100644 --- a/pype/hosts/nuke/plugins/load/load_sequence.py +++ b/pype/hosts/nuke/plugins/load/load_sequence.py @@ -1,5 +1,3 @@ -import re -import os import nuke import contextlib From e0680af5857b2351a11967a075ced02212cf1048 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 13:39:31 +0100 Subject: [PATCH 30/44] fix(global): removing private dev content --- pype/settings/defaults/system_settings/general.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/settings/defaults/system_settings/general.json b/pype/settings/defaults/system_settings/general.json index 31ee818715..1e7d4b697f 100644 --- a/pype/settings/defaults/system_settings/general.json +++ b/pype/settings/defaults/system_settings/general.json @@ -25,7 +25,7 @@ ] }, "FFMPEG_PATH": { - "windows": "C:/CODE/__PYPE/pype3/vendor/bin/ffmpeg_exec/windows/bin", + "windows": "{PYPE_ROOT}/vendor/bin/ffmpeg_exec/windows/bin", "darwin": "{VIRTUAL_ENV}/localized/ffmpeg_exec/darwin/bin:{PYPE_SETUP_PATH}/vendor/bin/ffmpeg_exec/darwin/bin", "linux": "{VIRTUAL_ENV}/localized/ffmpeg_exec/linux:{PYPE_SETUP_PATH}/vendor/bin/ffmpeg_exec/linux" }, From 92d0992e141a1361af0237b0142b14ad4b0930e7 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 13:40:41 +0100 Subject: [PATCH 31/44] nuke debug loglevel --- pype/settings/defaults/system_settings/applications.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/settings/defaults/system_settings/applications.json b/pype/settings/defaults/system_settings/applications.json index 24bed66783..b5f82c0593 100644 --- a/pype/settings/defaults/system_settings/applications.json +++ b/pype/settings/defaults/system_settings/applications.json @@ -249,7 +249,7 @@ "PATH": { "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" }, - "LOGLEVEL": "INFO" + "LOGLEVEL": "DEBUG" }, "variants": { "nuke_12.2": { From 5735ad4950eada953bb3ed981ee2fa775d0bb1bc Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 13:41:05 +0100 Subject: [PATCH 32/44] nuke disable plugins for different workflow --- pype/settings/defaults/project_settings/nuke.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pype/settings/defaults/project_settings/nuke.json b/pype/settings/defaults/project_settings/nuke.json index 82dcf23694..76a95d2140 100644 --- a/pype/settings/defaults/project_settings/nuke.json +++ b/pype/settings/defaults/project_settings/nuke.json @@ -36,7 +36,7 @@ } }, "ValidateKnobs": { - "enabled": true, + "enabled": false, "knobs": { "render": { "review": true @@ -44,7 +44,7 @@ } }, "ExtractReviewDataLut": { - "enabled": true + "enabled": false }, "ExtractReviewDataMov": { "enabled": true, From 398bc687d4e7fc7ce1a6d7e522cf6a7e4402abf1 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 13:41:22 +0100 Subject: [PATCH 33/44] fix: nuke self to cls --- pype/hosts/nuke/plugins/publish/validate_knobs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pype/hosts/nuke/plugins/publish/validate_knobs.py b/pype/hosts/nuke/plugins/publish/validate_knobs.py index 34c82f4b36..ce15831c9c 100644 --- a/pype/hosts/nuke/plugins/publish/validate_knobs.py +++ b/pype/hosts/nuke/plugins/publish/validate_knobs.py @@ -54,15 +54,15 @@ class ValidateKnobs(pyblish.api.ContextPlugin): # Filter families. families = [instance.data["family"]] families += instance.data.get("families", []) - families = list(set(families) & set(self.knobs.keys())) + families = list(set(families) & set(cls.knobs.keys())) if not families: continue # Get all knobs to validate. knobs = {} for family in families: - for preset in self.knobs[family]: - knobs.update({preset: self.knobs[family][preset]}) + for preset in cls.knobs[family]: + knobs.update({preset: cls.knobs[family][preset]}) # Get invalid knobs. nodes = [] From c7e331b786119026e1bd9d89b657c8ed8c3c7bb5 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 13:41:49 +0100 Subject: [PATCH 34/44] nuke plugins to precollect stage --- .../plugins/publish/collect_current_file.py | 19 ------------- .../publish/extract_review_data_mov.py | 2 +- .../plugins/publish/precollect_instances.py | 16 +++++++++-- ...ect_workfile.py => precollect_workfile.py} | 28 +++++++++++-------- ...collect_writes.py => precollect_writes.py} | 20 ++++++++----- 5 files changed, 44 insertions(+), 41 deletions(-) delete mode 100644 pype/hosts/nuke/plugins/publish/collect_current_file.py rename pype/hosts/nuke/plugins/publish/{collect_workfile.py => precollect_workfile.py} (79%) rename pype/hosts/nuke/plugins/publish/{collect_writes.py => precollect_writes.py} (90%) diff --git a/pype/hosts/nuke/plugins/publish/collect_current_file.py b/pype/hosts/nuke/plugins/publish/collect_current_file.py deleted file mode 100644 index 253b9a7a24..0000000000 --- a/pype/hosts/nuke/plugins/publish/collect_current_file.py +++ /dev/null @@ -1,19 +0,0 @@ -import pyblish.api - - -class CollectCurrentFile(pyblish.api.ContextPlugin): - """Inject the current working file into context""" - - order = pyblish.api.CollectorOrder - 0.5 - label = "Collect Current File" - hosts = ["nuke"] - - def process(self, context): - import os - import nuke - current_file = nuke.root().name() - - normalised = os.path.normpath(current_file) - - context.data["current_file"] = normalised - context.data["currentFile"] = normalised diff --git a/pype/hosts/nuke/plugins/publish/extract_review_data_mov.py b/pype/hosts/nuke/plugins/publish/extract_review_data_mov.py index e9ac3c2c84..c64c7adc93 100644 --- a/pype/hosts/nuke/plugins/publish/extract_review_data_mov.py +++ b/pype/hosts/nuke/plugins/publish/extract_review_data_mov.py @@ -1,7 +1,7 @@ import os import pyblish.api from avalon.nuke import lib as anlib -from pype.hosts.nuke import lib as pnlib +from pype.hosts.nuke.api import lib as pnlib import pype diff --git a/pype/hosts/nuke/plugins/publish/precollect_instances.py b/pype/hosts/nuke/plugins/publish/precollect_instances.py index 60e90002da..1084eec620 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_instances.py +++ b/pype/hosts/nuke/plugins/publish/precollect_instances.py @@ -8,7 +8,7 @@ from avalon.nuke import lib as anlib class PreCollectNukeInstances(pyblish.api.ContextPlugin): """Collect all nodes with Avalon knob.""" - order = pyblish.api.CollectorOrder - 0.6 + order = pyblish.api.CollectorOrder - 0.59 label = "Pre-collect Instances" hosts = ["nuke", "nukeassist"] @@ -36,7 +36,6 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): self.log.warning(E) # get data from avalon knob - self.log.debug("node[name]: {}".format(node['name'].value())) avalon_knob_data = anlib.get_avalon_knob_data( node, ["avalon:", "ak:"]) @@ -69,6 +68,12 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): instance = context.create_instance(subset) instance.append(node) + # get review knob value + review = False + if "review" in node.knobs(): + review = node["review"].value() + families.append("review") + # Add all nodes in group instances. if node.Class() == "Group": # only alter families for render family @@ -119,10 +124,15 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): "resolutionWidth": resolution_width, "resolutionHeight": resolution_height, "pixelAspect": pixel_aspect, + "review": review }) self.log.info("collected instance: {}".format(instance.data)) instances.append(instance) - context.data["instances"] = instances + # create instances in context data if not are created yet + if not context.data.get("instances"): + context.data["instances"] = list() + + context.data["instances"].extend(instances) self.log.debug("context: {}".format(context)) diff --git a/pype/hosts/nuke/plugins/publish/collect_workfile.py b/pype/hosts/nuke/plugins/publish/precollect_workfile.py similarity index 79% rename from pype/hosts/nuke/plugins/publish/collect_workfile.py rename to pype/hosts/nuke/plugins/publish/precollect_workfile.py index b95edf0a93..4b90587bbb 100644 --- a/pype/hosts/nuke/plugins/publish/collect_workfile.py +++ b/pype/hosts/nuke/plugins/publish/precollect_workfile.py @@ -2,32 +2,31 @@ import nuke import pyblish.api import os -from avalon.nuke import ( - get_avalon_knob_data, - add_publish_knob -) +from avalon.nuke import lib as anlib +reload(anlib) class CollectWorkfile(pyblish.api.ContextPlugin): """Collect current script for publish.""" - order = pyblish.api.CollectorOrder + 0.1 - label = "Collect Workfile" + order = pyblish.api.CollectorOrder - 0.60 + label = "Pre-collect Workfile" hosts = ['nuke'] def process(self, context): root = nuke.root() - knob_data = get_avalon_knob_data(root) + current_file = os.path.normpath(nuke.root().name()) - add_publish_knob(root) + knob_data = anlib.get_avalon_knob_data(root) + + anlib.add_publish_knob(root) family = "workfile" task = os.getenv("AVALON_TASK", None) # creating instances per write node - file_path = context.data["currentFile"] - staging_dir = os.path.dirname(file_path) - base_name = os.path.basename(file_path) + staging_dir = os.path.dirname(current_file) + base_name = os.path.basename(current_file) subset = family + task.capitalize() # Get frame range @@ -62,6 +61,8 @@ class CollectWorkfile(pyblish.api.ContextPlugin): "handleEnd": handle_end, "step": 1, "fps": root['fps'].value(), + + "currentFile": current_file } context.data.update(script_data) @@ -90,4 +91,9 @@ class CollectWorkfile(pyblish.api.ContextPlugin): instance.data["representations"].append(representation) self.log.info('Publishing script version') + + # create instances in context data if not are created yet + if not context.data.get("instances"): + context.data["instances"] = list() + context.data["instances"].append(instance) diff --git a/pype/hosts/nuke/plugins/publish/collect_writes.py b/pype/hosts/nuke/plugins/publish/precollect_writes.py similarity index 90% rename from pype/hosts/nuke/plugins/publish/collect_writes.py rename to pype/hosts/nuke/plugins/publish/precollect_writes.py index fb00aeb1ae..93865d534d 100644 --- a/pype/hosts/nuke/plugins/publish/collect_writes.py +++ b/pype/hosts/nuke/plugins/publish/precollect_writes.py @@ -1,14 +1,15 @@ import os import nuke import pyblish.api +import pype.api as pype @pyblish.api.log class CollectNukeWrites(pyblish.api.InstancePlugin): """Collect all write nodes.""" - order = pyblish.api.CollectorOrder + 0.1 - label = "Collect Writes" + order = pyblish.api.CollectorOrder - 0.58 + label = "Pre-collect Writes" hosts = ["nuke", "nukeassist"] families = ["write"] @@ -39,11 +40,11 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): # Get frame range handle_start = instance.context.data["handleStart"] handle_end = instance.context.data["handleEnd"] + current_file = instance.context.data["currentFile"] first_frame = int(nuke.root()["first_frame"].getValue()) last_frame = int(nuke.root()["last_frame"].getValue()) - frame_length = int( - last_frame - first_frame + 1 - ) + frame_length = int(last_frame - first_frame + 1) + review = instance.data["review"] if node["use_limit"].getValue(): first_frame = int(node["first"].getValue()) @@ -58,7 +59,7 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): if "prerender" in f), None) and self.sync_workfile_version: # get version to instance for integration - instance.data['version'] = instance.context.data["version"] + instance.data['version'] = pype.get_version_from_path(current_file) self.log.debug('Write Version: %s' % instance.data('version')) @@ -79,7 +80,8 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): representation = { 'name': ext, 'ext': ext, - "stagingDir": output_dir + "stagingDir": output_dir, + "tags": list() } try: @@ -108,6 +110,10 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): collected_frames.insert(0, slate_frame) representation['files'] = collected_frames + # add review if any + if review: + representation["tags"].extend(["review", "ftrackreview"]) + instance.data["representations"].append(representation) except Exception: instance.data["representations"].append(representation) From 8699e274a99e81c51766ffc7a60b10eb59b76e9a Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 14:20:06 +0100 Subject: [PATCH 35/44] nuke: adding precollect intances to settings adding defalut version sync bool --- pype/settings/defaults/project_settings/nuke.json | 3 +++ .../projects_schema/schema_project_nuke.json | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pype/settings/defaults/project_settings/nuke.json b/pype/settings/defaults/project_settings/nuke.json index 76a95d2140..94cd712639 100644 --- a/pype/settings/defaults/project_settings/nuke.json +++ b/pype/settings/defaults/project_settings/nuke.json @@ -8,6 +8,9 @@ } }, "publish": { + "PreCollectNukeInstances": { + "sync_workfile_version": true + }, "ExtractThumbnail": { "enabled": true, "nodes": { diff --git a/pype/tools/settings/settings/gui_schemas/projects_schema/schema_project_nuke.json b/pype/tools/settings/settings/gui_schemas/projects_schema/schema_project_nuke.json index 9bec54fa36..7a6960bcbd 100644 --- a/pype/tools/settings/settings/gui_schemas/projects_schema/schema_project_nuke.json +++ b/pype/tools/settings/settings/gui_schemas/projects_schema/schema_project_nuke.json @@ -47,6 +47,20 @@ "key": "publish", "label": "Publish plugins", "children": [ + { + "type": "dict", + "collapsable": true, + "key": "PreCollectNukeInstances", + "label": "PreCollectNukeInstances", + "is_group": true, + "children": [ + { + "type": "boolean", + "key": "sync_workfile_version", + "label": "Sync Version from workfile" + } + ] + }, { "type": "dict", "collapsable": true, From 5eac2364cc94548e4c7fcff61ea2e010e63c4072 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 14:21:17 +0100 Subject: [PATCH 36/44] nuke reducing nodes and moving args to precollect --- .../nuke/plugins/publish/collect_host.py | 14 ----- .../plugins/publish/collect_host_version.py | 13 ----- .../plugins/publish/collect_legacy_read.py | 30 ----------- .../nuke/plugins/publish/collect_review.py | 52 ------------------- .../nuke/plugins/publish/collect_selection.py | 14 ----- .../plugins/publish/precollect_workfile.py | 8 ++- .../nuke/plugins/publish/precollect_writes.py | 29 +++++++---- 7 files changed, 26 insertions(+), 134 deletions(-) delete mode 100644 pype/hosts/nuke/plugins/publish/collect_host.py delete mode 100644 pype/hosts/nuke/plugins/publish/collect_host_version.py delete mode 100644 pype/hosts/nuke/plugins/publish/collect_legacy_read.py delete mode 100644 pype/hosts/nuke/plugins/publish/collect_review.py delete mode 100644 pype/hosts/nuke/plugins/publish/collect_selection.py diff --git a/pype/hosts/nuke/plugins/publish/collect_host.py b/pype/hosts/nuke/plugins/publish/collect_host.py deleted file mode 100644 index 3ae41ab3e4..0000000000 --- a/pype/hosts/nuke/plugins/publish/collect_host.py +++ /dev/null @@ -1,14 +0,0 @@ -import pyblish.api - - -class CollectHost(pyblish.api.ContextPlugin): - """Inject the host into context""" - - order = pyblish.api.CollectorOrder - label = "Collect Host" - hosts = ["nuke"] - - def process(self, context): - import pyblish.api - - context.data["host"] = pyblish.api.current_host() diff --git a/pype/hosts/nuke/plugins/publish/collect_host_version.py b/pype/hosts/nuke/plugins/publish/collect_host_version.py deleted file mode 100644 index 8d2cb576b2..0000000000 --- a/pype/hosts/nuke/plugins/publish/collect_host_version.py +++ /dev/null @@ -1,13 +0,0 @@ -import pyblish.api - - -class CollectHostVersion(pyblish.api.ContextPlugin): - """Inject the hosts version into context""" - - order = pyblish.api.CollectorOrder - label = "Collect Host Version" - hosts = ["nuke"] - - def process(self, context): - import nuke - context.data["hostVersion"] = nuke.NUKE_VERSION_STRING diff --git a/pype/hosts/nuke/plugins/publish/collect_legacy_read.py b/pype/hosts/nuke/plugins/publish/collect_legacy_read.py deleted file mode 100644 index 6b6ce57245..0000000000 --- a/pype/hosts/nuke/plugins/publish/collect_legacy_read.py +++ /dev/null @@ -1,30 +0,0 @@ -import toml - -import nuke - -import pyblish.api - - -class CollectReadLegacy(pyblish.api.ContextPlugin): - """Collect legacy read nodes.""" - - order = pyblish.api.CollectorOrder - label = "Collect Read Legacy" - hosts = ["nuke", "nukeassist"] - - def process(self, context): - - for node in nuke.allNodes(): - if node.Class() != "Read": - continue - - if "avalon" not in node.knobs().keys(): - continue - - if not toml.loads(node["avalon"].value()): - return - - instance = context.create_instance( - node.name(), family="read.legacy" - ) - instance.append(node) diff --git a/pype/hosts/nuke/plugins/publish/collect_review.py b/pype/hosts/nuke/plugins/publish/collect_review.py deleted file mode 100644 index 42aa910917..0000000000 --- a/pype/hosts/nuke/plugins/publish/collect_review.py +++ /dev/null @@ -1,52 +0,0 @@ -import pyblish.api -import pype.api -from avalon import io, api - -import nuke - - -class CollectReview(pyblish.api.InstancePlugin): - """Collect review instance from rendered frames - """ - - order = pyblish.api.CollectorOrder + 0.3 - label = "Collect Review" - hosts = ["nuke"] - families = ["render", "render.local", "render.farm"] - - def process(self, instance): - - node = instance[0] - - if "review" not in node.knobs(): - knob = nuke.Boolean_Knob("review", "Review") - knob.setValue(True) - node.addKnob(knob) - - if not node["review"].value(): - return - - # * Add audio to instance if exists. - # Find latest versions document - version_doc = pype.api.get_latest_version( - instance.context.data["assetEntity"]["name"], "audioMain" - ) - repre_doc = None - if version_doc: - # Try to find it's representation (Expected there is only one) - repre_doc = io.find_one( - {"type": "representation", "parent": version_doc["_id"]} - ) - - # Add audio to instance if representation was found - if repre_doc: - instance.data["audio"] = [{ - "offset": 0, - "filename": api.get_representation_path(repre_doc) - }] - - instance.data["families"].append("review") - instance.data['families'].append('ftrack') - - self.log.info("Review collected: `{}`".format(instance)) - self.log.debug("__ instance.data: `{}`".format(instance.data)) diff --git a/pype/hosts/nuke/plugins/publish/collect_selection.py b/pype/hosts/nuke/plugins/publish/collect_selection.py deleted file mode 100644 index a8a4f44b1c..0000000000 --- a/pype/hosts/nuke/plugins/publish/collect_selection.py +++ /dev/null @@ -1,14 +0,0 @@ -import nuke - -import pyblish.api - - -class CollectSelection(pyblish.api.ContextPlugin): - """Collect selection.""" - - order = pyblish.api.CollectorOrder - label = "Collect Selection of Nodes" - hosts = ["nuke"] - - def process(self, context): - context.data["selection"] = nuke.selectedNodes() diff --git a/pype/hosts/nuke/plugins/publish/precollect_workfile.py b/pype/hosts/nuke/plugins/publish/precollect_workfile.py index 4b90587bbb..c570254f12 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_workfile.py +++ b/pype/hosts/nuke/plugins/publish/precollect_workfile.py @@ -1,7 +1,7 @@ import nuke import pyblish.api import os - +import pype.api as pype from avalon.nuke import lib as anlib reload(anlib) @@ -62,7 +62,11 @@ class CollectWorkfile(pyblish.api.ContextPlugin): "step": 1, "fps": root['fps'].value(), - "currentFile": current_file + "currentFile": current_file, + "version": pype.get_version_from_path(current_file), + + "host": pyblish.api.current_host(), + "hostVersion": nuke.NUKE_VERSION_STRING } context.data.update(script_data) diff --git a/pype/hosts/nuke/plugins/publish/precollect_writes.py b/pype/hosts/nuke/plugins/publish/precollect_writes.py index 93865d534d..e7b1a30e01 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_writes.py +++ b/pype/hosts/nuke/plugins/publish/precollect_writes.py @@ -2,6 +2,7 @@ import os import nuke import pyblish.api import pype.api as pype +from avalon import io, api @pyblish.api.log @@ -40,7 +41,6 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): # Get frame range handle_start = instance.context.data["handleStart"] handle_end = instance.context.data["handleEnd"] - current_file = instance.context.data["currentFile"] first_frame = int(nuke.root()["first_frame"].getValue()) last_frame = int(nuke.root()["last_frame"].getValue()) frame_length = int(last_frame - first_frame + 1) @@ -55,14 +55,6 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): output_dir = os.path.dirname(path) self.log.debug('output dir: {}'.format(output_dir)) - if not next((f for f in families - if "prerender" in f), - None) and self.sync_workfile_version: - # get version to instance for integration - instance.data['version'] = pype.get_version_from_path(current_file) - - self.log.debug('Write Version: %s' % instance.data('version')) - # create label name = node.name() # Include start and end render frame in label @@ -158,6 +150,25 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): "families": [] }) + # * Add audio to instance if exists. + # Find latest versions document + version_doc = pype.get_latest_version( + instance.data["asset"], "audioMain" + ) + repre_doc = None + if version_doc: + # Try to find it's representation (Expected there is only one) + repre_doc = io.find_one( + {"type": "representation", "parent": version_doc["_id"]} + ) + + # Add audio to instance if representation was found + if repre_doc: + instance.data["audio"] = [{ + "offset": 0, + "filename": api.get_representation_path(repre_doc) + }] + self.log.debug("families: {}".format(families)) self.log.debug("instance.data: {}".format(instance.data)) From b9d80ba01f802b14cdb5da12747f15ecfc7a4564 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 14:21:45 +0100 Subject: [PATCH 37/44] nuke version to instance additional --- pype/hosts/nuke/plugins/publish/collect_gizmo.py | 5 ----- pype/hosts/nuke/plugins/publish/collect_reads.py | 4 ++-- pype/hosts/nuke/plugins/publish/precollect_instances.py | 9 +++++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pype/hosts/nuke/plugins/publish/collect_gizmo.py b/pype/hosts/nuke/plugins/publish/collect_gizmo.py index 6436bdc562..bd47e63419 100644 --- a/pype/hosts/nuke/plugins/publish/collect_gizmo.py +++ b/pype/hosts/nuke/plugins/publish/collect_gizmo.py @@ -29,10 +29,6 @@ class CollectGizmo(pyblish.api.InstancePlugin): first_frame = int(nuke.root()["first_frame"].getValue()) last_frame = int(nuke.root()["last_frame"].getValue()) - # get version - version = pype.get_version_from_path(nuke.root().name()) - instance.data['version'] = int(version) - # Add version data to instance version_data = { "handles": handle_start, @@ -41,7 +37,6 @@ class CollectGizmo(pyblish.api.InstancePlugin): "frameStart": first_frame + handle_start, "frameEnd": last_frame - handle_end, "colorspace": nuke.root().knob('workingSpaceLUT').value(), - "version": int(version), "families": [instance.data["family"]] + instance.data["families"], "subset": instance.data["subset"], "fps": instance.context.data["fps"] diff --git a/pype/hosts/nuke/plugins/publish/collect_reads.py b/pype/hosts/nuke/plugins/publish/collect_reads.py index 7fda6334bb..45e9969eb9 100644 --- a/pype/hosts/nuke/plugins/publish/collect_reads.py +++ b/pype/hosts/nuke/plugins/publish/collect_reads.py @@ -10,7 +10,7 @@ class CollectNukeReads(pyblish.api.InstancePlugin): """Collect all read nodes.""" order = pyblish.api.CollectorOrder + 0.04 - label = "Collect Reads" + label = "Collect Source Reads" hosts = ["nuke", "nukeassist"] families = ["source"] @@ -109,7 +109,7 @@ class CollectNukeReads(pyblish.api.InstancePlugin): "handleEnd": handle_end, "frameStart": first_frame + handle_start, "frameEnd": last_frame - handle_end, - "colorspace": colorspace, + "colorspace": colorspace, "families": [instance.data["family"]], "subset": instance.data["subset"], "fps": instance.context.data["fps"] diff --git a/pype/hosts/nuke/plugins/publish/precollect_instances.py b/pype/hosts/nuke/plugins/publish/precollect_instances.py index 1084eec620..1333b19365 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_instances.py +++ b/pype/hosts/nuke/plugins/publish/precollect_instances.py @@ -12,6 +12,9 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): label = "Pre-collect Instances" hosts = ["nuke", "nukeassist"] + # presets + sync_workfile_version = False + def process(self, context): asset_data = io.find_one({ "type": "asset", @@ -109,6 +112,12 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): resolution_height = format.height() pixel_aspect = format.pixelAspect() + if not next((f for f in families + if "prerender" in f), + None) and self.sync_workfile_version: + # get version to instance for integration + instance.data['version'] = instance.context.data['version'] + instance.data.update({ "subset": subset, "asset": avalon_knob_data["asset"], From 0ddd4f904acd05daf8a803e444330c122c0d2e53 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 15:38:08 +0100 Subject: [PATCH 38/44] nuke fixing module import to new `api` host way and other small fixes --- pype/hosts/nuke/plugins/load/actions.py | 4 ++-- pype/hosts/nuke/plugins/load/load_backdrop.py | 2 +- pype/hosts/nuke/plugins/load/load_gizmo_ip.py | 2 +- pype/hosts/nuke/plugins/publish/collect_backdrop.py | 10 +++++----- pype/hosts/nuke/plugins/publish/extract_backdrop.py | 6 +++--- pype/hosts/nuke/plugins/publish/extract_gizmo.py | 3 +-- .../nuke/plugins/publish/extract_review_data_lut.py | 2 +- .../nuke/plugins/publish/precollect_instances.py | 9 +++++++-- .../hosts/nuke/plugins/publish/precollect_workfile.py | 2 +- pype/hosts/nuke/plugins/publish/validate_backdrop.py | 11 ++++++----- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/pype/hosts/nuke/plugins/load/actions.py b/pype/hosts/nuke/plugins/load/actions.py index d0c95b6b16..9741e956fa 100644 --- a/pype/hosts/nuke/plugins/load/actions.py +++ b/pype/hosts/nuke/plugins/load/actions.py @@ -25,7 +25,7 @@ class SetFrameRangeLoader(api.Loader): def load(self, context, name, namespace, data): - from pype.hosts.nuke import lib + from pype.hosts.nuke.api import lib version = context['version'] version_data = version.get("data", {}) @@ -59,7 +59,7 @@ class SetFrameRangeWithHandlesLoader(api.Loader): def load(self, context, name, namespace, data): - from pype.hosts.nuke import lib + from pype.hosts.nuke.api import lib version = context['version'] version_data = version.get("data", {}) diff --git a/pype/hosts/nuke/plugins/load/load_backdrop.py b/pype/hosts/nuke/plugins/load/load_backdrop.py index 7d18893965..00bf2df47d 100644 --- a/pype/hosts/nuke/plugins/load/load_backdrop.py +++ b/pype/hosts/nuke/plugins/load/load_backdrop.py @@ -1,7 +1,7 @@ from avalon import api, style, io import nuke import nukescripts -from pype.hosts.nuke import lib as pnlib +from pype.hosts.nuke.api import lib as pnlib from avalon.nuke import lib as anlib from avalon.nuke import containerise, update_container reload(pnlib) diff --git a/pype/hosts/nuke/plugins/load/load_gizmo_ip.py b/pype/hosts/nuke/plugins/load/load_gizmo_ip.py index a2e8a6abb8..b1a9748d16 100644 --- a/pype/hosts/nuke/plugins/load/load_gizmo_ip.py +++ b/pype/hosts/nuke/plugins/load/load_gizmo_ip.py @@ -1,6 +1,6 @@ from avalon import api, style, io import nuke -from pype.hosts.nuke import lib as pnlib +from pype.hosts.nuke.api import lib as pnlib from avalon.nuke import lib as anlib from avalon.nuke import containerise, update_container diff --git a/pype/hosts/nuke/plugins/publish/collect_backdrop.py b/pype/hosts/nuke/plugins/publish/collect_backdrop.py index 5a117c2920..7e616ea7bb 100644 --- a/pype/hosts/nuke/plugins/publish/collect_backdrop.py +++ b/pype/hosts/nuke/plugins/publish/collect_backdrop.py @@ -1,8 +1,8 @@ import pyblish.api -import pype.api as pype -from pype.hosts.nuke import lib as pnlib +from pype.hosts.nuke.api import lib as pnlib import nuke + @pyblish.api.log class CollectBackdrops(pyblish.api.InstancePlugin): """Collect Backdrop node instance and its content @@ -42,12 +42,12 @@ class CollectBackdrops(pyblish.api.InstancePlugin): # get all connections from outside of backdrop nodes = instance[1:] connections_in, connections_out = pnlib.get_dependent_nodes(nodes) - instance.data["connections_in"] = connections_in - instance.data["connections_out"] = connections_out + instance.data["nodeConnectionsIn"] = connections_in + instance.data["nodeConnectionsOut"] = connections_out # make label nicer instance.data["label"] = "{0} ({1} nodes)".format( - bckn.name(), len(instance)-1) + bckn.name(), len(instance) - 1) instance.data["families"].append(instance.data["family"]) diff --git a/pype/hosts/nuke/plugins/publish/extract_backdrop.py b/pype/hosts/nuke/plugins/publish/extract_backdrop.py index 0f7198887f..92153d563e 100644 --- a/pype/hosts/nuke/plugins/publish/extract_backdrop.py +++ b/pype/hosts/nuke/plugins/publish/extract_backdrop.py @@ -1,6 +1,6 @@ import pyblish.api from avalon.nuke import lib as anlib -from pype.hosts.nuke import lib as pnlib +from pype.hosts.nuke.api import lib as pnlib import nuke import os import pype @@ -30,8 +30,8 @@ class ExtractBackdropNode(pype.api.Extractor): # maintain selection with anlib.maintained_selection(): # all connections outside of backdrop - connections_in = instance.data["connections_in"] - connections_out = instance.data["connections_out"] + connections_in = instance.data["nodeConnectionsIn"] + connections_out = instance.data["nodeConnectionsOut"] self.log.debug("_ connections_in: `{}`".format(connections_in)) self.log.debug("_ connections_out: `{}`".format(connections_out)) diff --git a/pype/hosts/nuke/plugins/publish/extract_gizmo.py b/pype/hosts/nuke/plugins/publish/extract_gizmo.py index 465bf9824c..32d9dd0f55 100644 --- a/pype/hosts/nuke/plugins/publish/extract_gizmo.py +++ b/pype/hosts/nuke/plugins/publish/extract_gizmo.py @@ -1,7 +1,6 @@ import pyblish.api from avalon.nuke import lib as anlib -from pype.hosts.nuke import lib as pnlib -from pype.hosts.nuke import utils as pnutils +from pype.hosts.nuke.api import utils as pnutils import nuke import os import pype diff --git a/pype/hosts/nuke/plugins/publish/extract_review_data_lut.py b/pype/hosts/nuke/plugins/publish/extract_review_data_lut.py index 10fe8fa2a9..16ef7a9449 100644 --- a/pype/hosts/nuke/plugins/publish/extract_review_data_lut.py +++ b/pype/hosts/nuke/plugins/publish/extract_review_data_lut.py @@ -1,7 +1,7 @@ import os import pyblish.api from avalon.nuke import lib as anlib -from pype.hosts.nuke import lib as pnlib +from pype.hosts.nuke.api import lib as pnlib import pype reload(pnlib) diff --git a/pype/hosts/nuke/plugins/publish/precollect_instances.py b/pype/hosts/nuke/plugins/publish/precollect_instances.py index 1333b19365..d8c593b0b6 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_instances.py +++ b/pype/hosts/nuke/plugins/publish/precollect_instances.py @@ -52,7 +52,7 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): # establish families family = avalon_knob_data["family"] - families_ak = avalon_knob_data.get("families") + families_ak = avalon_knob_data.get("families") or [] families = list() if families_ak: @@ -112,6 +112,11 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): resolution_height = format.height() pixel_aspect = format.pixelAspect() + # get publish knob value + if "publish" not in node.knobs(): + anlib.add_publish_knob(node) + + # sync workfile version if not next((f for f in families if "prerender" in f), None) and self.sync_workfile_version: @@ -127,8 +132,8 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): "family": family, "families": families, "avalonKnob": avalon_knob_data, - "publish": node.knob('publish').value(), "step": 1, + "publish": node.knob('publish').value(), "fps": nuke.root()['fps'].value(), "resolutionWidth": resolution_width, "resolutionHeight": resolution_height, diff --git a/pype/hosts/nuke/plugins/publish/precollect_workfile.py b/pype/hosts/nuke/plugins/publish/precollect_workfile.py index c570254f12..288caa7a19 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_workfile.py +++ b/pype/hosts/nuke/plugins/publish/precollect_workfile.py @@ -63,7 +63,7 @@ class CollectWorkfile(pyblish.api.ContextPlugin): "fps": root['fps'].value(), "currentFile": current_file, - "version": pype.get_version_from_path(current_file), + "version": int(pype.get_version_from_path(current_file)), "host": pyblish.api.current_host(), "hostVersion": nuke.NUKE_VERSION_STRING diff --git a/pype/hosts/nuke/plugins/publish/validate_backdrop.py b/pype/hosts/nuke/plugins/publish/validate_backdrop.py index cf2d56087d..f280ad4af1 100644 --- a/pype/hosts/nuke/plugins/publish/validate_backdrop.py +++ b/pype/hosts/nuke/plugins/publish/validate_backdrop.py @@ -32,8 +32,8 @@ class SelectCenterInNodeGraph(pyblish.api.Action): # collect all failed nodes xpos and ypos for instance in instances: bdn = instance[0] - xC = bdn.xpos() + bdn.screenWidth()/2 - yC = bdn.ypos() + bdn.screenHeight()/2 + xC = bdn.xpos() + bdn.screenWidth() / 2 + yC = bdn.ypos() + bdn.screenHeight() / 2 all_xC.append(xC) all_yC.append(yC) @@ -58,10 +58,11 @@ class ValidateBackdrop(pyblish.api.InstancePlugin): actions = [SelectCenterInNodeGraph] def process(self, instance): - connections_out = instance.data["connections_out"] + connections_out = instance.data["nodeConnectionsOut"] - msg_multiple_outputs = "Only one outcoming connection from \"{}\" is allowed".format( - instance.data["name"]) + msg_multiple_outputs = ( + "Only one outcoming connection from " + "\"{}\" is allowed").format(instance.data["name"]) assert len(connections_out.keys()) <= 1, msg_multiple_outputs msg_no_content = "No content on backdrop node: \"{}\"".format( From f924b1a1425209792417b07cf4cf6ce3e7f6e1b6 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 16:39:35 +0100 Subject: [PATCH 39/44] nuke fixing node families definition --- pype/hosts/nuke/plugins/publish/collect_gizmo.py | 1 - pype/hosts/nuke/plugins/publish/precollect_instances.py | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pype/hosts/nuke/plugins/publish/collect_gizmo.py b/pype/hosts/nuke/plugins/publish/collect_gizmo.py index bd47e63419..3db26096ae 100644 --- a/pype/hosts/nuke/plugins/publish/collect_gizmo.py +++ b/pype/hosts/nuke/plugins/publish/collect_gizmo.py @@ -1,5 +1,4 @@ import pyblish.api -import pype.api as pype import nuke diff --git a/pype/hosts/nuke/plugins/publish/precollect_instances.py b/pype/hosts/nuke/plugins/publish/precollect_instances.py index d8c593b0b6..2f5edd7fe8 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_instances.py +++ b/pype/hosts/nuke/plugins/publish/precollect_instances.py @@ -52,7 +52,7 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): # establish families family = avalon_knob_data["family"] - families_ak = avalon_knob_data.get("families") or [] + families_ak = avalon_knob_data.get("families") families = list() if families_ak: @@ -76,11 +76,12 @@ class PreCollectNukeInstances(pyblish.api.ContextPlugin): if "review" in node.knobs(): review = node["review"].value() families.append("review") + families.append("ftrack") # Add all nodes in group instances. if node.Class() == "Group": - # only alter families for render family - if "write" in families_ak: + # check if it is write node in family + if "write" in families: target = node["render"].value() if target == "Use existing frames": # Local rendering From 43f363e6aa7e78c0154b731d53ac3b74423625fe Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 17:29:40 +0100 Subject: [PATCH 40/44] nuke, hiero, nukestudo changing settings env --- .../system_settings/applications.json | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pype/settings/defaults/system_settings/applications.json b/pype/settings/defaults/system_settings/applications.json index b5f82c0593..641c9f25da 100644 --- a/pype/settings/defaults/system_settings/applications.json +++ b/pype/settings/defaults/system_settings/applications.json @@ -362,17 +362,19 @@ "__environment_keys__": { "nukex": [ "NUKE_PATH", - "PATH" + "PATH", + "LOGLEVEL" ] }, "NUKE_PATH": [ - "{PYPE_MODULE_ROOT}/repos/avalon-core/setup/nuke/nuke_path", - "{PYPE_MODULE_ROOT}/setup/nuke/nuke_path", + "{PYPE_ROOT}/repos/avalon-core/setup/nuke/nuke_path", + "{PYPE_ROOT}/pype/hosts/nuke/startup", "{PYPE_STUDIO_PLUGINS}/nuke" ], "PATH": { "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" - } + }, + "LOGLEVEL": "DEBUG" }, "variants": { "nukex_12.2": { @@ -488,18 +490,18 @@ "PATH", "WORKFILES_STARTUP", "TAG_ASSETBUILD_STARTUP", - "PYPE_LOG_NO_COLORS" + "LOGLEVEL" ] }, "HIERO_PLUGIN_PATH": [ - "{PYPE_MODULE_ROOT}/setup/nukestudio/hiero_plugin_path" + "{PYPE_MODULE_ROOT}/setup/hiero/hiero_plugin_path" ], "PATH": { "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" }, "WORKFILES_STARTUP": "0", "TAG_ASSETBUILD_STARTUP": "0", - "PYPE_LOG_NO_COLORS": "True" + "LOGLEVEL": "DEBUG" }, "variants": { "nukestudio_12.2": { @@ -610,18 +612,18 @@ "PATH", "WORKFILES_STARTUP", "TAG_ASSETBUILD_STARTUP", - "PYPE_LOG_NO_COLORS" + "LOGLEVEL" ] }, "HIERO_PLUGIN_PATH": [ - "{PYPE_MODULE_ROOT}/setup/nukestudio/hiero_plugin_path" + "{PYPE_MODULE_ROOT}/setup/hiero/hiero_plugin_path" ], "PATH": { "windows": "C:/Program Files (x86)/QuickTime/QTSystem/;{PATH}" }, "WORKFILES_STARTUP": "0", "TAG_ASSETBUILD_STARTUP": "0", - "PYPE_LOG_NO_COLORS": "True" + "LOGLEVEL": "DEBUG" }, "variants": { "hiero_12.2": { From ba927f421e8fa9b2b0b32e0b572018de74dfcaa0 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 20 Jan 2021 18:07:05 +0100 Subject: [PATCH 41/44] nuke fix review on write node --- pype/hosts/nuke/plugins/publish/precollect_writes.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pype/hosts/nuke/plugins/publish/precollect_writes.py b/pype/hosts/nuke/plugins/publish/precollect_writes.py index e7b1a30e01..9806e38633 100644 --- a/pype/hosts/nuke/plugins/publish/precollect_writes.py +++ b/pype/hosts/nuke/plugins/publish/precollect_writes.py @@ -44,7 +44,6 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): first_frame = int(nuke.root()["first_frame"].getValue()) last_frame = int(nuke.root()["last_frame"].getValue()) frame_length = int(last_frame - first_frame + 1) - review = instance.data["review"] if node["use_limit"].getValue(): first_frame = int(node["first"].getValue()) @@ -102,10 +101,6 @@ class CollectNukeWrites(pyblish.api.InstancePlugin): collected_frames.insert(0, slate_frame) representation['files'] = collected_frames - # add review if any - if review: - representation["tags"].extend(["review", "ftrackreview"]) - instance.data["representations"].append(representation) except Exception: instance.data["representations"].append(representation) From 8c4879a7254cebb1be312c1dca8229868bb8b32d Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 22 Jan 2021 12:11:05 +0100 Subject: [PATCH 42/44] fix submodules --- .gitmodules | 2 +- repos/acre | 1 - repos/avalon-core | 2 +- repos/pyblish-base | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) delete mode 160000 repos/acre delete mode 160000 repos/pyblish-base diff --git a/.gitmodules b/.gitmodules index 20aa3a3e8d..a282ef169d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,4 +13,4 @@ url = https://bitbucket.org/ftrack/ftrack-python-api.git [submodule "pype/modules/ftrack/python2_vendor/arrow"] path = pype/modules/ftrack/python2_vendor/arrow - url = git@github.com:arrow-py/arrow.git + url = git@github.com:arrow-py/arrow.git \ No newline at end of file diff --git a/repos/acre b/repos/acre deleted file mode 160000 index 3d06232bd4..0000000000 --- a/repos/acre +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3d06232bd424df4350efe64ab459944b4096ca74 diff --git a/repos/avalon-core b/repos/avalon-core index 8a19fc31f9..67ff915857 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit 8a19fc31f9f503f63a1b4d6cb90f3690902c2e5d +Subproject commit 67ff9158574223152b9063fb8b74835df37155d1 diff --git a/repos/pyblish-base b/repos/pyblish-base deleted file mode 160000 index 3290fd5b51..0000000000 --- a/repos/pyblish-base +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3290fd5b51b496d431cc2ca608639e21e727ccbd From 8f1dab4188c3a31bccede81a11a9b6e4fcb1368a Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 22 Jan 2021 12:11:19 +0100 Subject: [PATCH 43/44] add foundry license to environments passed to deadline --- pype/modules/deadline/plugins/publish/submit_nuke_deadline.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pype/modules/deadline/plugins/publish/submit_nuke_deadline.py b/pype/modules/deadline/plugins/publish/submit_nuke_deadline.py index 5e5efb6e62..3ef5386e82 100644 --- a/pype/modules/deadline/plugins/publish/submit_nuke_deadline.py +++ b/pype/modules/deadline/plugins/publish/submit_nuke_deadline.py @@ -219,7 +219,8 @@ class NukeSubmitDeadline(pyblish.api.InstancePlugin): "PYBLISHPLUGINPATH", "NUKE_PATH", "TOOL_ENV", - "PYPE_DEV" + "PYPE_DEV", + "FOUNDRY_LICENSE" ] environment = dict({key: os.environ[key] for key in keys if key in os.environ}, **api.Session) From 6e5d7b5846383fa03f71b75edded2c5942f4ba43 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 22 Jan 2021 12:12:13 +0100 Subject: [PATCH 44/44] change avalon-core to develop --- repos/avalon-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/avalon-core b/repos/avalon-core index 67ff915857..964ae5fa71 160000 --- a/repos/avalon-core +++ b/repos/avalon-core @@ -1 +1 @@ -Subproject commit 67ff9158574223152b9063fb8b74835df37155d1 +Subproject commit 964ae5fa7110984d5c0c00ad81c2c108031a7834