nodify.workflow.Network

class nodify.workflow.Network(workflow: Type[Workflow])[source]

Bases: object

__init__(workflow: Type[Workflow])[source]

Methods

__init__(workflow)

to_nx(workflow[, include_workflow_inputs, ...])

Convert a Workflow class to a networkx directed graph.

to_pyvis([colorscale, show_workflow_inputs, ...])

Convert a Workflow class to a pyvis network for visualization.

visualize([colorscale, ...])

Visualize the workflow's network in a plot.

to_nx(workflow: Type[Workflow], include_workflow_inputs: bool = False, edge_labels: bool = False) nx.DiGraph[source]

Convert a Workflow class to a networkx directed graph.

The nodes of the graph are the node functions that compose the workflow. The edges represent connections between nodes, where one node’s output is sent to another node’s input.

Parameters:
  • workflow (Type[Workflow]) – The workflow class that you want to convert.

  • include_workflow_inputs (bool, optional) – Whether to include the workflow inputs in the graph.

  • edge_labels (bool, optional) – Whether to add labels to edges. If True, the labels are the key of the input that receives the output of the outgoing node.

to_pyvis(colorscale: str = 'viridis', show_workflow_inputs: bool = False, edge_labels: bool = True, node_help: bool = True, notebook: bool = False, hierarchial: bool = True, inputs_props: Dict[str, Any] = {}, node_props: Dict[str, Any] = {}, leafs_props: Dict[str, Any] = {}, output_props: Dict[str, Any] = {}, auto_text_color: bool = True, to_export: bool | None = None)[source]

Convert a Workflow class to a pyvis network for visualization.

The nodes of the graph are the node functions that compose the workflow. The edges represent connections between nodes, where one node’s output is sent to another node’s input.

Parameters:
  • colorscale (str, optional) – The matplotlib colorscale to use for coloring.

  • show_workflow_inputs (bool, optional) – Whether to include the workflow inputs in the graph.

  • edge_labels (bool, optional) – Whether to add labels to edges. If True, the labels are the key of the input that receives the output of the outgoing node.

  • node_help (bool, optional) – Whether to add the node class help as node metadata so that it can be shown on node hover.

  • notebook (bool, optional) – Whether the network will be plotted in a jupyter notebook.

  • hierarchial (bool, optional) –

    Whether the nodes vertical disposition needs to follow the order with which the nodes take part in the workflow.

    This can help understanding the structure of the workflow, but in some cases it might result in a too tight and hard to read layout.

  • node_props (dict, optional) – Properties to assign to the nodes, on top of the default ones.

  • leafs_props (dict, optional) – Properties to assign to the leaf nodes (those whose output is not connected to another node), on top of the default ones.

  • output_props (dict, optional) – Properties to assign to the output node, on top of the default ones.

  • auto_text_color (bool, optional) – Whether to automatically set the text color of the nodes to white or black depending on the background color.

  • to_export (bool, optional) – Not important for normal use. Whether the notebook is thought to be exported to html. If None, it is taken from the “NODIFY_EXPORT_VIZ” environment variable.

visualize(colorscale: str = 'viridis', show_workflow_inputs: bool = True, edge_labels: bool = True, node_help: bool = True, notebook: bool = False, hierarchial: bool = True, node_props: Dict[str, Any] = {}, inputs_props: Dict[str, Any] = {}, leafs_props: Dict[str, Any] = {}, output_props: Dict[str, Any] = {}, to_export: bool | None = None)[source]

Visualize the workflow’s network in a plot.

The nodes of the graph are the node functions that compose the workflow. The edges represent connections between nodes, where one node’s output is sent to another node’s input.

Parameters:
  • colorscale (str, optional) – The matplotlib colorscale to use for coloring.

  • show_workflow_inputs (bool, optional) – Whether to include the workflow inputs in the graph.

  • edge_labels (bool, optional) – Whether to add labels to edges. If True, the labels are the key of the input that receives the output of the outgoing node.

  • node_help (bool, optional) – Whether to add the node class help as node metadata so that it can be shown on node hover.

  • notebook (bool, optional) – Whether the network will be plotted in a jupyter notebook.

  • hierarchial (bool, optional) –

    Whether the nodes vertical disposition needs to follow the order with which the nodes take part in the workflow.

    This can help understanding the structure of the workflow, but in some cases it might result in a too tight and hard to read layout.

  • node_props (dict, optional) – Properties to assign to the nodes, on top of the default ones.

  • inputs_props (dict, optional) – Properties to assign to the workflow inputs, on top of the default ones.

  • leafs_props (dict, optional) – Properties to assign to the leaf nodes (those whose output is not connected to another node), on top of the default ones.

  • output_props (dict, optional) – Properties to assign to the output node, on top of the default ones.

  • to_export (bool, optional) – Not important for normal use. Whether the notebook is thought to be exported to html. If None, it is taken from the “NODIFY_EXPORT_VIZ” environment variable.