haive.core.graph.patterns.integration

Integration utilities for the pattern system.

from typing import Any, Dict This module provides helper functions for integrating the pattern system with other components of the Haive framework, particularly with the DynamicGraph builder and the NodeFactory.

Functions

apply_branch_to_graph(graph, branch_name, source_node, ...)

Apply a registered branch to a graph.

apply_pattern_to_graph(graph, pattern_name[, ...])

Apply a registered pattern to a graph with enhanced verification.

check_component_compatibility(components, pattern_name)

Check if components are compatible with a pattern.

create_pattern_node_config(pattern_name, node_name, ...)

Create a NodeConfig based on a pattern.

find_compatible_patterns(components)

Find patterns compatible with the given components.

register_callable_processor()

Register the callable processor explicitly.

register_dynamic_graph_integration()

Register integration with the DynamicGraph.

register_integrations()

Register all integrations.

register_node_factory_integration()

Register integration with the NodeFactory.

Module Contents

haive.core.graph.patterns.integration.apply_branch_to_graph(graph, branch_name, source_node, **kwargs)[source]

Apply a registered branch to a graph.

Parameters:
  • graph (Any) – Graph to apply the branch to

  • branch_name (str) – Name of branch to apply

  • source_node (str) – Source node for the branch

  • **kwargs – Branch parameters

Returns:

Modified graph

Return type:

Any

haive.core.graph.patterns.integration.apply_pattern_to_graph(graph, pattern_name, verify_compatibility=True, **kwargs)[source]

Apply a registered pattern to a graph with enhanced verification.

Parameters:
  • graph (Any)

  • pattern_name (str)

  • verify_compatibility (bool)

Return type:

Any

haive.core.graph.patterns.integration.check_component_compatibility(components, pattern_name)[source]

Check if components are compatible with a pattern.

Parameters:
  • components (list[Any]) – List of components to check

  • pattern_name (str) – Name of pattern to check against

Returns:

Tuple of (is_compatible, missing_components)

Return type:

tuple[bool, list[str]]

haive.core.graph.patterns.integration.create_pattern_node_config(pattern_name, node_name, **pattern_params)[source]

Create a NodeConfig based on a pattern.

Note: This requires importing NodeConfig, which is done dynamically to avoid circular imports.

Parameters:
  • pattern_name (str) – Pattern to use as template

  • node_name (str) – Name for the node

  • **pattern_params – Pattern parameters

Returns:

NodeConfig instance

Return type:

Any

haive.core.graph.patterns.integration.find_compatible_patterns(components)[source]

Find patterns compatible with the given components.

Parameters:

components (list[Any]) – List of components to check

Returns:

List of compatible pattern names

Return type:

list[str]

haive.core.graph.patterns.integration.register_callable_processor()[source]

Register the callable processor explicitly.

Return type:

None

haive.core.graph.patterns.integration.register_dynamic_graph_integration()[source]

Register integration with the DynamicGraph.

This enhances the apply_pattern method in DynamicGraph.

Return type:

Any

haive.core.graph.patterns.integration.register_integrations()[source]

Register all integrations.

Return type:

None

haive.core.graph.patterns.integration.register_node_factory_integration()[source]

Register integration with the NodeFactory.

This adds a method to NodeFactory to create nodes from patterns.

Return type:

Any