nuke load plugins are expecting representation context

This commit is contained in:
Jakub Trllo 2024-02-26 17:54:35 +01:00
parent c575d081e4
commit 05e8ebabe6
11 changed files with 96 additions and 86 deletions

View file

@ -178,7 +178,7 @@ class LoadBackdropNodes(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -189,13 +189,14 @@ class LoadBackdropNodes(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
# get corresponding node
GN = container["node"]
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
name = container['name']
version_data = version_doc.get("data", {})
@ -207,7 +208,7 @@ class LoadBackdropNodes(load.LoaderPlugin):
add_keys = ["source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"version": vname,
"colorspaceInput": colorspace,
}
@ -248,8 +249,8 @@ class LoadBackdropNodes(load.LoaderPlugin):
return update_container(GN, data_imprint)
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = container["node"]

View file

@ -92,7 +92,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""
Called by Scene Inventory when look should be updated to current
version.
@ -109,8 +109,8 @@ class AlembicCameraLoader(load.LoaderPlugin):
None
"""
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
version_doc = context["version"]
repre_doc = context["representation"]
# get main variables
version_data = version_doc.get("data", {})
@ -124,7 +124,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
add_keys = ["source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": first,
"frameEnd": last,
"version": vname
@ -134,7 +134,7 @@ class AlembicCameraLoader(load.LoaderPlugin):
data_imprint.update({k: version_data[k]})
# getting file path
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
with maintained_selection():
camera_node = container["node"]
@ -191,8 +191,8 @@ class AlembicCameraLoader(load.LoaderPlugin):
color_value = "0xd88467ff"
node["tile_color"].setValue(int(color_value, 16))
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = container["node"]

View file

@ -209,8 +209,8 @@ class LoadClip(plugin.NukeLoader):
return container
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def _representation_with_hash_in_frame(self, representation):
"""Convert frame key value to padded hash
@ -241,7 +241,7 @@ class LoadClip(plugin.NukeLoader):
representation["context"]["frame"] = hashed_frame
return representation
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -250,16 +250,18 @@ class LoadClip(plugin.NukeLoader):
"""
is_sequence = len(representation["files"]) > 1
repre_doc = context["representation"]
is_sequence = len(repre_doc["files"]) > 1
read_node = container["node"]
if is_sequence:
representation = self._representation_with_hash_in_frame(
representation
repre_doc = self._representation_with_hash_in_frame(
repre_doc
)
filepath = get_representation_path(representation).replace("\\", "/")
filepath = get_representation_path(repre_doc).replace("\\", "/")
self.log.debug("_ filepath: {}".format(filepath))
start_at_workfile = "start at" in read_node['frame_mode'].value()
@ -270,13 +272,13 @@ class LoadClip(plugin.NukeLoader):
]
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
version_doc = get_version_by_id(project_name, repre_doc["parent"])
version_data = version_doc.get("data", {})
repre_id = representation["_id"]
repre_id = repre_doc["_id"]
# colorspace profile
colorspace = representation["data"].get("colorspace")
colorspace = repre_doc["data"].get("colorspace")
colorspace = colorspace or version_data.get("colorspace")
self.handle_start = version_data.get("handleStart", 0)
@ -303,12 +305,12 @@ class LoadClip(plugin.NukeLoader):
# we will switch off undo-ing
with viewer_update_and_undo_stop():
used_colorspace = self._set_colorspace(
read_node, version_data, representation["data"], filepath)
read_node, version_data, repre_doc["data"], filepath)
self._set_range_to_node(read_node, first, last, start_at_workfile)
updated_dict = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": str(first),
"frameEnd": str(last),
"version": str(version_doc.get("name")),

View file

@ -146,7 +146,7 @@ class LoadEffects(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -156,13 +156,14 @@ class LoadEffects(load.LoaderPlugin):
"""
# get main variables
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
# get corresponding node
GN = container["node"]
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
name = container['name']
version_data = version_doc.get("data", {})
vname = version_doc.get("name", None)
@ -177,7 +178,7 @@ class LoadEffects(load.LoaderPlugin):
"source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": first,
"frameEnd": last,
"version": vname,
@ -344,8 +345,8 @@ class LoadEffects(load.LoaderPlugin):
else:
return input
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = container["node"]

View file

@ -150,7 +150,7 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -161,13 +161,14 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
# get corresponding node
GN = container["node"]
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
version_data = version_doc.get("data", {})
vname = version_doc.get("name", None)
first = version_data.get("frameStart", None)
@ -179,7 +180,7 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
"source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": first,
"frameEnd": last,
"version": vname,
@ -355,8 +356,8 @@ class LoadEffectsInputProcess(load.LoaderPlugin):
else:
return input
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = container["node"]

View file

@ -97,7 +97,7 @@ class LoadGizmo(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -108,13 +108,14 @@ class LoadGizmo(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
# get corresponding node
group_node = container["node"]
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
name = container['name']
version_data = version_doc.get("data", {})
vname = version_doc.get("name", None)
@ -128,7 +129,7 @@ class LoadGizmo(load.LoaderPlugin):
"source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": first,
"frameEnd": last,
"version": vname,
@ -173,8 +174,8 @@ class LoadGizmo(load.LoaderPlugin):
return update_container(new_group_node, data_imprint)
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = container["node"]

View file

@ -104,7 +104,7 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -115,13 +115,14 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
# get main variables
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
# get corresponding node
group_node = container["node"]
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
name = container['name']
version_data = version_doc.get("data", {})
vname = version_doc.get("name", None)
@ -135,7 +136,7 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
"source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": first,
"frameEnd": last,
"version": vname,
@ -254,8 +255,8 @@ class LoadGizmoInputProcess(load.LoaderPlugin):
else:
return input
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = container["node"]

View file

@ -155,10 +155,10 @@ class LoadImage(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -171,12 +171,16 @@ class LoadImage(load.LoaderPlugin):
assert node.Class() == "Read", "Must be Read"
repr_cont = representation["context"]
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
file = get_representation_path(representation)
repr_cont = repre_doc["context"]
file = get_representation_path(repre_doc)
if not file:
repr_id = representation["_id"]
repr_id = repre_doc["_id"]
self.log.warning(
"Representation id `{}` is failing to load".format(repr_id))
return
@ -191,8 +195,6 @@ class LoadImage(load.LoaderPlugin):
format(frame_number, "0{}".format(padding)))
# Get start frame from version data
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
last_version_doc = get_last_version_by_subset_id(
project_name, version_doc["parent"], fields=["_id"]
)
@ -210,7 +212,7 @@ class LoadImage(load.LoaderPlugin):
updated_dict = {}
updated_dict.update({
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": str(first),
"frameEnd": str(last),
"version": str(version_doc.get("name")),

View file

@ -96,7 +96,7 @@ class AlembicModelLoader(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def update(self, container, representation):
def update(self, container, context):
"""
Called by Scene Inventory when look should be updated to current
version.
@ -106,15 +106,15 @@ class AlembicModelLoader(load.LoaderPlugin):
Args:
container: object that has look to be updated
representation: (dict): relationship data to get proper
context: (dict): relationship data to get proper
representation from DB and persisted
data in .json
Returns:
None
"""
# Get version from io
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
version_doc = context["version"]
repre_doc = context["representation"]
# get corresponding node
model_node = container["node"]
@ -131,7 +131,7 @@ class AlembicModelLoader(load.LoaderPlugin):
add_keys = ["source", "author", "fps"]
data_imprint = {
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameStart": first,
"frameEnd": last,
"version": vname
@ -141,7 +141,7 @@ class AlembicModelLoader(load.LoaderPlugin):
data_imprint.update({k: version_data[k]})
# getting file path
file = get_representation_path(representation).replace("\\", "/")
file = get_representation_path(repre_doc).replace("\\", "/")
with maintained_selection():
model_node['selected'].setValue(True)
@ -202,8 +202,8 @@ class AlembicModelLoader(load.LoaderPlugin):
color_value = "0xd88467ff"
node["tile_color"].setValue(int(color_value, 16))
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = nuke.toNode(container['objectName'])

View file

@ -219,14 +219,13 @@ class LoadOcioLookNodes(load.LoaderPlugin):
return group_node
def update(self, container, representation):
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
def update(self, container, context):
version_doc = context["version"]
repre_doc = context["representation"]
group_node = container["node"]
filepath = get_representation_path(representation)
filepath = get_representation_path(repre_doc)
json_f = self._load_json_data(filepath)
@ -242,7 +241,7 @@ class LoadOcioLookNodes(load.LoaderPlugin):
group_node["name"].value()))
return update_container(
group_node, {"representation": str(representation["_id"])})
group_node, {"representation": str(repre_doc["_id"])})
def _load_json_data(self, filepath):
# getting data from json file with unicode conversion
@ -280,8 +279,8 @@ class LoadOcioLookNodes(load.LoaderPlugin):
else:
return input
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def remove(self, container):
node = nuke.toNode(container['objectName'])

View file

@ -104,10 +104,10 @@ class LinkAsGroup(load.LoaderPlugin):
loader=self.__class__.__name__,
data=data_imprint)
def switch(self, container, representation):
self.update(container, representation)
def switch(self, container, context):
self.update(container, context)
def update(self, container, representation):
def update(self, container, context):
"""Update the Loader's path
Nuke automatically tries to reset some variables when changing
@ -117,11 +117,13 @@ class LinkAsGroup(load.LoaderPlugin):
"""
node = container["node"]
root = get_representation_path(representation).replace("\\", "/")
project_name = context["project"]["name"]
version_doc = context["version"]
repre_doc = context["representation"]
root = get_representation_path(repre_doc).replace("\\", "/")
# Get start frame from version data
project_name = get_current_project_name()
version_doc = get_version_by_id(project_name, representation["parent"])
last_version_doc = get_last_version_by_subset_id(
project_name, version_doc["parent"], fields=["_id"]
)
@ -129,7 +131,7 @@ class LinkAsGroup(load.LoaderPlugin):
updated_dict = {}
version_data = version_doc["data"]
updated_dict.update({
"representation": str(representation["_id"]),
"representation": str(repre_doc["_id"]),
"frameEnd": version_data.get("frameEnd"),
"version": version_doc.get("name"),
"colorspace": version_data.get("colorspace"),