Monitoring Ops generated by the Node Graph

The PortOpClient API enables monitoring of Ops for a given Port and Graph State specification.

API Reference

Nodes3DAPI.RegisterPortOpClient(portOpClient)

Register the given Port Op Client for evaluation on changes to Node Graph, according to the current 3D Update Mode.

Note:

The registry does not store strong references to registered Port Op Clients.

Parameters:

portOpClient (PortOpClient) – Port Op Client to register.

Nodes3DAPI.UnregisterPortOpClient(portOpClient)

Unregister the given Port Op Client for evaluation on changes to Node Graph.

Parameters:

portOpClient (PortOpClient) – Port Op Client to unregister.

Nodes3DAPI.MarkPortOpClientDirty(portOpClient)

Mark the given Port Op Client as requiring re-evaluation. This should be called whenever a Port Op Client’s dependencies change, other than implicit dependencies such as the Node Graph and current Viewed Node).

Parameters:

portOpClient (PortOpClient) – Port Op Client to mark as requiring re-evaluation.

Nodes3DAPI.UpdatePortOpClients(portOpClients=None)

Force registered Port Op Clients to be [synchronously] re-evaluated.

Note:

Non-continuous 3D Update Modes do not prevent this function from committing changes to the Geolib runtime.

Return type:

int

Parameters:

portOpClients (Iterable of PortOpClient, or NoneType.) – Registered Port Op Clients to update, or None to update all registered Port Op Clients.

Returns:

The resulting commit ID.

Port Op Client interface

class Nodes3DAPI.PortOpClient.GraphStateId(value='Current Graph State')

Bases: str

Graph State identifier.

static __new__(cls, value='Current Graph State')
kCurrent = 'Current Graph State'
kNone = 'No Graph State'
kValues = ('Current Graph State', 'No Graph State')
class Nodes3DAPI.PortOpClient.PortId(value='Viewed Port')

Bases: str

Port identifier.

static __new__(cls, value='Viewed Port')
kValues = ('Viewed Port',)
kViewed = 'Viewed Port'
class Nodes3DAPI.PortOpClient.NodeId(value='Viewed Node')

Bases: str

Node identifier.

static __new__(cls, value='Viewed Node')
kValues = ('Viewed Node',)
kViewed = 'Viewed Node'
class Nodes3DAPI.PortOpClient.GraphStateSpec(value='Current Graph State')

Bases: GraphStateSpec

Graph State specification. This may take the value of a Graph State, or of a Graph State identifier for subsequent resolution.

static __new__(cls, value='Current Graph State')
Parameters:

value (NodegraphAPI.GraphState or {GraphStateId}) – Value

class Nodes3DAPI.PortOpClient.NodeTraversalEndpoints(searchPort, startPortOrNode)

Bases: NodeTraversalEndpointsBase

Start and end points for a Node Graph traversal.

The end or ‘search’ point, is a NodegraphAPI.Port. The start point may be either a NodegraphAPI.Port or a NodegraphAPI.Node. A start Node is traversed each of its output Ports in order.

static __new__(cls, searchPort, startPortOrNode)
Parameters:
  • searchPort (NodegraphAPI.Port) – Port at which Node Graph traversal returns a resulting modified Graph State.

  • startPortOrNode (NodegraphAPI.Port or NodegraphAPI.Node) – Port or Node from which Node Graph traversal commences.

property searchPort
property startPortOrNode
class Nodes3DAPI.PortOpClient.NodeTraversalEndpointsSpec(searchPortSpec, startPortOrNodeSpec='Viewed Node')

Bases: NodeTraversalEndpointsBase

Specification for start and end points for a Node Graph traversal (Node traversal endpoints). This may hold values of Ports/Nodes or Port/Node IDs for subsequent resolution.

See:

NodeTraversalEndpoints

static __new__(cls, searchPortSpec, startPortOrNodeSpec='Viewed Node')
Parameters:
  • searchPortSpec (NodegraphAPI.Port or PortId) – Port specification for the Port at which Node Graph traversal returns a resulting modified Graph State.

  • startPortOrNodeSpec (NodegraphAPI.Port or PortId or NodegraphAPI.Node or NodeId) – Port-or-Node specification for the Port or Node from which Node Graph traversal commences.

getNodeTraversalEndpoints()
Return type:

NodeTraversalEndpoints or NoneType

Returns:

Resolved Node traversal endpoints, or None.

property searchPortSpec
property startPortOrNodeSpec
class Nodes3DAPI.PortOpClient.PortOpClient(port='Viewed Port', initialGraphStateSpec='Current Graph State', nodeTraversalEndpointsSpec='Default Node Traversal Endpoints', applyTerminalOpDelegates=True)

Bases: ABC

An abstract base class for a client that can be registered to listen to changes to the Op that is produced for a given Port and Graph State specification.

The Port and Graph State specification is provided by a combination of component specifications:

  • Initial Graph State

  • Initial Graph State modification function

  • Node traversal

  • Post-traversal Graph State modification function

When any dependency is invalidated, including the Node Graph (and Global Graph State), the Viewed Node (where applicable), and any explicit invalidations, Port Op Clients registered with Nodes3DAPI are [re-]evaluated using the Port and Graph State specification, and are notified if the resulting Op changes.

