dataflow.registry.base¶
Base registry system for Haive components.
This module provides the fundamental registry system that all specific registries inherit from. It handles registration, discovery, database persistence, and retrieval of components.
Classes¶
Base class for component registries. |
|
Base model for registry items with metadata. |
Functions¶
Module Contents¶
- class dataflow.registry.base.Registry¶
Bases:
Generic
[T
]Base class for component registries.
This class provides the foundation for registering and retrieving components in a type-safe way with added features like: - Automatic component discovery - Metadata tracking - Supabase integration - Caching
- entries¶
Registry entries
- Type:
Dict[str, RegistryItem]
- _supabase_client¶
Supabase client for persistence
Singleton pattern to ensure only one registry exists.
- create(name, *args, **kwargs)¶
Create an instance of a component.
- Parameters:
name (str) – Name of the component to create
*args – Positional arguments for the constructor
**kwargs – Keyword arguments for the constructor
- Returns:
Instance of the component if found, None otherwise
- Return type:
T | None
- discover_components(search_paths=None)¶
Discover components by scanning package paths.
- get(name, load_if_missing=True)¶
Get a component class by name.
- get_default_search_paths()¶
Get default search paths for component discovery.
This method should be overridden by subclasses to provide specific search paths for their component types.
- get_item_type()¶
Get the default item type for this registry.
This method should be overridden by subclasses to provide the default item type for their registry.
- Returns:
String representing the default item type
- Return type:
- get_metadata(name)¶
Get metadata for a registry item.
- list_items(item_type=None)¶
List all registered items, optionally filtered by type.
- list_names(item_type=None)¶
List all registered item names, optionally filtered by type.
- register(name=None, item_type='component', **metadata)¶
Register a component in the registry.
- Parameters:
- Returns:
Decorator function that registers the component
- Return type:
collections.abc.Callable[[type[T]], type[T]]
Examples
@registry.register(name=”custom_name”, author=”John”) class MyComponent:
…
- class dataflow.registry.base.RegistryItem(/, **data)¶
Bases:
pydantic.BaseModel
Base model for registry items with metadata.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- dataflow.registry.base.create(registry, name, *args, **kwargs)¶
Create a component instance from a registry.
- dataflow.registry.base.get(registry, name)¶
Get a component from a registry.