trinity.manager.config_registry.config_registry module
- class trinity.manager.config_registry.config_registry.ConfigRegistry(name: str)[source]
Bases:
Registry
A registry for managing configuration settings and their associated functions.
- set_unfinished_fields(unfinished_fields: set)[source]
Set the unfinished fields to track incomplete configurations.
- Parameters:
unfinished_fields (set) – Set of field names that are not yet configured.
- property default_config: dict
Get the dictionary of default configuration values.
- get(config_name: str)[source]
Retrieve a configuration function if its visible is met (if any).
- Parameters:
config_name (str) – Name of the configuration to retrieve.
- Returns:
The configuration function if visibles are met, else None.
- get_check_func(config_name: str)[source]
Get the check function associated with a configuration.
- Parameters:
config_name (str) – Name of the configuration.
- Returns:
The check function for the specified configuration.
- get_configs(*config_names: str, columns_spec: List[int] | None = None)[source]
Retrieve and display multiple configurations in Streamlit columns.
- Parameters:
*config_names (str) – Names of configurations to retrieve.
columns_spec (List[int], optional) – Configuration for Streamlit columns.
- register_config(default_value: Any | None = None, config_func: Callable[[None], None] | None = None, visible: Callable[[], bool] | None = None, other_configs: Dict[str, Any] | None = None)[source]
Decorator to register a configuration function.
The function name must start with ‘set_’, and the part after ‘set_’ becomes the config name.
Note: This function will automatically pass key=config_name as an argument to the registered configuration function. Ensure your function accepts this keyword argument.
- Parameters:
default_value (Any, optional) – Default value for the configuration.
config_func (Callable, optional) – The configuration function to register.
visible (Callable, optional) – visible for when the config should be visible.
other_configs (Dict[str, Any], optional) – Additional configurations to register.
- Returns:
A decorator function if config_func is None, else the registered config function.
- register_check(check_func: Callable[[Set, str], None] | None = None)[source]
Decorator to register a check function for a configuration.
The function name must start with ‘check_’, and the part after ‘check_’ should match a config name.
Note: This function will automatically pass key=config_name and unfinished_fields=self.unfinished_fields as an argument to the registered check function. Ensure your function accepts these keyword arguments.
- Parameters:
check_func (Callable, optional) – The check function to register.
- Returns:
A decorator function if check_func is None, else the registered check function.