πŸͺ†Nested Configurations

Hypster enables hierarchical configuration management through the hp.nest() method, allowing you to compose complex configurations from smaller, reusable components.

For an in depth tutorial, please check out the article on Medium: Implementing Modular-RAG using Haystack and Hypster

nest Function Signature

def nest(
    config_func: Union[str, Path, "Hypster"],
    *,
    name: Optional[str] = None,
    final_vars: List[str] = [],
    exclude_vars: List[str] = [],
    values: Dict[str, Any] = {}
) -> Dict[str, Any]

Parameters

  • config_func: Either a path to a saved configuration or a Hypster config object

  • name: Optional name for the nested configuration (used in dot notation)

  • final_vars: List of variables that cannot be modified by parent configs

  • exclude_vars: List of variables to exclude from the configuration

  • values: Dictionary of values to override in the nested configuration

Steps for nesting

1

Define a reusable config

2

Save it

3

Define a parent config and use hp.nest

4

Instantiate using dot notation

Configuration Sources

hp.nest() accepts two types of sources:

Path to Configuration File

Direct Configuration Object

Value Assignment

Values for nested configurations can be set using either dot notation or nested dictionaries:

Hierarchical Nesting

Configurations can be nested multiple times to create modular, reusable components:

Passing Values to Nested Configs

Use the values parameter to pass dependent values to nested configuration values:

final_vars and exclude_vars are also supported.

Best Practices

  1. Modular Design

    • Create small, focused configurations for specific components

    • Combine configurations only when there are clear dependencies

    • Keep configurations reusable across different use cases

  2. Clear Naming

  3. Value Dependencies

  4. File Organization

Last updated

Was this helpful?