Graph State modification functions are implemented as overridden methods of this class. Instantiable derived classes must implement opChanged().

__init__(port='Viewed Port', initialGraphStateSpec='Current Graph State', nodeTraversalEndpointsSpec='Default Node Traversal Endpoints', applyTerminalOpDelegates=True)
Parameters:
  • port (NodegraphAPI.Port, PortId or NoneType) – Port or Port ID to track for Op changes, or None to use a no-op as the input Op.

  • initialGraphStateSpec (GraphStateSpec) – Initial Graph State for the Port and Graph State specification.

  • nodeTraversalEndpointsSpec (NodeTraversalEndpointsSpec or NoneType or str) – Node traversal endpoints for the Port and Graph State specification. This may be a NodeTraversalEndpointsSpec object, None (indicating no traversal), or kDefaultNodeTraversalEndpointsSpec (which is equivalent to NodeTraversalEndPointsSpec(port)).

  • applyTerminalOpDelegates (bool) – Option to applying Terminal Op Delegates to the Op result.

getNodeTraversalEndpoints()
Return type:

NodeTraversalEndpoints or NoneType

Returns:

Resolved Node traversal endpoints, or None.

getResolvedPort()
Return type:

NodegraphAPI.Port or NoneType

Returns:

Resolved Port or None

property initialGraphStateSpec
kDefaultInitialGraphStateSpec = 'Current Graph State'
kDefaultNodeTraversalEndpointsSpec = 'Default Node Traversal Endpoints'
modifyInitialGraphState(graphState)

Override this method to modify the initial Graph State prior to any Node Graph traversal.

Parameters:

graphState (NodegraphAPI.GraphState or NoneType) – Resolved initial Graph State, or None.

Return type:

NodegraphAPI.GraphState

Returns:

Modified (or unmodified) Graph State

modifyPostTraversalGraphState(graphState)

Override this method to modify the post-traversal Graph State.

Parameters:

graphState (NodegraphAPI.GraphState) – Post-traversal Graph State

Return type:

NodegraphAPI.GraphState

Returns:

Modified (or unmodified) Graph State

property nodeTraversalEndpointsSpec
abstract opChanged(op, graphState, txn)

Implement this abstract method to receive notifications of Op changes.

Parameters:
  • op (PyFnGeolib.GeolibRuntime.Op) – Op produced by the Port and Graph State specification

  • graphState (NodegraphAPI.GraphState) – Final Graph State used to produce the resultant Op.

  • txn (PyFnGeolib.GeolibRuntime.Transaction) – Geolib runtime transaction that may be used to perform further configuration that will be committed as part of the operating batch.

property port
class Nodes3DAPI.PortOpClient.CallbackPortOpClient(port='Viewed Port', opChangeCallback=None, initialGraphStateSpec='Current Graph State', nodeTraversalEndpointsSpec='Default Node Traversal Endpoints', initialGraphStateModifier=None, postTraversalGraphStateModifier=None, applyTerminalOpDelegates=True)

Bases: PortOpClient

Implementation of PortOpClient that forwards overridden functions to configurable weakly-referenced callables: - opChanged() -> opChangeCallback - modifyInitialGraphState() -> initialGraphStateModifier - modifyPostTraversalGraphState() -> postTraversalGraphStateModifier

__init__(port='Viewed Port', opChangeCallback=None, initialGraphStateSpec='Current Graph State', nodeTraversalEndpointsSpec='Default Node Traversal Endpoints', initialGraphStateModifier=None, postTraversalGraphStateModifier=None, applyTerminalOpDelegates=True)
Parameters:
  • port (NodegraphAPI.Port, PortId or NoneType) – Port or Port ID to track for Op changes, or None to use a no-op as the input Op..

  • opChangeCallback (Callable or NoneType) – Callable acting as a destination for forwarded calls to opChanged(), with positional parameters starting with the PortOpClient instance.

  • initialGraphStateSpec (GraphStateSpec) – Initial Graph State for the Port and Graph State specification.

  • nodeTraversalEndpointsSpec (NodeTraversalEndpointsSpec or NoneType or str) – Node traversal endpoints for the Port and Graph State specification. This may be a NodeTraversalEndpointsSpec object, None (indicating no traversal), or kDefaultNodeTraversalEndpointsSpec (which is equivalent to NodeTraversalEndPointsSpec(port)).

  • initialGraphStateModifier (Callable or NoneType) – Callable acting as a destination for forwarded calls to modifyInitialGraphState(), with positional parameters starting with the PortOpClient instance.

  • postTraversalGraphStateModifier (Callable or NoneType) – Callable acting as a destination for forwarded calls to modifyPostTraversalGraphState(), with positional parameters starting with the PortOpClient instance.

  • applyTerminalOpDelegates (bool) – Option to applying Terminal Op Delegates to the Op result.

property initialGraphStateModifier
modifyInitialGraphState(graphState)

Forwards to self.initialGraphStateModifier.

See:

PortOpClient.modifyInitialGraphState()

modifyPostTraversalGraphState(graphState)

Forwards to self.postTraversalGraphStateModifier.

See:

PortOpClient.modifyPostTraversalGraphState()

property opChangeCallback
opChanged(op, graphState, txn)

Forwards to self.opChangeCallback.

See:

PortOpClient.opChanged()

property postTraversalGraphStateModifier