hydraclick#

Submodules#

Functions#

set_terminal_effect(terminal_effect)

Set a terminal effect animation for displaying help in Click commands.

hydra_command([config_path, config_name, ...])

Integrate Hydra's configuration management capabilities with a Click-based CLI.

Package Contents#

hydraclick.set_terminal_effect(terminal_effect)[source]#

Set a terminal effect animation for displaying help in Click commands.

This function applies a patch to the Click parse_args and get_help_option methods, so the help message is displayed with the specified terminal effect.

Parameters:

terminal_effect (Callable) – A callable that renders the terminal effect.

Example

>>> set_terminal_effect(display_terminal_effect)
hydraclick.hydra_command(config_path=None, config_name='config', version_base=None, as_kwargs=False, preprocess_config=None, print_config=True, resolve=True, use_flogging=True, terminal_effect=omegaconf.MISSING, **flogging_kwargs)[source]#

Integrate Hydra’s configuration management capabilities with a Click-based CLI.

Parameters:
  • config_path (str | Path | None, optional) – The path to the configuration directory. If not specified, the default directory is used.

  • config_name (str | None, optional) – The name of the configuration file (without the .yaml or .yml extension). Defaults to “config”.

  • version_base (str | None, optional) – The base version of the configuration. Defaults to None.

  • as_kwargs (bool, optional) – The mode in which to run the function. If True, the function is run with the configuration as keyword arguments. In this case the configuration is converted to a dictionary before passing it to the function. Defaults to False.

  • preprocess_config (Callable[[DictConfig], DictConfig] | None, optional) – A function to preprocess the configuration before passing it to the main function. Defaults to None.

  • print_config (bool, optional) – Whether to print the configuration before running the function. Defaults to True.

  • resolve (bool, optional) – Whether to resolve the configuration before running the function. Defaults to True.

  • use_flogging (bool, optional) – Whether to use the flogging library for structured logging. Defaults to True.

  • terminal_effect (Callable | None, optional) – The terminal effect function to use when rendering the command help.

  • **flogging_kwargs (Any, optional) – Additional keyword arguments to pass to the flogging.setup function.

Returns:

A Click-compatible command function that can be used as a CLI command.

Return type:

Callable

Notes

  • The command_api function uses several Hydra and Click decorators to provide a rich CLI experience.

  • If use_flogging is enabled but the flogging library is not available, a warning is logged, and flogging is disabled.

  • The preprocess_config function, if provided, allows for custom preprocessing of the configuration before it is passed to the main function.