Scheme (scheme
)
Scheme Workflow
The Scheme
class defines a DAG (Directed Acyclic Graph) workflow.
-
class
orangecanvas.scheme.scheme.
Scheme
(parent=None, title=None, description=None, env={}, **kwargs) Bases:
PyQt5.QtCore.QObject
An
QObject
subclass representing the scheme widget workflow with annotations.Parameters: -
nodes
list of
SchemeNode
– A list of all the nodes in the scheme.
-
links
list of
SchemeLink
– A list of all links in the scheme.
-
annotations
list of
BaseSchemeAnnotation
– A list of all the annotations in the scheme.
-
title_changed
(title) Signal emitted when the title of scheme changes.
-
description_changed
(description) Signal emitted when the description of scheme changes.
-
node_added
(node) Signal emitted when a node is added to the scheme.
-
node_removed
(node) Signal emitted when a node is removed from the scheme.
-
link_added
(link) Signal emitted when a link is added to the scheme.
-
link_removed
(link) Signal emitted when a link is removed from the scheme.
-
annotation_added
(annotation) Signal emitted when a annotation is added to the scheme.
-
annotation_removed
(annotation) Signal emitted when a annotation is removed from the scheme.
-
runtime_env_changed
(key: str, newvalue: Optional[str], oldvalue: Optional[str]) Signal emitted when the associated runtime environment changes
-
nodes
A list of all nodes (
SchemeNode
) currently in the scheme.
-
links
A list of all links (
SchemeLink
) currently in the scheme.
-
annotations
A list of all annotations (
BaseSchemeAnnotation
) in the scheme.
-
set_title
(title) Set the scheme title text.
-
title
The title (human readable string) of the scheme.
-
set_description
(description) Set the scheme description text.
-
description
Scheme description text.
-
add_node
(node) Add a node to the scheme. An error is raised if the node is already in the scheme.
Parameters: node ( SchemeNode
) – Node instance to add to the scheme.
-
new_node
(description, title=None, position=None, properties=None) Create a new
SchemeNode
and add it to the scheme.Same as:
scheme.add_node(SchemeNode(description, title, position, properties))
Parameters: - description (
WidgetDescription
) – The new node’s description. - title (str, optional) – Optional new nodes title. By default description.name is used.
- position ((x, y) tuple of floats, optional) – Optional position in a 2D space.
- properties (dict, optional) – A dictionary of optional extra properties.
See also
SchemeNode()
,Scheme.add_node()
- description (
-
remove_node
(node) Remove a node from the scheme. All links into and out of the node are also removed. If the node in not in the scheme an error is raised.
Parameters: node ( SchemeNode
) – Node instance to remove.
-
add_link
(link) Add a link to the scheme.
Parameters: link ( SchemeLink
) – An initialized link instance to add to the scheme.
-
new_link
(source_node, source_channel, sink_node, sink_channel) Create a new
SchemeLink
from arguments and add it to the scheme. The new link is returned.Parameters: - source_node (
SchemeNode
) – Source node of the new link. - source_channel (
OutputSignal
) – Source channel of the new node. The instance must be fromsource_node.output_channels()
- sink_node (
SchemeNode
) – Sink node of the new link. - sink_channel (
InputSignal
) – Sink channel of the new node. The instance must be fromsink_node.input_channels()
See also
SchemeLink()
,Scheme.add_link()
- source_node (
-
remove_link
(link) Remove a link from the scheme.
Parameters: link ( SchemeLink
) – Link instance to remove.
-
check_connect
(link) Check if the link can be added to the scheme and raise an appropriate exception.
- Can raise:
TypeError
if link is not an instance ofSchemeLink
SchemeCycleError
if the link would introduce a loop in the graph which does not allow loops.IncompatibleChannelTypeError
if the channel types are not compatibleSinkChannelError
if a sink channel has a Single flag specification and the channel is already connected.DuplicatedLinkError
if a link duplicates an already present link.
-
creates_cycle
(link) Return True if link would introduce a cycle in the scheme.
Parameters: link ( SchemeLink
) –
-
compatible_channels
(link) Return True if the channels in link have compatible types.
Parameters: link ( SchemeLink
) –
-
can_connect
(link) Return True if link can be added to the scheme.
See also
-
upstream_nodes
(start_node) Return a set of all nodes upstream from start_node (i.e. all ancestor nodes).
Parameters: start_node ( SchemeNode
) –
-
downstream_nodes
(start_node) Return a set of all nodes downstream from start_node.
Parameters: start_node ( SchemeNode
) –
-
is_ancestor
(node, child) Return True if node is an ancestor node of child (is upstream of the child in the workflow). Both nodes must be in the scheme.
Parameters: - node (
SchemeNode
) – - child (
SchemeNode
) –
- node (
-
children
(node) Return a set of all children of node.
-
parents
(node) Return a set of all parents of node.
-
input_links
(node) Return a list of all input links (
SchemeLink
) connected to the node instance.
-
output_links
(node) Return a list of all output links (
SchemeLink
) connected to the node instance.
-
propose_links
(source_node, sink_node) Return a list of ordered (
OutputSignal
,InputSignal
, weight) tuples that could be added to the scheme between source_node and sink_node.Note
This can depend on the links already in the scheme.
-
add_annotation
(annotation) Add an annotation (
BaseSchemeAnnotation
subclass) instance to the scheme.
-
remove_annotation
(annotation) Remove the annotation instance from the scheme.
-
clear
() Remove all nodes, links, and annotation items from the scheme.
-
sync_node_properties
() Called before saving, allowing a subclass to update/sync.
The default implementation does nothing.
-
save_to
(stream, pretty=True, pickle_fallback=False) Save the scheme as an xml formated file to stream
See also
scheme_to_ows_stream()
-
load_from
(stream) Load the scheme from xml formated stream.
-
set_runtime_env
(key, value) Set a runtime environment variable key to value
-
get_runtime_env
(key, default=None) Return a runtime environment variable for key.
-
runtime_env
() Return (a view to) the full runtime environment.
The return value is a types.MappingProxyType of the underlying environment dictionary. Changes to the env. will be reflected in it.
-
-
class
orangecanvas.scheme.scheme.
SchemeCycleError
Bases:
orangecanvas.scheme.errors.SchemeTopologyError
A link would create a cycle in the scheme.
-
class
orangecanvas.scheme.scheme.
IncompatibleChannelTypeError
Bases:
TypeError
Source and sink channels do not have compatible types
-
class
orangecanvas.scheme.scheme.
SinkChannelError
Bases:
orangecanvas.scheme.errors.SchemeTopologyError
Sink channel already connected.
-
class
orangecanvas.scheme.scheme.
DuplicatedLinkError
Bases:
orangecanvas.scheme.errors.SchemeTopologyError
A link duplicates another link already present in the scheme.