allennlp.common.plugins#

Plugin management.

AllenNLP supports loading "plugins" dynamically. A plugin is just a Python package that is found by AllenNLP with the methods provided in this module.

There are two ways of declaring plugins for discovery:

* Writing the package name to import in a file (typically ".allennlp_plugins", in the current
directory from which the command "allennlp" is run). This is the simplest approach.

* Creating a folder called "allennlp_plugins" that's in the Python path when you run the
"allennlp" command (typically under your project's root directory), then creating a subfolder
with the name you want and creating an "__init__.py" file that imports the code you want (e.g.,
your Python package). This option is preferred when you want to create a pip-installable
package and you want to make your AllenNLP plugin available when users install your package.
See [allennlp-server](https://github.com/allenai/allennlp-server) for an example.

discover_file_plugins#

discover_file_plugins(plugins_filename:str='.allennlp_plugins') -> Iterable[str]

Returns an iterable of the plugins found, declared within a file whose path is plugins_filename.

discover_namespace_plugins#

discover_namespace_plugins(
    namespace_name: str = 'allennlp_plugins',
) -> Iterable[pkgutil.ModuleInfo]

Returns an iterable of the plugins found, declared within the namespace package namespace_name.

discover_plugins#

discover_plugins() -> Iterable[str]

Returns an iterable of the plugins found.

import_plugins#

import_plugins() -> None

Imports the plugins found with discover_plugins().