Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Houdini: Sync publisher attributes with node parameters #418

Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d11a7b2
add update_node_parameters and use it from plugins inside update_inst…
MustafaJafar Apr 15, 2024
bcafa9e
implement update_node_parameters and refactor CreateRedshiftROP a lit…
MustafaJafar Apr 15, 2024
c7edb52
undo some changes from another PR
MustafaJafar Apr 15, 2024
ae7097b
implement update_node_parameters and refactor CreateBGEO a little bit
MustafaJafar Apr 15, 2024
8986b56
implement update_node_parameters and refactor CreateArnoldRop a littl…
MustafaJafar Apr 15, 2024
effce17
Merge branch 'develop' into enhancement/update_houdini_node_parms_on_…
MustafaJafar Apr 18, 2024
bfdcf02
add missing attribute defs
MustafaJafar Apr 18, 2024
1b5ae59
refactor some of rs creator logic
MustafaJafar Apr 18, 2024
eda3b88
refactor logic of udpate_instances to use the same object instead of …
MustafaJafar Apr 18, 2024
518024b
Merge branch 'enhancement/update_houdini_node_parms_on_creator_attrib…
MustafaJafar Apr 18, 2024
ad16bdf
only update node parameters if changes include 'creator_attributes'
MustafaJafar Apr 18, 2024
101a86d
allow reading node data to override the metadata when refereshing the…
MustafaJafar Apr 18, 2024
c2ca04d
Implement `read_node_data` in `CreateRedshiftROP`
MustafaJafar Apr 18, 2024
0e688eb
add missing parameter
MustafaJafar Apr 24, 2024
909cf8c
update doc string of 'update_node_parameters' and 'read_node_data'
MustafaJafar Apr 24, 2024
b865d49
Transfer settings from pre create to instance data
MustafaJafar Apr 24, 2024
8cce460
add a TODO about considering other publihser attributes
MustafaJafar Apr 24, 2024
990ea5b
implement 'read_node_data'
MustafaJafar Apr 24, 2024
10467d2
use unexpanded string and fix multidot extensions
MustafaJafar Apr 24, 2024
ee0c95c
add a todo about update node_data
MustafaJafar Apr 24, 2024
9fdcce4
Merge branch 'develop' into enhancement/update_houdini_node_parms_on_…
MustafaJafar Apr 25, 2024
0905cb6
Merge branch 'develop' into enhancement/update_houdini_node_parms_on_…
MustafaJafar May 2, 2024
6492c53
Merge branch 'enhancement/update_houdini_node_parms_on_creator_attrib…
MustafaJafar May 2, 2024
3934e5d
remove @staticmethod
MustafaJafar May 10, 2024
030b983
Merge branch 'develop' into enhancement/update_houdini_node_parms_on_…
MustafaJafar May 10, 2024
0b6631c
Merge branch 'develop' into enhancement/update_houdini_node_parms_on_…
MustafaJafar May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 59 additions & 2 deletions client/ayon_core/hosts/houdini/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Creator as NewCreator,
CreatedInstance,
AYON_INSTANCE_ID,
AVALON_INSTANCE_ID,
AVALON_INSTANCE_ID
)
from ayon_core.lib import BoolDef
from .lib import imprint, read, lsattr, add_self_publish_button
Expand Down Expand Up @@ -241,6 +241,10 @@ def collect_instances(self):
if "AYON_productName" in node_data:
node_data["productName"] = node_data.pop("AYON_productName")

# Override metadata with node parameters
# We should use node parameters as source of truth.
node_data.update(self.read_node_data(instance))

created_instance = CreatedInstance.from_existing(
node_data, self
)
Expand All @@ -253,13 +257,24 @@ def update_instances(self, update_list):
key: changes[key].new_value
for key in changes.changed_keys
}
# Update parm templates and values

# Update Extra AYON parm templates and values.
self.imprint(
instance_node,
new_values,
update=True
)

# Update Houdini node's parameters based on creator attributes.
# This is done by re-using the logic inside the creators.
# Note: self is instance of the creator plugin that's responsible for
# the product type of instance_node.
if "creator_attributes" in new_values:
self.update_node_parameters(
instance_node,
new_values["creator_attributes"]
)

def imprint(self, node, values, update=False):
# Never store instance node and instance id since that data comes
# from the node's path
Expand Down Expand Up @@ -347,3 +362,45 @@ def apply_settings(self, project_settings):

for key, value in settings.items():
setattr(self, key, value)

@staticmethod
MustafaJafar marked this conversation as resolved.
Show resolved Hide resolved
def update_node_parameters(node, creator_attributes):
"""Update node parameters according to creator attributes.

This method is used in `update_instances` to update Houdini node
according to the values of creator_attributes.

Note:
Implementation differs based on the node type.
This method should include the key parameters that
you want to change on creator parameters change.

Args:
node(hou.Node): Houdini node to apply changes to.
creator_attributes(dict): Dictionary of creator attributes.
"""

pass

@staticmethod
def read_node_data(node):
"""Read node data from node parameters.

This method is used in `collect_instances` to compute creator
from node parameters.
It should invert the logic of `update_node_parameters`

Note:
Implementation differs based on the node type.
This method should include the key parameters that
you want to change in AYON parameters based
the values of node parameters.

Args:
node(hou.Node): Houdini node to read changes from.

Returns:
settings (Optional[dict[str, Any]]):
"""

return {}
35 changes: 31 additions & 4 deletions client/ayon_core/hosts/houdini/plugins/create/create_arnold_rop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ayon_core.hosts.houdini.api import plugin
from ayon_core.hosts.houdini.api import lib, plugin
from ayon_core.lib import EnumDef, BoolDef


