haive.core.graph.state_graph.registry

State graph registry for managing graph model instances.

This module provides a singleton registry for managing state graph models in the Haive framework.

Classes

GraphRegistry

Singleton registry for managing state graph models.

Module Contents

class haive.core.graph.state_graph.registry.GraphRegistry

Bases: haive.core.registry.base.AbstractRegistry[haive.core.graph.state_graph.models.state_graph_model.GraphModel]

Singleton registry for managing state graph models.

This registry provides centralized management of GraphModel instances, allowing registration, retrieval, and lifecycle management of graph models throughout the application.

Example

>>> registry = GraphRegistry.get_instance()
>>> graph = GraphModel(name="my_graph", id="graph_123")
>>> registry.register(graph)
>>> retrieved = registry.get(None, "my_graph")

Initialize the registry with empty graph collections.

clear()

Clear all registered graph models from the registry.

Return type:

None

find_by_id(id)

Find a graph model by its unique identifier.

Parameters:

id (str) – The unique identifier of the graph.

Returns:

The graph model if found, None otherwise.

Return type:

Optional[GraphModel]

get(item_type, name)

Get a graph model by name.

Parameters:
  • item_type (Any) – Not used in this implementation.

  • name (str) – The name of the graph to retrieve.

Returns:

The graph model if found, None otherwise.

Return type:

Optional[GraphModel]

get_all(item_type)

Get all registered graph models.

Parameters:

item_type (Any) – Not used in this implementation.

Returns:

Dictionary of all graph models by name.

Return type:

Dict[str, GraphModel]

classmethod get_instance()

Get the singleton instance of the registry.

Returns:

The singleton instance.

Return type:

GraphRegistry

list(item_type)

List all registered graph names.

Parameters:

item_type (Any) – Not used in this implementation.

Returns:

List of all graph names.

Return type:

List[str]

register(item)

Register a graph model in the registry.

Parameters:

item (haive.core.graph.state_graph.models.state_graph_model.GraphModel) – The GraphModel instance to register.

Returns:

The registered graph model.

Return type:

GraphModel