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
, orNoneType
.) – Registered Port Op Clients to update, orNone
to update all registered Port Op Clients.- Returns:
The resulting commit ID.
Port Op Client interface
- class Nodes3DAPI.PortOpClient.GraphStateId(value=kCurrent)¶
Bases:
str
Graph State identifier.
- kCurrent = 'Current Graph State'¶
- kNone = 'No Graph State'¶
- kValues = ('Current Graph State', 'No Graph State')¶
- static __new__(cls, value=kCurrent)¶
- class Nodes3DAPI.PortOpClient.PortId(value=kViewed)¶
Bases:
str
Port identifier.
- kViewed = 'Viewed Port'¶
- kValues = ('Viewed Port',)¶
- static __new__(cls, value=kViewed)¶
- class Nodes3DAPI.PortOpClient.NodeId(value=kViewed)¶
Bases:
str
Node identifier.
- kViewed = 'Viewed Node'¶
- kValues = ('Viewed Node',)¶
- static __new__(cls, value=kViewed)¶
- class Nodes3DAPI.PortOpClient.GraphStateSpec(value=kCurrentGraphStateId)¶
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=kCurrentGraphStateId)¶
- 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 aNodegraphAPI.Port
or aNodegraphAPI.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
orNodegraphAPI.Node
) – Port or Node from which Node Graph traversal commences.
- property searchPort¶
- property startPortOrNode¶
- class Nodes3DAPI.PortOpClient.NodeTraversalEndpointsSpec(searchPortSpec, startPortOrNodeSpec=kViewedNodeId)¶
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.
- static __new__(cls, searchPortSpec, startPortOrNodeSpec=kViewedNodeId)¶
- Parameters:
searchPortSpec (
NodegraphAPI.Port
orPortId
) – Port specification for the Port at which Node Graph traversal returns a resulting modified Graph State.startPortOrNodeSpec (
NodegraphAPI.Port
orPortId
orNodegraphAPI.Node
orNodeId
) – Port-or-Node specification for the Port or Node from which Node Graph traversal commences.
- property searchPortSpec¶
- property startPortOrNodeSpec¶
- getNodeTraversalEndpoints()¶
- Return type:
NodeTraversalEndpoints
orNoneType
- Returns:
Resolved Node traversal endpoints, or
None
.
- class Nodes3DAPI.PortOpClient.PortOpClient(port=kViewedPortId, initialGraphStateSpec=kDefaultInitialGraphStateSpec, nodeTraversalEndpointsSpec=kDefaultNodeTraversalEndpointsSpec, 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()
.- kDefaultInitialGraphStateSpec = 'Current Graph State'¶
- kDefaultNodeTraversalEndpointsSpec = 'Default Node Traversal Endpoints'¶
- __init__(port=kViewedPortId, initialGraphStateSpec=kDefaultInitialGraphStateSpec, nodeTraversalEndpointsSpec=kDefaultNodeTraversalEndpointsSpec, applyTerminalOpDelegates=True)¶
- Parameters:
port (
NodegraphAPI.Port
,PortId
orNoneType
) – Port or Port ID to track for Op changes, orNone
to use a no-op as the input Op.initialGraphStateSpec (
GraphStateSpec
) – Initial Graph State for the Port and Graph State specification.nodeTraversalEndpointsSpec (
NodeTraversalEndpointsSpec
orNoneType
orstr
) – Node traversal endpoints for the Port and Graph State specification. This may be a NodeTraversalEndpointsSpec object,None
(indicating no traversal), orkDefaultNodeTraversalEndpointsSpec
(which is equivalent toNodeTraversalEndPointsSpec(port)
).applyTerminalOpDelegates (
bool
) – Option to applying Terminal Op Delegates to the Op result.
- property port¶
- getResolvedPort()¶
- Return type:
NodegraphAPI.Port
orNoneType
- Returns:
Resolved Port or
None
- property initialGraphStateSpec¶
- property nodeTraversalEndpointsSpec¶
- getNodeTraversalEndpoints()¶
- Return type:
NodeTraversalEndpoints
orNoneType
- Returns:
Resolved Node traversal endpoints, or
None
.
- modifyInitialGraphState(graphState)¶
Override this method to modify the initial Graph State prior to any Node Graph traversal.
- Parameters:
graphState (
NodegraphAPI.GraphState
orNoneType
) – Resolved initial Graph State, orNone
.- Return type:
- 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:
- Returns:
Modified (or unmodified) Graph State
- 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 specificationgraphState (
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.
- class Nodes3DAPI.PortOpClient.CallbackPortOpClient(port=kViewedPortId, opChangeCallback=None, initialGraphStateSpec=PortOpClient.kDefaultInitialGraphStateSpec, nodeTraversalEndpointsSpec=PortOpClient.kDefaultNodeTraversalEndpointsSpec, 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=kViewedPortId, opChangeCallback=None, initialGraphStateSpec=PortOpClient.kDefaultInitialGraphStateSpec, nodeTraversalEndpointsSpec=PortOpClient.kDefaultNodeTraversalEndpointsSpec, initialGraphStateModifier=None, postTraversalGraphStateModifier=None, applyTerminalOpDelegates=True)¶
- Parameters:
port (
NodegraphAPI.Port
,PortId
orNoneType
) – Port or Port ID to track for Op changes, orNone
to use a no-op as the input Op..opChangeCallback (Callable or
NoneType
) – Callable acting as a destination for forwarded calls toopChanged()
, with positional parameters starting with thePortOpClient
instance.initialGraphStateSpec (
GraphStateSpec
) – Initial Graph State for the Port and Graph State specification.nodeTraversalEndpointsSpec (
NodeTraversalEndpointsSpec
orNoneType
orstr
) – Node traversal endpoints for the Port and Graph State specification. This may be a NodeTraversalEndpointsSpec object,None
(indicating no traversal), orkDefaultNodeTraversalEndpointsSpec
(which is equivalent toNodeTraversalEndPointsSpec(port)
).initialGraphStateModifier (Callable or
NoneType
) – Callable acting as a destination for forwarded calls tomodifyInitialGraphState()
, with positional parameters starting with thePortOpClient
instance.postTraversalGraphStateModifier (Callable or
NoneType
) – Callable acting as a destination for forwarded calls tomodifyPostTraversalGraphState()
, with positional parameters starting with thePortOpClient
instance.applyTerminalOpDelegates (
bool
) – Option to applying Terminal Op Delegates to the Op result.
- property opChangeCallback¶
- property initialGraphStateModifier¶
- property postTraversalGraphStateModifier¶
- modifyInitialGraphState(graphState)¶
Forwards to
self.initialGraphStateModifier
.
- modifyPostTraversalGraphState(graphState)¶
Forwards to
self.postTraversalGraphStateModifier
.
- opChanged(op, graphState, txn)¶
Forwards to
self.opChangeCallback
.