Houdini 18.0 Nodes TOP nodes

Python Processor TOP node

Generate work items using a Python script

On this page

This node can be used to write custom processor logic using the Python API.

For uses cases that need a single work item per upstream item that runs a Python Script, the Python Script or [Generic Generator| Node:top/genericgenerator] are simpler alternatives.

Parameters

Save to Python Script

Saves the callbacks defined on this node to a Python script, which can be imported and registered with PDG. The parameter template associated with the node is also saved and embedded into the Python script. After saving the script is automatically imported and the node type is made available in the TAB menu.

Save to Digital Asset

Saves the callbacks defined on this node to a standalone Houdini Digital asset. The callbacks are stored inside the .hda itself and are registered with PDG as an embedded PDG node type.

Work Item Generation

Whether this node generates static or dynamic work items. You should generally leave this set to "Automatic" unless you know the node’s work items can be computed statically, or that they need to be generated dynamically.

Dynamic

This node always creates dynamic work items: it waits until the upstream work items are known, and generates new work items from the upstream work items.

Static

This node always creates static work items: it creates the number of work items it thinks it needs based on the parameters (and any upstream static items) before the network runs.

Automatic

If the input is static (a static processor, or a partitioner with only static inputs, or a mapper), this node generates static work items, otherwise it generates dynamic work items.

Command

The command line (executable and arguments) to run when the work item runs. If this field is empty the work item will not be scheduled, and will be instantly marked done once all of its dependencies finish.

onGenerate Callback

This script is run whenever the node needs to generate new work items from upstream items, or from nothing if it has no inputs. It is used for both static and dynamic work item generation.

When generating static work items, a single will be made to the script and it will receive the entire list of upstream static items in the upstream_items variable. When generating dynamic work items, the script will be called once for each upstream item that has finished cooking.

Several variables are available in the script:

self

Refers to the underyling PDG node associated with the TOP node. Note that this is different than TOP node itself, which is a standard Houdini operator.

Spare parameters added to the TOP node’s parameter interface will automatically be added to the PDG node.

item_holder

The work item holder used to construct new work items. Items in the holder will be committed to the node once the script is completed. If the script fails, the items will be discarded.

upstream_items

The list of upstream items.

generation_type

The type of work item generation the script is doing.

onRegenerateStatic Callback

This script is run whenever the node needs to generate static items, but already has existing items. It can be used to add new static items, and dirty or delete existing ones.

The following variables are available in the script:

self

Refers to the underlying PDG node associated with the TOP node.

item_holder

The work item holder used to construct new work items.

existing_items

The list of existing static work items currently in the node.

upstream_items

The list of upstream work items.

onAddInternalDependencies Callback

Called when the node should add dependencies between sibling work items. This is called once for each call to the onGenerate Callback. It can be used to add dependencies between the items created in that callback invocation.

The following variables are available in the script:

self

Refers to the underlying PDG node associated with the TOP node.

dependency_holder

The work item holder used to assign dependency pairs.

internal_items

The list of work items added by the last onGenerate Callback execution.

is_static

Boolean that is set to True if the last generation was static, else False.

onCookTask Callback

Called when the node should cook an in-process work item. The code is invoked for each in-process item produced by the onGenerate Callback, when that item needs to cook. In-process work items are created by passing the inProcess=True flag when constructing a work item.

The following variables are available in the script:

self

Refers to the underlying PDG node associated with the TOP node.

work_item

The work item that is cooking in process.

Examples

example_top_pythonprocessor Example for Python Processor TOP node

This example demonstrates how to use the python processor in PDG/TOPs.

See also

TOP nodes