FunctionDef¶
Define a function.
A function is a subgraph that can be called (and executed) from elsewhere in the pipeline using the FunctionCall node. A function can receive arguments which are passed by the FunctionCall node calling the function. These arguments must be listed in the Graph [signature] property, and may be positional (the values received are assigned to the arguments listed in the signature property in the order they are listed), or and/or keyword arguments (arguments are assigned by name irrespective of order). The function subgraph must contain a Placeholder node for each argument, with the respective Placeholder slotname set to the argument name listed in Graph [signature]. When the function is executed at runtime, the arguments are passed to their respective Placeholder nodes, which then passes them on to the downstream node(s) they are wired into. Therefore, the Placeholder nodes act as the "starting points" of the function, which then executes the downstream nodes. The final node of your function should be wired into the graph input port of this FunctionDefinition node. In visual editors such as Pipeline Designer, this edge (link) will be drawn in dotted style to indicate that the function body (the subgraph) itself is passed to this FunctionDefinition node (which then causes the subgraph to be executed when it is called). This node does not need to be wired into another node in the pipeline; instead, the output of the function will be passed to the FunctionCall node that called it. The value that is returned will be the value of the output port of the node wired to the graph input port of this node. Typically that is the data output port, but in some nodes it may be a different output port. The calling FunctionCall node, upon receiving this value, will pass it on to the downstream node(s) it is wired into. If your function subgraph does not return any value (i.e., it simply exports data to disk), then this node will return None. In the event the final node in your function does not have an output port (i.e., such is the case with export nodes), you can wire the special-purpose this output port into the graph input port of this FunctionDefinition node.
Version 1.0.1
Ports/Properties¶
graph¶
Graph that defines the function.
- verbose name: Graph
- default value: None
- port type: GraphPort
- value type: Graph
graph__signature¶
Arguments accepted by your function. This is the list of argument names that your function receives, in the order in which they are expected if the function is called with positional arguments.
The arguments can be followed by a tilde, which allows portions of the computation that are constant (i.e., will not change each time the function is executed) to be automatically cached and reused across subsequent calls instead of recomputed (for performance reasons); however in that case the function can then not be used in NeuroPype's parallel loops.
A second special symbol that may be used here is a + separator to define positional arguments from keyword arguments, i.e., as in (arg1,arg2,+,kw1,kw2,~). Keyword arguments cannot be passed positionally when the function is called (to protect against ordering mistakes).
- verbose name: Graph [Signature]
- default value: (arg1,~)
- port type: Port
- value type: object (can be None)
function¶
Resulting function object.
- verbose name: Function
- default value: None
- port type: DataPort
- value type: object (can be None)
- data direction: OUT
funcname¶
Name of the function. The function can then be invoked under its name elsewhere in the graph via the Invoke node.
- verbose name: Function Name
- default value: myfunction
- port type: StringPort
- value type: str (can be None)
friendly_name¶
Friendly name of the node. This is the name that would show up in visual editors when the function is invoked as a node. This is capitalized and with spaces, as in "My Function".
- verbose name: Friendly Name
- default value: None
- port type: StringPort
- value type: str (can be None)
desc¶
Description of the function. The first sentence is taken as the executive summary and should not exceed 60 characters). The next paragraph is the essential description, and any following paragraphs are considered additional description text. This should not list the arguments, but can give a high-level overview of what the function can accept and what it does. It is possible to use limited amounts of HTML formatting, for instance for emphasis.
- verbose name: Description
- default value: None
- port type: StringPort
- value type: str (can be None)
version¶
Version of the function.
- verbose name: Version
- default value: 0.1.0
- port type: StringPort
- value type: str (can be None)
status¶
Development status of the function.
- verbose name: Status
- default value: alpha
- port type: EnumPort
- value type: str (can be None)
export¶
Export the function for use by other pipelines. If set to False, the function will not be available to import, which can help with encapsulation in large projects.
- verbose name: Export
- default value: True
- 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)