コード例 #1
0
def test_discovery():
    """
    Tests that this plugin can be discovered via the plugins subsystem when looking for Sweeper
    :return:
    """
    assert RangeSweeper.__name__ in [
        x.__name__ for x in Plugins.discover(Sweeper)
    ]
コード例 #2
0
def test_discovery() -> None:
    # This may seem weird, but it verifies that we can discover this Plugin via
    # the plugins subsystem.
    # The discover method takes a class and return all plugins that implements that class.
    # Typically we would be discovering all plugins that implementing some common interface.
    plugins = Plugins.discover(ExamplePlugin)
    # discovered plugins are actually different class objects, compare by name
    assert ExamplePlugin.__name__ in [x.__name__ for x in plugins]
コード例 #3
0
def test_discovery() -> None:
    """
    Tests that this plugin can be discovered via the plugins subsystem when looking for Launchers
    :return:
    """
    assert ExampleLauncher.__name__ in [
        x.__name__ for x in Plugins.discover(Launcher)
    ]
コード例 #4
0
 def setup(
     self,
     config: DictConfig,
     config_loader: ConfigLoader,
     task_function: TaskFunction,
 ) -> None:
     self.config = config
     self.launcher = Plugins.instantiate_launcher(
         config=config,
         config_loader=config_loader,
         task_function=task_function)
コード例 #5
0
 def _multirun(self, config_file, task_function, overrides):
     # Initial config is loaded without strict (individual job configs may have strict).
     from hydra._internal.plugins import Plugins
     cfg = self.compose_config(config_file=config_file,
                               overrides=overrides,
                               strict=strict,
                               with_log_configuration=True)
     HydraConfig().set_config(cfg)
     sweeper = Plugins.instantiate_sweeper(
         config=cfg,
         config_loader=self.config_loader,
         task_function=task_function)
     # override launcher for using multiprocessing
     sweeper.launcher = ParallelLauncher(ncpu=ncpu)
     sweeper.launcher.setup(config=cfg,
                            config_loader=self.config_loader,
                            task_function=task_function)
     return sweeper.sweep(arguments=cfg.hydra.overrides.task)
コード例 #6
0
def test_discover(plugin_type, expected):
    plugins = Plugins.discover(plugin_type)
    expected_classes = [get_class(c) for c in sorted(expected)]
    for ex in expected_classes:
        assert ex in plugins
コード例 #7
0
 def setup(self, config, config_loader, task_function):
     self.config = config
     self.launcher = Plugins.instantiate_launcher(
         config=config, config_loader=config_loader, task_function=task_function
     )
コード例 #8
0
def test_discover(plugin_type: Type[Plugin], expected: List[str]) -> None:
    plugins = Plugins.discover(plugin_type)
    expected_classes = [get_class(c) for c in sorted(expected)]
    for ex in expected_classes:
        assert ex in plugins