Search - User list
Full Version: ResultData vs Attributes
Root » PDG/TOPs » ResultData vs Attributes
Ostap
Hi,

Can you please clarify when is better to use one or another data delivery (ResultData or Attributes)? In which cases?

Thanks
Ostap
Johan Boekhoven
This is just my opinion so take it for what it's worth.
I see Attributes as data I want to cary through many nodes and ResultData as just the output of the previous node.
So say I want to have a specific output file or data from a node in the beginning to have an effect later on. I use a python or attr create node to ‘promote’ the ResultData to an attribute.

So temporary vs permanent. Other then that it's just how you like to work best I think.

Hope it helps somewhat.
Ostap
I doubt it that a resultData was designed only as a temporary variable (vs permanent). Otherwise, we would not have tag handlers to work with files on the disk, only “reportResultData” at cook time and another data structure in partitions - all those things for resultData.

Would be nice if SideFX can clarify what the architecture idea is behind implementing resultData. Why it wasn't possible to done just by attributes?
tpetrick
Starting with Houdini 18.0 and onward, work item input and output file are implemented as attributes internally. The main difference between those and regular attributes is the way they get copied between work items. Output files are copied to the input files of their dependents, so those work items can produce their own output file list without overwriting the inputs. The input attribute of a work item is effectively read-only for that work item.

You can create a file-type attribute on a work item using the following:

new_file = pdg.File("example.txt", "file/txt", 0, True)
work_item.setFileAttrib("example", new_file)

Also note that at cook time you can call setStringAttrib, setIntAttrib to transmit an attribute name/value back to PDG, in the same way as sending back a file/tag.
Ostap
Can you please explain how you would you use tag in attributes?

Does attribute with tag works with PDG file caching system?

Why do you differentiate concatenation in partitions with resultData and attributes?
tpetrick
Ostap
Can you please explain how you would you use tag in attributes?

Only attributes with the File data type can use tags: https://www.sidefx.com/docs/houdini/tops/pdg/AttributeFile.html [www.sidefx.com] You can add a file attribute to a work item by calling work_item.setFileAttrib(..) or by calling work_item.addAttrib(“name”, pdg.attribType.File). See https://www.sidefx.com/docs/houdini/tops/pdg/WorkItem.html#setFileAttrib [www.sidefx.com] and/or https://www.sidefx.com/docs/houdini/tops/pdg/WorkItem.html#addAttrib [www.sidefx.com] for more details.

A file attribute is just like a string attribute, except the entries in the attribute are instances of the pdg.File class instead of str. See https://www.sidefx.com/docs/houdini/tops/pdg/File.html [www.sidefx.com] for details on the members available on that class. I've also backported some additionally utility methods to 18.0 that were originally added for the next release, which will be available tomorrow. Some examples:

# Print paths/tag
attrib = work_item['file_attrib']
for file in attrib.values:
    print(file.path + " : " + file.tag)

# Add new file
example_file = pdg.File("example.txt", "file/txt", 0, True)
work_item.setFileAttrib("file", example_file, 0)

# Available in the next daily build
tagged_files = work_item['file_attrib'].valuesForTag('file/txt')
specific_file = work_item['file_attrib'].valueForTag(1, 'file/txt')

Ostap
Does attribute with tag works with PDG file caching system?
No, they don't. The only thing that works with the caching system are work item results – I should have mentioned that in my last post.

Ostap
Why do you differentiate concatenation in partitions with resultData and attributes?
Result data can be concatenated on partitions because they have more restrictions than regular attributes, and they're managed by PDG internally. That limitation has been fixed in the next release and all partitioner nodes will have advanced options for merging attributes. It's not possible to backport that to 18.0 because it involved large internal changes to PDG's attribute storage.
Ostap
tpetrick
Ostap
Does attribute with tag works with PDG file caching system?
No, they don't. The only thing that works with the caching system are work item results – I should have mentioned that in my last post.
In the conclusion that. Is it possible to say:
If your workitem result is a file on the disk and you want to use caching mechanism then you need to use “resulData” output

Also, since we have `resultDataForTag(tag)` then is it possible to add `expectedResultDataForTag(tag)`?
Ostap
Can you please confirm or not my suggestion above?
tpetrick
Ostap
In the conclusion that. Is it possible to say:
If your workitem result is a file on the disk and you want to use caching mechanism then you need to use “resulData” output

Yes, that's correct.

Ostap
Also, since we have `resultDataForTag(tag)` then is it possible to add `expectedResultDataForTag(tag)`?

Sure, I'll log an RFE for that.
Ostap
Thank you!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB