fluxion_ai.workflows.abstract_workflow module
fluxion_ai.core.abstract_workflow
Defines the AbstractWorkflow class, which serves as the base class for defining and executing workflows.
This module is part of the Fluxion framework and provides core functionality for constructing workflows with nodes and managing their execution order.
- class fluxion_ai.workflows.abstract_workflow.AbstractWorkflow(name: str, workflow_dir: str = None)[source]
Bases:
ABCAbstract base class for workflows.
Defines the structure for adding nodes, validating dependencies, determining execution order, and executing the workflow.
- abstractmethod define_workflow()[source]
Define the workflow by adding nodes and dependencies. Must be implemented in subclasses.
- determine_execution_order() List[str][source]
Determine the execution order of nodes based on dependencies.
- Returns:
A list of node names in the order they should be executed.
- Return type:
List[str]
- execute(inputs: Dict[str, Any] = None) Dict[str, Any][source]
Execute the workflow.
- Parameters:
inputs (Dict[str, Any], optional) – Inputs for the workflow.
- Returns:
Results of the workflow execution.
- Return type:
Dict[str, Any]
- get_node_by_name(name: str)[source]
Get a node by name.
- Parameters:
name (str) – The name of the node to retrieve.
- Returns:
The node with the given name.
- Return type:
Node
- get_node_dependencies(node_name: str) Dict[str, Node][source]
Get the dependencies of a node by name.
- Parameters:
node_name (str) – The name of the node.
- Returns:
Dictionary of dependencies for the node.
- Return type:
Dict[str, Node]
- get_node_parents(node_name: str) List[str][source]
Get the parent nodes of a node by name.
- Parameters:
node_name (str) – The name of the node.
- Returns:
List of parent node names for the node.
- Return type:
List[str]
- property nodes
- visualize(output_path: str = 'workflow_graph', format: str = 'png')[source]
Visualizes the workflow as a directed graph.
- Parameters:
output_path (str) – The output path for the generated graph (without extension).
format (str) – The format of the output file (e.g., ‘png’, ‘pdf’).
- Returns:
Path to the generated visualization file.
- Return type:
str