trinity.manager.config_registry.config_registry module#

class trinity.manager.config_registry.config_registry.ConfigRegistry(name: str)[源代码]#

基类:Registry

A registry for managing configuration settings and their associated functions.

__init__(name: str)[源代码]#
参数:
  • name (str) -- The name of the registry.

  • default_mapping (dict) -- Default mapping from module names to module paths (strings).

set_unfinished_fields(unfinished_fields: set)[源代码]#

Set the unfinished fields to track incomplete configurations.

参数:

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)[源代码]#

Retrieve a configuration function if its visible is met (if any).

参数:

config_name (str) -- Name of the configuration to retrieve.

返回:

The configuration function if visibles are met, else None.

get_check_func(config_name: str)[源代码]#

Get the check function associated with a configuration.

参数:

config_name (str) -- Name of the configuration.

返回:

The check function for the specified configuration.

get_configs(*config_names: str, columns_spec: List[int] = None)[源代码]#

Retrieve and display multiple configurations in Streamlit columns.

参数:
  • *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)[源代码]#

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.

参数:
  • 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.

返回:

A decorator function if config_func is None, else the registered config function.

register_check(check_func: Callable[[Set, str], None] = None)[源代码]#

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.

参数:

check_func (Callable, optional) -- The check function to register.

返回:

A decorator function if check_func is None, else the registered check function.