Skip to content

Commit

Permalink
Refactor staging directory data passing in publishing instance plugins
Browse files Browse the repository at this point in the history
- Refactored code to pass staging directory data uniformly across multiple instance plugins for consistency and maintainability. Updated the method to handle this data transfer efficiently.
  • Loading branch information
jakubjezek001 committed Sep 13, 2024
1 parent 812c5e4 commit 6701cd7
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 12 deletions.
15 changes: 14 additions & 1 deletion client/ayon_nuke/plugins/publish/collect_gizmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class CollectGizmo(pyblish.api.InstancePlugin):

def process(self, instance):

# pass staging dir data
self._pass_staging_dir_data(instance)

gizmo_node = instance.data["transientData"]["node"]

# add product type to familiess
# add product type to families
instance.data["families"].insert(0, instance.data["productType"])
# make label nicer
instance.data["label"] = gizmo_node.name()
Expand Down Expand Up @@ -47,3 +50,13 @@ def process(self, instance):
"frameEnd": last_frame
})
self.log.debug("Gizmo instance collected: `{}`".format(instance))

def _pass_staging_dir_data(self, instance):
staging_dir = instance.data["transientData"]["stagingDir"]
staging_dir_persistent = instance.data["transientData"].get(
"stagingDir_persistent", False
)
instance.data.update({
"stagingDir": staging_dir,
"stagingDir_persistent": staging_dir_persistent
})
15 changes: 14 additions & 1 deletion client/ayon_nuke/plugins/publish/collect_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class CollectModel(pyblish.api.InstancePlugin):

def process(self, instance):

# pass staging dir data
self._pass_staging_dir_data(instance)

geo_node = instance.data["transientData"]["node"]

# add product type to familiess
# add product type to families
instance.data["families"].insert(0, instance.data["productType"])
# make label nicer
instance.data["label"] = geo_node.name()
Expand Down Expand Up @@ -46,3 +49,13 @@ def process(self, instance):
"frameEnd": last_frame
})
self.log.debug("Model instance collected: `{}`".format(instance))

def _pass_staging_dir_data(self, instance):
staging_dir = instance.data["transientData"]["stagingDir"]
staging_dir_persistent = instance.data["transientData"].get(
"stagingDir_persistent", False
)
instance.data.update({
"stagingDir": staging_dir,
"stagingDir_persistent": staging_dir_persistent
})
13 changes: 13 additions & 0 deletions client/ayon_nuke/plugins/publish/collect_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class CollectNukeReads(pyblish.api.InstancePlugin):
def process(self, instance):
self.log.debug("checking instance: {}".format(instance))

# pass staging dir data
self._pass_staging_dir_data(instance)

node = instance.data["transientData"]["node"]
if node.Class() != "Read":
return
Expand Down Expand Up @@ -122,3 +125,13 @@ def process(self, instance):
})

self.log.debug("instance.data: {}".format(instance.data))

def _pass_staging_dir_data(self, instance):
staging_dir = instance.data["transientData"]["stagingDir"]
staging_dir_persistent = instance.data["transientData"].get(
"stagingDir_persistent", False
)
instance.data.update({
"stagingDir": staging_dir,
"stagingDir_persistent": staging_dir_persistent
})
26 changes: 20 additions & 6 deletions client/ayon_nuke/plugins/publish/collect_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,29 @@ class CollectNukeWrites(pyblish.api.InstancePlugin,
_write_nodes = {}
_frame_ranges = {}

def _pass_staging_dir_data(self, instance):
staging_dir = instance.data["transientData"]["stagingDir"]
instance.data["stagingDir"] = staging_dir

staging_dir_persistent = instance.data["transientData"].get(
"stagingDir_persistent", False
)

if staging_dir_persistent is not None:
instance.data["stagingDir_persistent"] = staging_dir_persistent
else:
# compatibility. This is mainly focused on `renders`folders which
# were previously not cleaned up (and could be used in read notes)
# this logic should be removed and replaced with custom staging dir
instance.data["stagingDir_persistent"] = True

def process(self, instance):

# pass staging dir data
self._pass_staging_dir_data(instance)

group_node = instance.data["transientData"]["node"]

render_target = instance.data["render_target"]

write_node = self._write_node_helper(instance)
Expand Down Expand Up @@ -200,12 +220,6 @@ def _set_additional_instance_data(
"frameEndHandle": last_frame,
})

# TODO temporarily set stagingDir as persistent for backward
# compatibility. This is mainly focused on `renders`folders which
# were previously not cleaned up (and could be used in read notes)
# this logic should be removed and replaced with custom staging dir
instance.data["stagingDir_persistent"] = True

def _write_node_helper(self, instance):
"""Helper function to get write node from instance.
Expand Down
22 changes: 18 additions & 4 deletions client/ayon_nuke/plugins/publish/extract_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def _get_camera_export_presets(self, instance):
write_geo_knobs.append((("storageFormat", "Ogawa")))

elif export_camera_settings == "fbx":
write_geo_knobs.insert(0, ("file_type", "fbx"))
write_geo_knobs.append(("writeLights", False))
write_geo_knobs.insert(0, ("file_type", "fbx"))
write_geo_knobs.append(("writeLights", False))

else:
raise ValueError(
Expand All @@ -53,8 +53,11 @@ def _get_camera_export_presets(self, instance):

return write_geo_knobs


def process(self, instance):

# pass staging dir data
staging_dir = self._pass_staging_dir_data(instance)

camera_node = instance.data["transientData"]["node"]
handle_start = instance.context.data["handleStart"]
handle_end = instance.context.data["handleEnd"]
Expand All @@ -66,7 +69,6 @@ def process(self, instance):
rm_nodes = []
self.log.debug("Creating additional nodes for 3D Camera Extractor")
product_name = instance.data["productName"]
staging_dir = self.staging_dir(instance)

# get extension form preset
export_presets = self._get_camera_export_presets(instance)
Expand Down Expand Up @@ -138,6 +140,18 @@ def process(self, instance):
self.log.debug("Extracted instance '{0}' to: {1}".format(
instance.name, file_path))

def _pass_staging_dir_data(self, instance):
staging_dir = instance.data["transientData"]["stagingDir"]
staging_dir_persistent = instance.data["transientData"].get(
"stagingDir_persistent", False
)
instance.data.update({
"stagingDir": staging_dir,
"stagingDir_persistent": staging_dir_persistent
})

return staging_dir


def bakeCameraWithAxeses(camera_node, output_range):
""" Baking all perent hierarchy of axeses into camera
Expand Down

0 comments on commit 6701cd7

Please sign in to comment.