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
¶ Bases:
str
Graph State identifier.
-
static
__new__
(value='Current Graph State')¶
-
kCurrent
= 'Current Graph State'¶
-
kNone
= 'No Graph State'¶
-
kValues
= ('Current Graph State', 'No Graph State')¶
-
static
-
class
Nodes3DAPI.PortOpClient.
PortId
¶ Bases:
str
Port identifier.
-
static
__new__
(value='Viewed Port')¶
-
kValues
= ('Viewed Port',)¶
-
kViewed
= 'Viewed Port'¶
-
static
-
class
Nodes3DAPI.PortOpClient.
NodeId
¶ Bases:
str
Node identifier.
-
static
__new__
(value='Viewed Node')¶
-
kValues
= ('Viewed Node',)¶
-
kViewed
= 'Viewed Node'¶
-
static
-
class
Nodes3DAPI.PortOpClient.
GraphStateSpec
¶ Bases:
Nodes3DAPI.PortOpClient.GraphStateSpec
Graph State specification. This may take the value of a Graph State, or of a Graph State identifier for subsequent resolution.
-
static
__new__
(value='Current Graph State')¶ Parameters: value ( NodegraphAPI.GraphState
or {GraphStateId}) – Value
-
static
-
class
Nodes3DAPI.PortOpClient.
NodeTraversalEndpoints
¶ Bases:
Nodes3DAPI.PortOpClient.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__
(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.
- searchPort (
-
searchPort
¶
-
startPortOrNode
¶
-
static
-
class
Nodes3DAPI.PortOpClient.
NodeTraversalEndpointsSpec
¶ Bases:
Nodes3DAPI.PortOpClient.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__
(searchPortSpec, startPortOrNodeSpec='Viewed Node')¶ 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.
- searchPortSpec (
-
getNodeTraversalEndpoints
()¶ Return type: NodeTraversalEndpoints
orNoneType
Returns: Resolved Node traversal endpoints, or None
.
-
searchPortSpec
¶
-
startPortOrNodeSpec
¶
-
static
-
class
Nodes3DAPI.PortOpClient.
PortOpClient
(port='Viewed Port', initialGraphStateSpec='Current Graph State', nodeTraversalEndpointsSpec='Default Node Traversal Endpoints', applyTerminalOpDelegates=True)¶ Bases:
object
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
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.
- port (
-
getNodeTraversalEndpoints
()¶ Return type: NodeTraversalEndpoints
orNoneType
Returns: Resolved Node traversal endpoints, or None
.
-
getResolvedPort
()¶ Return type: NodegraphAPI.Port
orNoneType
Returns: Resolved Port or None
-
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
orNoneType
) – Resolved initial Graph State, orNone
.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 StateReturn type: NodegraphAPI.GraphState
Returns: Modified (or unmodified) Graph State
-
nodeTraversalEndpointsSpec
¶
-
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.
- op (
-
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:
Nodes3DAPI.PortOpClient.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
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.
- port (
-
initialGraphStateModifier
¶
-
modifyInitialGraphState
(graphState)¶ Forwards to
self.initialGraphStateModifier
.See: PortOpClient.modifyInitialGraphState
-
modifyPostTraversalGraphState
(graphState)¶ Forwards to
self.postTraversalGraphStateModifier
.See: PortOpClient.modifyPostTraversalGraphState
-
opChangeCallback
¶
-
opChanged
(op, graphState, txn)¶ Forwards to
self.opChangeCallback
.See: PortOpClient.opChanged
-
postTraversalGraphStateModifier
¶