Hydra Plugins

Introduction

By default the cli supports configurations present in 2 search paths

  1. Default path sail_on_client.configs present in the sail-on-client package.

  2. config-dir provided to the cli by the user.

However there might be use-cases where the configuration files might be present in multiple packages. An example use case would be an agent that is split across multiple python package. In this case, the user could use hydra searchpath plugin to provide additional directories where the configuration files might be available.

Searchpath Plugin

To create add a new search path to cli, use the following steps

  1. Create a hydra_plugins folder at the root directory of your package.

  2. Create a class in it that inherits from SearchPathPlugin. Check the example plugin for more details

    """Add additional search paths to hydra's default searchpath."""
    
    from hydra.core.config_search_path import ConfigSearchPath
    from hydra.plugins.search_path_plugin import SearchPathPlugin
    
    
    class AdditionalSearchPathPlugin(SearchPathPlugin):
        """Plugin to add additional search paths to hydra's default searchpaths."""
    
        def manipulate_search_path(self, search_path: ConfigSearchPath) -> None:
            """
            Add additional search paths for configurations for hydra.
    
            Args:
                search_path: Search path used by hydra
    
            Returns:
                None
            """
            search_path.append(provider="sail-on-client", path="pkg://hydra_plugins.test")
    
  3. The example plugin above registers test directory found under hydra_plugins directory to the search path used by the cli.

  4. Add additional configuration files or overrides in the directory that was registered in the previous step.

  5. Check if the search path has been registered using:

    sail-on-client --info searchpath
    

Note

Using pkg:// syntax requires an __init__.py in the directory specified in the plugin. Please refer to example plugin for a concrete example.

Note

Testing plugins locally can sometimes cause errors with default hydra plugins like colorlor. To resolve the issue use pip install .