Expand Down Expand Up @@ -66,15 +66,37 @@ def create(self, product_name, instance_data, pre_create_data):
to_lock = ["productType", "id"]
self.lock_parameters(instance_node, to_lock)

def get_pre_create_attr_defs(self):
attrs = super(CreateArnoldRop, self).get_pre_create_attr_defs()
@staticmethod
def update_node_parameters(node, creator_attributes):
"""update node parameters according to creator attributes.

Implementation of update_node_parameters.

Args:
node(hou.Node): Houdini node to apply changes to.
creator_attributes(dict): Dictionary of creator attributes.
"""
file_path, _ = lib.splitext(
node.evalParm("ar_picture"),
allowed_multidot_extensions=["pic.gz"]
)
output = "{file_path}.{ext}".format(
file_path=file_path,
ext=creator_attributes["image_format"]
)

node.setParms({
"ar_picture": output,
"ar_ass_export_enable": creator_attributes.get("export_job")
})

def get_instance_attr_defs(self):
image_format_enum = [
"bmp", "cin", "exr", "jpg", "pic", "pic.gz", "png",
"rad", "rat", "rta", "sgi", "tga", "tif",
]

return attrs + [
return [
BoolDef("farm",
label="Submitting to Farm",
default=True),
Expand All @@ -86,3 +108,8 @@ def get_pre_create_attr_defs(self):
default=self.ext,
label="Image Format Options")
]

def get_pre_create_attr_defs(self):
attrs = super(CreateArnoldRop, self).get_pre_create_attr_defs()

return attrs + self.get_instance_attr_defs()
82 changes: 46 additions & 36 deletions client/ayon_core/hosts/houdini/plugins/create/create_bgeo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Creator plugin for creating pointcache bgeo files."""
from ayon_core.hosts.houdini.api import plugin
from ayon_core.hosts.houdini.api import lib, plugin
from ayon_core.pipeline import CreatorError
import hou
from ayon_core.lib import EnumDef, BoolDef
Expand Down Expand Up @@ -29,11 +29,10 @@ def create(self, product_name, instance_data, pre_create_data):

instance_node = hou.node(instance.get("instance_node"))

file_path = "{}{}".format(
hou.text.expandString("$HIP/pyblish/"),
"{}.$F4.{}".format(
product_name,
pre_create_data.get("bgeo_type") or "bgeo.sc")
file_path = "{export_dir}/{product_name}.$F4.{ext}".format(
export_dir=hou.text.expandString("$HIP/pyblish"),
product_name=product_name,
ext=pre_create_data.get("bgeo_type") or "bgeo.sc"
)
parms = {
"sopoutput": file_path
Expand Down Expand Up @@ -61,45 +60,56 @@ def create(self, product_name, instance_data, pre_create_data):

instance_node.setParms(parms)

@staticmethod
def update_node_parameters(node, creator_attributes):
"""update node parameters according to creator attributes.

Implementation of update_node_parameters.

Args:
node(hou.Node): Houdini node to apply changes to.
creator_attributes(dict): Dictionary of creator attributes.
"""

file_path, _ = lib.splitext(
node.evalParm("sopoutput"),
allowed_multidot_extensions=[
".ass.gz", ".bgeo.sc", ".bgeo.gz",
".bgeo.lzma", ".bgeo.bz2"
]
)

output = "{file_path}.{ext}".format(
file_path=file_path,
ext=creator_attributes["bgeo_type"]
MustafaJafar marked this conversation as resolved.
Show resolved Hide resolved
)

node.setParms({"sopoutput": output})

def get_instance_attr_defs(self):
bgeo_enum = {
"bgeo": "uncompressed bgeo (.bgeo)",
"bgeosc": "BLOSC compressed bgeo (.bgeosc)",
"bgeo.sc": "BLOSC compressed bgeo (.bgeo.sc)",
"bgeo.gz": "GZ compressed bgeo (.bgeo.gz)",
"bgeo.lzma": "LZMA compressed bgeo (.bgeo.lzma)",
"bgeo.bz2": "BZip2 compressed bgeo (.bgeo.bz2)",
}

return [
BoolDef("farm",
label="Submitting to Farm",
default=False)
default=False),
EnumDef("bgeo_type",
items=bgeo_enum,
default="bgeo",
label="BGEO Options")
]

def get_pre_create_attr_defs(self):
attrs = super().get_pre_create_attr_defs()
bgeo_enum = [
{
"value": "bgeo",
"label": "uncompressed bgeo (.bgeo)"
},
{
"value": "bgeosc",
"label": "BLOSC compressed bgeo (.bgeosc)"
},
{
"value": "bgeo.sc",
"label": "BLOSC compressed bgeo (.bgeo.sc)"
},
{
"value": "bgeo.gz",
"label": "GZ compressed bgeo (.bgeo.gz)"
},
{
"value": "bgeo.lzma",
"label": "LZMA compressed bgeo (.bgeo.lzma)"
},
{
"value": "bgeo.bz2",
"label": "BZip2 compressed bgeo (.bgeo.bz2)"
}
]

return attrs + [
EnumDef("bgeo_type", bgeo_enum, label="BGEO Options"),
] + self.get_instance_attr_defs()
return attrs + self.get_instance_attr_defs()
MustafaJafar marked this conversation as resolved.
Show resolved Hide resolved

def get_network_categories(self):
return [
Expand Down
Loading
Loading