Skip to content

← utilities package

WithOptions

Run the wired-in computational graph with the specified options applied to it.

This node can be used to distribute a single value to a large number of nodes in a graph, which can either be one or more instances of Placeholder nodes of the same name in the graph, or any ports of a specified name on nodes of a certain class. See the options property for more details. By default this node will run the entire graph that is wired into it under the given backend context. However, you can also tag a subgraph that shall run under the given context by placing a dummy Placeholder node in your graph, giving it a unique slotname (one would usually name it "with" as a reminder that it pairs with a downstream "With..." node), and then and selectively wiring that placeholder's update output port to select nodes of your graph. Then only the nodes downstream of that placeholder will run under the given context. You will also need to set the "Graph [tag]" option (graph__signature in code) to name the tag that you used (e.g. "(with)" in this example). The full set of options can be accessed within the graph by the name __options. Version 0.5.0

Ports/Properties

graph

Computation to run.

  • verbose name: Graph
  • default value: None
  • port type: GraphPort
  • value type: Graph

graph__signature

Optionally the slotname of a Placeholder node that shall mark the starting point of the graph that runs under the with context. As with all "With" context manager nodes in NeuroPype, the graph that runs under the context managed by this node is preceding the context manager node in the graph, rather than following it. This is accomplished by wiring the final node of the graph that shall execute under the governance of the context manager into the "graph" input port of the subsequent "With" node. In graphical UIs, this edge will be drawn in dotted style to indicate that this is not normal forward data flow where first the preceding node executes and then the subsequent node receives its output, but that instead the subsequent node (the context manager) receives a portion of the preceding graph, which it then runs in such a way that the context applies. You can use a "tilde" binding, spelled as (~), which affects the same nodes that a then or else branch in an IfElse node would control, which is normally what one would expect. However, note that this can have sometimes the unexpected consequence that simply wiring a value into your graph may "infect" an upstream portion of the graph with unintentionally running under the context, too. As an alternative, you can instead rely on a named Placeholder node to mark the beginning of the managed graph. The typical way to do this is to list a single placeholder name, e.g., (with), and then to create a Placeholder in your graph whose slotname is set to "with". Then, only the nodes that are downstream of (i.e., formally depending on) that placeholder will run under the context defined by the "With" node. In this case you need to make everything that shall be part of the context dependent on the placeholder, which can be accomplished by wiring the update output port of the Placeholder into the update input port of any nodes that shall run under the context (this dependency propagates down the graph, so you don't need to wire it to every node, just to the first node(s) that you want to be part of the context).. The options apply to any matching nodes in this context.

  • verbose name: Graph [Tag]
  • default value: (~)
  • port type: Port
  • value type: object (can be None)

result

Result of the computation.

  • verbose name: Result
  • default value: None
  • port type: DataPort
  • value type: object (can be None)
  • data direction: OUT

options

Dictionary of named options to apply. The graph may contain one or more placeholders whose slotname matches the name of the option, which then resolve to the option. Additionally, if the option is named like "node:port" then the option applies to any port with the given name on any node of the given node class (node: these are the CamelCase node classes and the under_score, port names as they show up in the hover documentation, not the friendly names with spaces that show under each node). Both node and port may contain the * or ? wildcard characters to apply to multiple nodes and/or multiple ports matching a certain name pattern. You can mix and match different kinds of options. For brevity you may also omit the node or port part, and use options formatted like node: or :port.

  • verbose name: Options
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)

is_global

If True, the context implicitly applies to the entire graph (except for those parts that are configuring the context itself). To use multiple global With context managers, you need to chain them together using their respective graph ports since they are required to apply in a well-defined order.

  • verbose name: Is Global
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

  • verbose name: Set Breakpoint (Debug Only)
  • default value: False
  • port type: BoolPort
  • value type: bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

  • verbose name: Metadata
  • default value: {}
  • port type: DictPort
  • value type: dict (can be None)